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

Commit bcee0f7

Browse files
fix: getCurrentSessions for cloud providers using Basic Auth (#1693)
* fix: getCurrentSessions for cloud providers using Basic Auth * use env variable 'BROWSERSTACK_PORT' & set ssl to true if port is 443 * use ternary operator
1 parent ce48856 commit bcee0f7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

app/main/appium.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,11 @@ function connectClientMethodListener () {
330330
}
331331

332332
const getCurrentSessions = _.debounce(async (evt, data) => {
333-
const {host, port, path: appiumPath = '/wd/hub', ssl} = data;
333+
const {host, port, path: appiumPath = '/wd/hub', ssl, username, accessKey} = data;
334334
try {
335-
const res = await request(`http${ssl ? 's' : ''}://${host}:${port}${appiumPath}/sessions`);
335+
const res = username && accessKey
336+
? await request(`http${ssl ? 's' : ''}://${username}:${accessKey}@${host}:${port}${appiumPath}/sessions`)
337+
: await request(`http${ssl ? 's' : ''}://${host}:${port}${appiumPath}/sessions`);
336338
evt.sender.send('appium-client-get-sessions-response', {res});
337339
} catch (e) {
338340
evt.sender.send('appium-client-get-sessions-fail');

app/renderer/actions/Session.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ export function newSession (caps, attachSessId = null) {
245245
https = session.server.perfecto.ssl = false;
246246
break;
247247
case ServerTypes.browserstack:
248-
host = process.env.BROWSERSTACK_HOST || 'hub-cloud.browserstack.com';
249-
port = session.server.browserstack.port = 443;
248+
host = session.server.browserstack.hostname = process.env.BROWSERSTACK_HOST || 'hub-cloud.browserstack.com';
249+
port = session.server.browserstack.port = process.env.BROWSERSTACK_PORT || 443;
250250
path = session.server.browserstack.path = '/wd/hub';
251251
username = session.server.browserstack.username || process.env.BROWSERSTACK_USERNAME;
252252
desiredCapabilities['browserstack.source'] = 'appiumdesktop';
@@ -259,7 +259,7 @@ export function newSession (caps, attachSessId = null) {
259259
});
260260
return;
261261
}
262-
https = session.server.browserstack.ssl = true;
262+
https = session.server.browserstack.ssl = (parseInt(port, 10) === 443);
263263
break;
264264
case ServerTypes.bitbar:
265265
host = process.env.BITBAR_HOST || 'appium.bitbar.com';
@@ -599,7 +599,12 @@ export function getRunningSessions () {
599599
dispatch({type: GET_SESSIONS_DONE});
600600
} else {
601601
ipcRenderer.send('appium-client-get-sessions', {
602-
host: serverInfo.hostname, port: serverInfo.port, path: serverInfo.path, ssl: serverInfo.ssl
602+
host: serverInfo.hostname,
603+
port: serverInfo.port,
604+
path: serverInfo.path,
605+
ssl: serverInfo.ssl,
606+
username: serverInfo.username,
607+
accessKey: serverInfo.accessKey
603608
});
604609
ipcRenderer.once('appium-client-get-sessions-response', (evt, e) => {
605610
const res = JSON.parse(e.res);

0 commit comments

Comments
 (0)