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

fix: getCurrentSessions for cloud providers using Basic Auth #1693

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/main/appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,15 @@ 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;
let res;
try {
const res = await request(`http${ssl ? 's' : ''}://${host}:${port}${appiumPath}/sessions`);
if (username && accessKey) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made these changes

// Basic Authorization for some cloud providers
res = await request(`http${ssl ? 's' : ''}://${username}:${accessKey}@${host}:${port}${appiumPath}/sessions`);
} else {
res = 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