Bug 1369827 - Fix socksVersion key in proxy capabilities. draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 23 Aug 2017 11:47:01 +0200
changeset 651184 8c5b5512635539b2d62472b3e67d6664597fa0bd
parent 651183 8384fa719fb23158acb0fad21a853bf10bfb6878
child 651185 d06972257836b055981d34b263925dc4d70a1423
push id75622
push userbmo:hskupin@gmail.com
push dateWed, 23 Aug 2017 09:48:18 +0000
bugs1369827
milestone57.0a1
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
testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
testing/marionette/session.js
testing/marionette/test_session.js
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
@@ -81,24 +81,24 @@ class TestProxyCapabilities(MarionetteTe
 
     def test_proxy_type_manual_socks(self):
         proxy_port = 4444
         proxy_host = "marionette.test"
         proxy_hostname = "{}:{}".format(proxy_host, proxy_port)
         capabilities = {"proxy": {
             "proxyType": "manual",
             "socksProxy": proxy_hostname,
-            "socksProxyVersion": 4,
+            "socksVersion": 4,
         }}
 
         self.marionette.start_session(capabilities)
         self.assertEqual(self.marionette.session_capabilities["proxy"],
                          capabilities["proxy"])
 
-    def tst_proxy_type_manual_socks_requires_version(self):
+    def test_proxy_type_manual_socks_requires_version(self):
         proxy_port = 4444
         proxy_host = "marionette.test"
         proxy_hostname = "{}:{}".format(proxy_host, proxy_port)
         capabilities = {"proxy": {
             "proxyType": "manual",
             "socksProxy": proxy_hostname,
             "socksUsername": "cake",
             "socksPassword": "made with love"
@@ -140,8 +140,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
@@ -262,18 +262,17 @@ session.Proxy = class {
         if (typeof json.httpProxy != "undefined") {
           [p.httpProxy, p.httpProxyPort] = fromHost(json.httpProxy);
         }
         if (typeof json.sslProxy != "undefined") {
           [p.sslProxy, p.sslProxyPort] = fromHost(json.sslProxy);
         }
         if (typeof json.socksProxy != "undefined") {
           [p.socksProxy, p.socksProxyPort] = fromHost(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}`);
     }
 
@@ -298,17 +297,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
@@ -185,16 +185,21 @@ add_test(function test_Proxy_toJSON() {
 
   for (let proxy of ["ftpProxy", "httpProxy", "sslProxy", "socksProxy"]) {
     let manual = new session.Proxy();
     manual.proxyType = "manual";
 
     let expected = {proxyType: "manual"}
     expected[proxy] = "foo"
 
+    if (proxy == "socksProxy") {
+      manual.socksVersion = 5;
+      expected.socksVersion = 5;
+    }
+
     manual[proxy] = "foo";
     deepEqual(manual.toJSON(), expected);
 
     manual[`${proxy}Port`] = 42;
     expected[proxy] = "foo:42"
     deepEqual(manual.toJSON(), expected);
   }
 
@@ -225,18 +230,18 @@ add_test(function test_Proxy_fromJSON() 
         "foo:-1", "foo/test", "foo#42", "foo?foo=bar"]) {
       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;
     }
 
     for (let host of ["foo", "foo.bar:80", "127.0.0.1", "127.0.0.1:42",
         "[2001:db8::1]", "[2001:db8::1]:42"]) {
       manual[proxy] = host;
       expected[proxy] = host;
 
       deepEqual(expected, session.Proxy.fromJSON(manual).toJSON());