A few of my tests require access to modify the HTTP Request headers. Unfortunately, Selenium hides access to them to allow for portability, and to better emulate what “users” generally can change. To work around this a Firefox extension can be used and configured at runtime for this purpose.

NOTE: for Maven, you need to place a copy of the .xpi file referenced into the /src/test/resources folder for Selenium to locate it.

In the example below, I’m setting the HTTP Header for “DNT” to “1”.
 public FirefoxDriver createFirefoxDriver() throws URISyntaxException, IOException { // Specify the install location (if not default) System.setProperty("webdriver.firefox.bin","C:\\path\\to\\Firefox.exe"); // Prevent Console log "noise" from the Selenium Firefox plugin System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "OFF"); System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "OFF");

 final FirefoxProfile profile = new FirefoxProfile(); final URL url = this.getClass().getResource("/modify_headers-0.7.1.1-fx.xpi"); final File modifyHeaders = modifyHeaders = new File(url.toURI()); profile.setEnableNativeEvents(false); profile.addExtension(modifyHeaders); profile.setPreference("modifyheaders.headers.count", 1); profile.setPreference("modifyheaders.headers.action0", "Add"); profile.setPreference("modifyheaders.headers.name0", "DNT"); profile.setPreference("modifyheaders.headers.value0", "1"); profile.setPreference("modifyheaders.headers.enabled0", true); profile.setPreference("modifyheaders.config.active", true); profile.setPreference("modifyheaders.config.alwaysOn", true); 

 final DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName("firefox"); capabilities.setPlatform(org.openqa.selenium.Platform.ANY); capabilities.setCapability(FirefoxDriver.PROFILE, profile); return new FirefoxDriver(capabilities); } 

## Comcast Business Class gateway forwarding port 22 for SSH

For as long as I’ve had Comcast, and other providers for that matter, I’ve been able to configure my internet gateway/router to allow port 22 (SSH) access to an internal machine. It came as a surprise to me earlier this week that I was blocked when I tried to use their web admin console to change the internal forwarding to a newer machine. As usual, Technical Support was less that helpful and said that it was not possible to do so, and never should have been as Comcast uses that port to administer the gateway. To make matters more disturbing, I was told that I could not have similar SSH access to the gateway, and that replacing their hardware, while permitted, would prevent my use of a static IP.

Back to the solution, as I know that I had only setup this forwarding about a year ago, and it was working only minutes before I tried to change it, I knew that the configuration was possible if I could figure out how it was being blocked. The message in the web console was a javascript alert(); and gave me a starting point. I opened up Firefox and used Firebug to look for the message. Here are a few interesting findings from:

http://HOSTNAME/user/feat-firewall-port-forward-edit.asp

var RemoteManagementPortsCgiBase = “8080,8080,1\|8181,8181,1\|2323,2323,1\|22,22,1\|”;

msg += “Public Port Range conflict with Remote Management Ports.\n”;

if (msg.length > 1)
{
return false;
}
return true;
}

If you even a little bit of javascript (or simple computer programming for that matter), the solution is clear…. if the ‘msg’ value is empty you will not see the alert or be prevented from making the change you desire.

Lesson to be learned by the Comcast developers (or most likely = subcontractors), always validate submitted form data in your application code, NEVER rely upon javascript alone to verify user entered data!

I also find it interesting that they are also preventing 8080, 8081 and 2323… perhaps that’s their other back doors in these gateways for their access. The same approach should work for those ports if you need it!

 cd /opt/jboss-x.x.x/jboss-as/server/default/conf/props vi jmx-console-users.properties admin=admin