Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: getCurrentSessions for cloud providers using Basic Auth (#1693)
Browse files Browse the repository at this point in the history
* fix: getCurrentSessions for cloud providers using Basic Auth

* use env variable 'BROWSERSTACK_PORT' & set ssl to true if port is 443

* use ternary operator
  • Loading branch information
huzaifaiftikhar authored Feb 15, 2021
1 parent ce48856 commit bcee0f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions app/main/appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,11 @@ function connectClientMethodListener () {
}

const getCurrentSessions = _.debounce(async (evt, data) => {
const {host, port, path: appiumPath = '/wd/hub', ssl} = data;
const {host, port, path: appiumPath = '/wd/hub', ssl, username, accessKey} = data;
try {
const res = await request(`http${ssl ? 's' : ''}://${host}:${port}${appiumPath}/sessions`);
const res = username && accessKey
? await request(`http${ssl ? 's' : ''}://${username}:${accessKey}@${host}:${port}${appiumPath}/sessions`)
: await request(`http${ssl ? 's' : ''}://${host}:${port}${appiumPath}/sessions`);
evt.sender.send('appium-client-get-sessions-response', {res});
} catch (e) {
evt.sender.send('appium-client-get-sessions-fail');
Expand Down
13 changes: 9 additions & 4 deletions app/renderer/actions/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ export function newSession (caps, attachSessId = null) {
https = session.server.perfecto.ssl = false;
break;
case ServerTypes.browserstack:
host = process.env.BROWSERSTACK_HOST || 'hub-cloud.browserstack.com';
port = session.server.browserstack.port = 443;
host = session.server.browserstack.hostname = process.env.BROWSERSTACK_HOST || 'hub-cloud.browserstack.com';
port = session.server.browserstack.port = process.env.BROWSERSTACK_PORT || 443;
path = session.server.browserstack.path = '/wd/hub';
username = session.server.browserstack.username || process.env.BROWSERSTACK_USERNAME;
desiredCapabilities['browserstack.source'] = 'appiumdesktop';
Expand All @@ -259,7 +259,7 @@ export function newSession (caps, attachSessId = null) {
});
return;
}
https = session.server.browserstack.ssl = true;
https = session.server.browserstack.ssl = (parseInt(port, 10) === 443);
break;
case ServerTypes.bitbar:
host = process.env.BITBAR_HOST || 'appium.bitbar.com';
Expand Down Expand Up @@ -599,7 +599,12 @@ export function getRunningSessions () {
dispatch({type: GET_SESSIONS_DONE});
} else {
ipcRenderer.send('appium-client-get-sessions', {
host: serverInfo.hostname, port: serverInfo.port, path: serverInfo.path, ssl: serverInfo.ssl
host: serverInfo.hostname,
port: serverInfo.port,
path: serverInfo.path,
ssl: serverInfo.ssl,
username: serverInfo.username,
accessKey: serverInfo.accessKey
});
ipcRenderer.once('appium-client-get-sessions-response', (evt, e) => {
const res = JSON.parse(e.res);
Expand Down

0 comments on commit bcee0f7

Please sign in to comment.