Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py b/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
- --- a/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
- +++ b/testing/marionette/harness/marionette_harness/tests/unit/test_proxy.py
- @@ -61,16 +61,29 @@ class TestProxyCapabilities(MarionetteTe
- "socksProxy": proxy_hostname,
- "socksVersion": 4,
- }}
- self.marionette.start_session(capabilities)
- self.assertEqual(self.marionette.session_capabilities["proxy"],
- capabilities["proxy"])
- + def test_proxy_type_manual_with_authentication(self):
- + proxy_hostname = "marionette.test"
- + username = "username"
- + password = "password"
- + capabilities = {"proxy": {
- + "proxyType": "manual",
- + "ftpProxy": "{}:{}@{}:21".format(username, password, proxy_hostname)
- + }}
- +
- + 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,
- }}
- diff --git a/testing/marionette/session.js b/testing/marionette/session.js
- --- a/testing/marionette/session.js
- +++ b/testing/marionette/session.js
- @@ -225,23 +225,29 @@ session.Proxy = class {
- if (!Number.isInteger(port)) {
- if (scheme === "socks") {
- port = null;
- } else {
- port = Services.io.getProtocolHandler(scheme).defaultPort;
- }
- }
- - if (url.username != "" ||
- - url.password != "" ||
- - url.pathname != "/" ||
- + if (url.username !== "") {
- + let login = Cc["@mozilla.org/login-manager/loginInfo;1"]
- + .createInstance(Ci.nsILoginInfo);
- + login.init(`${scheme}://${url.hostname}`, null, url.hostname, url.username, url.password, "", "");
- + // dump(`Adding login for ${scheme}://${url.hostname}`);
- + Services.logins.addLogin(login);
- + }
- +
- + if (url.pathname != "/" ||
- url.search != "" ||
- url.hash != "") {
- throw new InvalidArgumentError(
- - `${host} was not of the form host[:port]`);
- + `${host} was not of the form [username:password@]host[:port]`);
- }
- return [url.hostname, port];
- }
- let p = new session.Proxy();
- if (typeof json == "undefined" || json === null) {
- return p;
- @@ -293,35 +299,41 @@ session.Proxy = class {
- return p;
- }
- /**
- * @return {Object.<string, (number|string)>}
- * JSON serialisation of proxy object.
- */
- toJSON() {
- - function toHost(hostname, port) {
- + function toHost(scheme, hostname, port) {
- if (!hostname) {
- return null;
- }
- + let logins = Services.logins.findLogins({}, `${scheme}://${hostname}`, "", "", {});
- + if (logins.length) {
- + let login = logins[0];
- + hostname = `${login.username}:${login.password}@${hostname}`;
- + }
- +
- if (port != null) {
- return `${hostname}:${port}`;
- }
- return hostname;
- }
- return marshal({
- proxyType: this.proxyType,
- - ftpProxy: toHost(this.ftpProxy, this.ftpProxyPort),
- - httpProxy: toHost(this.httpProxy, this.httpProxyPort),
- + ftpProxy: toHost("ftp", this.ftpProxy, this.ftpProxyPort),
- + httpProxy: toHost("http", this.httpProxy, this.httpProxyPort),
- noProxy: this.noProxy,
- - sslProxy: toHost(this.sslProxy, this.sslProxyPort),
- - socksProxy: toHost(this.socksProxy, this.socksProxyPort),
- + sslProxy: toHost("https", this.sslProxy, this.sslProxyPort),
- + socksProxy: toHost("socks", this.socksProxy, this.socksProxyPort),
- socksVersion: this.socksVersion,
- proxyAutoconfigUrl: this.proxyAutoconfigUrl,
- });
- }
- toString() { return "[object session.Proxy]"; }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement