Skip to content

Commit 2cffd30

Browse files
authored
fix(ignoressl): pass ignore ssl down to the binary and config source (#208)
closes #207 and closes #221
1 parent 83b7be0 commit 2cffd30

10 files changed

+37
-19
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ selenium_test/
55
typings/
66
.idea/
77
npm-debug.log
8+
.vscode

e2e_spec/android_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as os from 'os';
22
import * as webdriver from 'selenium-webdriver';
33
import {AndroidSDK} from '../lib/binaries'
44

5-
let versions: { androidsdk: string, appium: string } = require('../config.json').webdriverVersions;
5+
let versions: {androidsdk: string, appium: string} = require('../config.json').webdriverVersions;
66

77
describe('browser smoke tests', () => {
88
it('should be able to boot up android chrome', (done) => {

lib/binaries/binary.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,24 @@ export abstract class Binary {
8181
/**
8282
* Gets the url to download the file set by the version. This will use the XML if available.
8383
* If not, it will download from an existing url.
84+
*
85+
* @param {string} version The version we are looking for. This could also be 'latest'.
86+
* @param {opt_proxy} string Option to get proxy URL.
87+
* @param {opt_ignoreSSL} boolean Option to ignore SSL.
8488
*/
85-
getUrl(version?: string): Promise<BinaryUrl> {
89+
getUrl(version?: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
90+
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
91+
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
8692
if (this.alternativeDownloadUrl != null) {
8793
return Promise.resolve({url: '', version: ''});
8894
} else {
8995
return this.getVersionList().then(() => {
9096
version = version || Config.binaryVersions()[this.id()];
91-
return this.configSource.getUrl(version).then(binaryUrl => {
92-
this.versionCustom = binaryUrl.version;
93-
return {url: binaryUrl.url, version: binaryUrl.version};
94-
});
97+
return this.configSource.getUrl(version, this.opt_proxy, this.opt_ignoreSSL)
98+
.then(binaryUrl => {
99+
this.versionCustom = binaryUrl.version;
100+
return {url: binaryUrl.url, version: binaryUrl.version};
101+
});
95102
});
96103
}
97104
}

lib/binaries/chrome_xml.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class ChromeXml extends XmlConfigSource {
1010
super('chrome', Config.cdnUrls()['chrome']);
1111
}
1212

13-
getUrl(version: string): Promise<BinaryUrl> {
13+
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
14+
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
15+
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
1416
if (version === 'latest') {
1517
return this.getLatestChromeDriverVersion();
1618
} else {

lib/binaries/config_source.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export abstract class ConfigSource {
1414
opt_ignoreSSL: boolean;
1515
opt_proxy: string;
1616

17-
abstract getUrl(version: string): Promise<{url: string, version: string}>;
17+
abstract getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean):
18+
Promise<{url: string, version: string}>;
1819
abstract getVersionList(): Promise<string[]>;
1920
}
2021

@@ -38,7 +39,7 @@ export abstract class XmlConfigSource extends ConfigSource {
3839
if (content != null) {
3940
return Promise.resolve(content);
4041
}
41-
return this.requestXml(this.xmlUrl, this.opt_ignoreSSL, this.opt_proxy).then(text => {
42+
return this.requestXml().then(text => {
4243
let xml = this.convertXml2js(text);
4344
fs.writeFileSync(fileName, text);
4445
return xml;
@@ -60,11 +61,11 @@ export abstract class XmlConfigSource extends ConfigSource {
6061
}
6162
}
6263

63-
private requestXml(url: string, opt_ignoreSSL: boolean, opt_proxy: string): Promise<string> {
64+
private requestXml(): Promise<string> {
6465
return new Promise<string>((resolve, reject) => {
65-
let options = HttpUtils.initOptions(url);
66-
options = HttpUtils.optionsSSL(options, opt_ignoreSSL);
67-
options = HttpUtils.optionsProxy(options, url, opt_proxy);
66+
let options = HttpUtils.initOptions(this.xmlUrl);
67+
options = HttpUtils.optionsSSL(options, this.opt_ignoreSSL);
68+
options = HttpUtils.optionsProxy(options, this.xmlUrl, this.opt_proxy);
6869

6970
let req = request(options);
7071
req.on('response', response => {

lib/binaries/gecko_driver_github.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class GeckoDriverGithub extends GithubApiConfigSource {
1010
super('gecko', 'https://api.github.com/repos/mozilla/geckodriver/releases');
1111
}
1212

13-
getUrl(version: string): Promise<BinaryUrl> {
13+
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
14+
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
15+
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
1416
if (version === 'latest') {
1517
return this.getLatestGeckoDriverVersion();
1618
} else {

lib/binaries/iedriver_xml.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class IEDriverXml extends XmlConfigSource {
1010
super('iedriver', Config.cdnUrls()['ie']);
1111
}
1212

13-
getUrl(version: string): Promise<BinaryUrl> {
13+
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
14+
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
15+
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
1416
if (version === 'latest') {
1517
return this.getLatestIEDriverVersion();
1618
} else {

lib/binaries/standalone_xml.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export class StandaloneXml extends XmlConfigSource {
1010
super('standalone', Config.cdnUrls()['selenium']);
1111
}
1212

13-
getUrl(version: string): Promise<BinaryUrl> {
13+
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
14+
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
15+
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
1416
if (version === 'latest') {
1517
return this.getLatestStandaloneVersion();
1618
} else {

lib/files/file_manager.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ export class FileManager {
178178
let downloaded: BinaryMap<DownloadedBinary> = FileManager.downloadedBinaries(outputDir);
179179
let contentLength = 0;
180180

181-
binary.getUrl(binary.version()).then(fileUrl => {
181+
// Pass options down to binary to make request to get the latest version to download.
182+
binary.getUrl(binary.version(), opt_proxy, opt_ignoreSSL).then(fileUrl => {
182183
binary.versionCustom = fileUrl.version;
183184
let filePath = path.resolve(outputDir, binary.filename());
184185
let fileName = binary.filename();

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"@types/form-data": "^0.0.33",
5050
"@types/glob": "^5.0.29",
5151
"@types/ini": "^1.3.28",
52-
"@types/jasmine": "^2.5.37",
52+
"@types/jasmine": "^2.5.43",
5353
"@types/minimatch": "^2.0.28",
5454
"@types/minimist": "^1.1.28",
5555
"@types/node": "^7.0.4",
@@ -65,7 +65,7 @@
6565
"jasmine": "^2.4.1",
6666
"run-sequence": "^1.1.5",
6767
"selenium-webdriver": "~3.0.1",
68-
"typescript": "~2.0.0"
68+
"typescript": "~2.2.0"
6969
},
7070
"engines": {
7171
"node": ">=6.9.x"

0 commit comments

Comments
 (0)