Bug 1369827 - Fix socksVersion key in proxy capabilities.
In the spec the socksProxyVersion key has been renamed to
socksVersion. Marionette has to be adjusted for this change.
MozReview-Commit-ID: Ep3zNZLKxXl
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
@@ -53,16 +53,36 @@ class TestProxyCapabilities(MarionetteTe
def test_proxy_type_manual_without_port(self):
proxy_hostname = "marionette.test"
capabilities = {"proxy": {
"proxyType": "manual",
"ftpProxy": "{}:21".format(proxy_hostname),
"httpProxy": "{}:80".format(proxy_hostname),
"sslProxy": "{}:443".format(proxy_hostname),
+ "socksProxy": proxy_hostname,
+ "socksVersion": 4,
+ }}
+
+ self.marionette.start_session(capabilities)
+ self.assertEqual(self.marionette.session_capabilities["proxy"],
+ capabilities["proxy"])
+
+ def test_proxy_type_manual_socks_requires_version(self):
+ proxy_port = 4444
+ proxy_hostname = "marionette.test"
+ proxy_host = "{}:{}".format(proxy_hostname, proxy_port)
+ capabilities = {"proxy": {
+ "proxyType": "manual",
+ "socksProxy": proxy_host,
+ }}
+
+ with self.assertRaises(errors.SessionNotCreatedException):
+ self.marionette.start_session(capabilities)
+
def test_proxy_type_pac(self):
pac_url = "http://marionette.test"
capabilities = {"proxy": {"proxyType": "pac", "proxyAutoconfigUrl": pac_url}}
self.marionette.start_session(capabilities)
self.assertEqual(self.marionette.session_capabilities["proxy"],
capabilities["proxy"])
@@ -91,8 +111,14 @@ class TestProxyCapabilities(MarionetteTe
def test_invalid_autoconfig_url_for_pac(self):
with self.assertRaises(errors.SessionNotCreatedException):
self.marionette.start_session({"proxy": {"proxyType": "pac"}})
with self.assertRaises(errors.SessionNotCreatedException):
self.marionette.start_session({"proxy": {"proxyType": "pac",
"proxyAutoconfigUrl": None}})
+
+ def test_missing_socks_version_for_manual(self):
+ capabilities = {"proxy": {"proxyType": "manual", "socksProxy": "marionette.test"}}
+
+ with self.assertRaises(errors.SessionNotCreatedException):
+ self.marionette.start_session(capabilities)
--- a/testing/marionette/session.js
+++ b/testing/marionette/session.js
@@ -271,18 +271,17 @@ session.Proxy = class {
if (typeof json.httpProxy != "undefined") {
[p.httpProxy, p.httpProxyPort] = fromHost("http", json.httpProxy);
}
if (typeof json.sslProxy != "undefined") {
[p.sslProxy, p.sslProxyPort] = fromHost("https", json.sslProxy);
}
if (typeof json.socksProxy != "undefined") {
[p.socksProxy, p.socksProxyPort] = fromHost("socks", json.socksProxy);
- p.socksProxyVersion = assert.positiveInteger(
- json.socksProxyVersion);
+ p.socksVersion = assert.positiveInteger(json.socksVersion);
}
break;
default:
throw new InvalidArgumentError(
`Invalid type of proxy: ${p.proxyType}`);
}
@@ -307,17 +306,17 @@ session.Proxy = class {
}
return marshal({
proxyType: this.proxyType,
ftpProxy: toHost(this.ftpProxy, this.ftpProxyPort),
httpProxy: toHost(this.httpProxy, this.httpProxyPort),
sslProxy: toHost(this.sslProxy, this.sslProxyPort),
socksProxy: toHost(this.socksProxy, this.socksProxyPort),
- socksProxyVersion: this.socksProxyVersion,
+ socksVersion: this.socksVersion,
proxyAutoconfigUrl: this.proxyAutoconfigUrl,
});
}
toString() { return "[object session.Proxy]"; }
};
/** WebDriver session capabilities representation. */
--- a/testing/marionette/test_session.js
+++ b/testing/marionette/test_session.js
@@ -184,16 +184,21 @@ add_test(function test_Proxy_toJSON() {
deepEqual(p.toJSON(), {proxyType: "manual"});
for (let proxy of ["ftpProxy", "httpProxy", "sslProxy", "socksProxy"]) {
let expected = {proxyType: "manual"}
let manual = new session.Proxy();
manual.proxyType = "manual";
+ if (proxy == "socksProxy") {
+ manual.socksVersion = 5;
+ expected.socksVersion = 5;
+ }
+
// without port
manual[proxy] = "foo";
expected[proxy] = "foo"
deepEqual(manual.toJSON(), expected);
// with port
manual[proxy] = "foo";
manual[`${proxy}Port`] = 0;
@@ -233,18 +238,18 @@ add_test(function test_Proxy_fromJSON()
"2001:db8::1"]) {
manual[proxy] = host;
Assert.throws(() => session.Proxy.fromJSON(manual),
InvalidArgumentError);
}
let expected = {"proxyType": "manual"};
if (proxy == "socksProxy") {
- manual.socksProxyVersion = 5;
- expected.socksProxyVersion = 5;
+ manual.socksVersion = 5;
+ expected.socksVersion = 5;
}
// valid proxy hosts with port
for (let host of ["foo:1", "foo:80", "foo:443", "foo:65535",
"127.0.0.1:42", "[2001:db8::1]:42"]) {
manual[proxy] = host;
expected[proxy] = host;