Skip to content

Commit

Permalink
fix(ignoressl): pass ignore ssl down to the binary and config source (#…
Browse files Browse the repository at this point in the history
…208)

closes #207 and closes #221
  • Loading branch information
cnishina authored Mar 4, 2017
1 parent 83b7be0 commit 2cffd30
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ selenium_test/
typings/
.idea/
npm-debug.log
.vscode
2 changes: 1 addition & 1 deletion e2e_spec/android_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as os from 'os';
import * as webdriver from 'selenium-webdriver';
import {AndroidSDK} from '../lib/binaries'

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

describe('browser smoke tests', () => {
it('should be able to boot up android chrome', (done) => {
Expand Down
17 changes: 12 additions & 5 deletions lib/binaries/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,24 @@ export abstract class Binary {
/**
* Gets the url to download the file set by the version. This will use the XML if available.
* If not, it will download from an existing url.
*
* @param {string} version The version we are looking for. This could also be 'latest'.
* @param {opt_proxy} string Option to get proxy URL.
* @param {opt_ignoreSSL} boolean Option to ignore SSL.
*/
getUrl(version?: string): Promise<BinaryUrl> {
getUrl(version?: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
if (this.alternativeDownloadUrl != null) {
return Promise.resolve({url: '', version: ''});
} else {
return this.getVersionList().then(() => {
version = version || Config.binaryVersions()[this.id()];
return this.configSource.getUrl(version).then(binaryUrl => {
this.versionCustom = binaryUrl.version;
return {url: binaryUrl.url, version: binaryUrl.version};
});
return this.configSource.getUrl(version, this.opt_proxy, this.opt_ignoreSSL)
.then(binaryUrl => {
this.versionCustom = binaryUrl.version;
return {url: binaryUrl.url, version: binaryUrl.version};
});
});
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/binaries/chrome_xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export class ChromeXml extends XmlConfigSource {
super('chrome', Config.cdnUrls()['chrome']);
}

getUrl(version: string): Promise<BinaryUrl> {
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
if (version === 'latest') {
return this.getLatestChromeDriverVersion();
} else {
Expand Down
13 changes: 7 additions & 6 deletions lib/binaries/config_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export abstract class ConfigSource {
opt_ignoreSSL: boolean;
opt_proxy: string;

abstract getUrl(version: string): Promise<{url: string, version: string}>;
abstract getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean):
Promise<{url: string, version: string}>;
abstract getVersionList(): Promise<string[]>;
}

Expand All @@ -38,7 +39,7 @@ export abstract class XmlConfigSource extends ConfigSource {
if (content != null) {
return Promise.resolve(content);
}
return this.requestXml(this.xmlUrl, this.opt_ignoreSSL, this.opt_proxy).then(text => {
return this.requestXml().then(text => {
let xml = this.convertXml2js(text);
fs.writeFileSync(fileName, text);
return xml;
Expand All @@ -60,11 +61,11 @@ export abstract class XmlConfigSource extends ConfigSource {
}
}

private requestXml(url: string, opt_ignoreSSL: boolean, opt_proxy: string): Promise<string> {
private requestXml(): Promise<string> {
return new Promise<string>((resolve, reject) => {
let options = HttpUtils.initOptions(url);
options = HttpUtils.optionsSSL(options, opt_ignoreSSL);
options = HttpUtils.optionsProxy(options, url, opt_proxy);
let options = HttpUtils.initOptions(this.xmlUrl);
options = HttpUtils.optionsSSL(options, this.opt_ignoreSSL);
options = HttpUtils.optionsProxy(options, this.xmlUrl, this.opt_proxy);

let req = request(options);
req.on('response', response => {
Expand Down
4 changes: 3 additions & 1 deletion lib/binaries/gecko_driver_github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export class GeckoDriverGithub extends GithubApiConfigSource {
super('gecko', 'https://api.github.com/repos/mozilla/geckodriver/releases');
}

getUrl(version: string): Promise<BinaryUrl> {
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
if (version === 'latest') {
return this.getLatestGeckoDriverVersion();
} else {
Expand Down
4 changes: 3 additions & 1 deletion lib/binaries/iedriver_xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export class IEDriverXml extends XmlConfigSource {
super('iedriver', Config.cdnUrls()['ie']);
}

getUrl(version: string): Promise<BinaryUrl> {
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
if (version === 'latest') {
return this.getLatestIEDriverVersion();
} else {
Expand Down
4 changes: 3 additions & 1 deletion lib/binaries/standalone_xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export class StandaloneXml extends XmlConfigSource {
super('standalone', Config.cdnUrls()['selenium']);
}

getUrl(version: string): Promise<BinaryUrl> {
getUrl(version: string, opt_proxy?: string, opt_ignoreSSL?: boolean): Promise<BinaryUrl> {
this.opt_proxy = opt_proxy == undefined ? this.opt_proxy : opt_proxy;
this.opt_ignoreSSL = opt_ignoreSSL == undefined ? this.opt_ignoreSSL : opt_ignoreSSL;
if (version === 'latest') {
return this.getLatestStandaloneVersion();
} else {
Expand Down
3 changes: 2 additions & 1 deletion lib/files/file_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ export class FileManager {
let downloaded: BinaryMap<DownloadedBinary> = FileManager.downloadedBinaries(outputDir);
let contentLength = 0;

binary.getUrl(binary.version()).then(fileUrl => {
// Pass options down to binary to make request to get the latest version to download.
binary.getUrl(binary.version(), opt_proxy, opt_ignoreSSL).then(fileUrl => {
binary.versionCustom = fileUrl.version;
let filePath = path.resolve(outputDir, binary.filename());
let fileName = binary.filename();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@types/form-data": "^0.0.33",
"@types/glob": "^5.0.29",
"@types/ini": "^1.3.28",
"@types/jasmine": "^2.5.37",
"@types/jasmine": "^2.5.43",
"@types/minimatch": "^2.0.28",
"@types/minimist": "^1.1.28",
"@types/node": "^7.0.4",
Expand All @@ -65,7 +65,7 @@
"jasmine": "^2.4.1",
"run-sequence": "^1.1.5",
"selenium-webdriver": "~3.0.1",
"typescript": "~2.0.0"
"typescript": "~2.2.0"
},
"engines": {
"node": ">=6.9.x"
Expand Down

0 comments on commit 2cffd30

Please sign in to comment.