Skip to content

Commit da311f5

Browse files
waggledansamckenzie132budziam
authored
sc5 support resolves #240 (#265)
* sc: use sc api to retrieve SC download url * update endpoint to retrive SC download * always extend metadata with runner when starting sauce connect * fix downloading custom sauce connect version --------- Co-authored-by: Alana McKenzie <[email protected]> Co-authored-by: Michał Budziak <[email protected]>
1 parent d916ab1 commit da311f5

20 files changed

+623
-807
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ or start Sauce Connect Proxy in EU datacenter:
104104
# start Sauce Connect tunnel for eu-central-1 region
105105
$ sl sc --region eu --tunnel-name "my-tunnel"
106106
# run a specific Sauce Connect version
107-
$ sl sc --scVersion 4.9.1
107+
$ sl sc --scVersion 5.2.2
108108
# see all available Sauce Connect parameters via:
109109
$ sl sc --help
110110
```
111111
112-
You can see all available Sauce Connect parameters on the [Sauce Labs Docs](https://docs.saucelabs.com/dev/cli/sauce-connect-proxy/).
112+
You can see all available Sauce Connect parameters on the [Sauce Labs Docs](https://docs.saucelabs.com/dev/cli/sauce-connect-5/run/).
113113
114114
### As NPM Package
115115
@@ -179,7 +179,7 @@ import SauceLabs from 'saucelabs';
179179
*/
180180
logger: (stdout) => console.log(stdout),
181181
/**
182-
* see all available parameters here: https://docs.saucelabs.com/dev/cli/sauce-connect-proxy/
182+
* see all available parameters here: https://docs.saucelabs.com/dev/cli/sauce-connect-5/run/
183183
* all parameters have to be applied camel cased instead of with hyphens, e.g.
184184
* to apply the `--tunnel-name` parameter, set:
185185
*/
@@ -219,6 +219,7 @@ const myAccount = new SauceLabs({
219219
user: 'YOUR-USER',
220220
key: 'YOUR-ACCESS-KEY',
221221
region: 'eu', // run in EU datacenter
222+
tunnelName: 'my-tunnel',
222223
});
223224
224225
// get full webdriver url from the client depending on `region` option:

apis/sauce.json

+44-85
Original file line numberDiff line numberDiff line change
@@ -458,81 +458,33 @@
458458
},
459459
"type": "object"
460460
},
461-
"SauceConnectDownloadInfo": {
461+
"SauceConnectDownload": {
462462
"type": "object",
463463
"properties": {
464-
"download_url": {
465-
"type": "string"
466-
},
467-
"sha1": {
468-
"type": "string",
469-
"nullable": true
470-
},
471-
"sha256": {
472-
"type": "string",
473-
"nullable": true
474-
},
475-
"version": {
476-
"type": "string",
477-
"nullable": true
478-
}
479-
}
480-
},
481-
"SauceConnectByPlatform": {
482-
"type": "object",
483-
"properties": {
484-
"linux": {
485-
"$ref": "#/definitions/SauceConnectDownloadInfo",
486-
"nullable": true
487-
},
488-
"linux-arm64": {
489-
"$ref": "#/definitions/SauceConnectDownloadInfo",
490-
"nullable": true
491-
},
492-
"win32": {
493-
"$ref": "#/definitions/SauceConnectDownloadInfo",
494-
"nullable": true
495-
},
496-
"osx": {
497-
"$ref": "#/definitions/SauceConnectDownloadInfo"
498-
}
499-
}
500-
},
501-
"SauceConnectVersions": {
502-
"type": "object",
503-
"properties": {
504-
"latest_version": {
505-
"type": "string"
506-
},
507-
"client_version": {
508-
"type": "string"
509-
},
510-
"status": {
511-
"type": "string",
512-
"enum": ["LATEST", "UPGRADE", "PRERELEASE", "UNKNOWN", "EOL"]
513-
},
514-
"info_url": {
515-
"type": "string"
516-
},
517-
"download_url": {
518-
"type": "string"
519-
},
520-
"sha1": {
521-
"type": "string",
522-
"nullable": true
523-
},
524-
"sha256": {
525-
"type": "string",
526-
"nullable": true
527-
}
528-
},
529-
"downloads": {
530-
"$ref": "#/definitions/SauceConnectByPlatform"
531-
},
532-
"all_downloads": {
533-
"type": "array",
534-
"items": {
535-
"$ref": "#/definitions/SauceConnectByPlatform"
464+
"download": {
465+
"type": "object",
466+
"properties": {
467+
"url": {
468+
"type": "string"
469+
},
470+
"version": {
471+
"type": "string"
472+
},
473+
"checksums": {
474+
"type": "array",
475+
"items": {
476+
"type": "object",
477+
"properties": {
478+
"value": {
479+
"type": "string"
480+
},
481+
"algorithm": {
482+
"type": "string"
483+
}
484+
}
485+
}
486+
}
487+
}
536488
}
537489
}
538490
},
@@ -820,17 +772,24 @@
820772
"required": true,
821773
"type": "string"
822774
},
823-
"clientHost": {
824-
"description": "SC client host OS and CPU arch",
775+
"clientArch": {
776+
"description": "SC client host CPU arch",
825777
"in": "query",
826-
"name": "client_host",
778+
"name": "arch",
779+
"required": false,
780+
"type": "string"
781+
},
782+
"clientOS": {
783+
"description": "SC client host OS",
784+
"in": "query",
785+
"name": "os",
827786
"required": false,
828787
"type": "string"
829788
},
830789
"clientVersion": {
831790
"description": "SC client version",
832791
"in": "query",
833-
"name": "client_version",
792+
"name": "version",
834793
"required": false,
835794
"type": "string"
836795
},
@@ -1768,25 +1727,26 @@
17681727
"tags": ["Tunnel"]
17691728
}
17701729
},
1771-
"/v1/public/tunnels/info/versions": {
1730+
"/v1/public/tunnels/sauce-connect/download": {
17721731
"get": {
1773-
"operationId": "sc_versions",
1732+
"description": "Get Sauce Connect download information for the latest version",
1733+
"operationId": "sc_download",
17741734
"parameters": [
17751735
{
1776-
"$ref": "#/parameters/clientVersion"
1736+
"$ref": "#/parameters/clientArch"
17771737
},
17781738
{
1779-
"$ref": "#/parameters/clientHost"
1739+
"$ref": "#/parameters/clientOS"
17801740
},
17811741
{
1782-
"$ref": "#/parameters/all"
1742+
"$ref": "#/parameters/clientVersion"
17831743
}
17841744
],
17851745
"responses": {
17861746
"200": {
1787-
"description": "Tunnels",
1747+
"description": "download",
17881748
"schema": {
1789-
"$ref": "#/definitions/SauceConnectVersions"
1749+
"$ref": "#/definitions/SauceConnectDownload"
17901750
}
17911751
},
17921752
"default": {
@@ -1796,7 +1756,6 @@
17961756
}
17971757
}
17981758
},
1799-
"summary": "Get tunnels for the user or all the users in the team",
18001759
"tags": ["Tunnel"]
18011760
}
18021761
},

docs/interface.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ The following commands are available via package or cli tool:
185185
</tr>
186186
<tr>
187187
<td>
188-
<b>GET</b> <code>/v1/public/tunnels/info/versions</code><br>
189-
Get tunnels for the user or all the users in the team
188+
<b>GET</b> <code>/v1/public/tunnels/sauce-connect/download</code><br>
189+
Get Sauce Connect download information for the latest version
190190
<h3>Example:</h3>
191-
<code>api.scVersions({ ...options })</code>
191+
<code>api.scDownload({ ...options })</code>
192192
<br><h4>Options</h4>
193-
<ul> <li><b>client_version</b>: SC client version</li> <li><b>client_host</b>: SC client host OS and CPU arch</li> <li><b>all</b>: Should the response contain the same team user data</li> </ul> </td>
193+
<ul> <li><b>arch</b>: SC client host CPU architecture</li> <li><b>os</b>: SC client host OS</li> <li><b>version</b>: Optional. Return the newest version matching this minimal version</li> </ul> </td>
194194
</tr>
195195
<tr>
196196
<td>

e2e/sc.test.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,42 @@ test('should be able to get Sauce Connect versions', async () => {
2323
return;
2424
}
2525
const api = new SauceLabs();
26-
const scVersion = await api.scVersions({
27-
clientVersion: '5.1.0',
28-
clientHost: 'darwin-arm64',
26+
const response = await api.scDownload({
27+
version: '5.2.2',
28+
arch: 'arm64',
29+
os: 'macos',
2930
});
30-
expect(scVersion.status).toEqual('UPGRADE');
31-
expect(scVersion.latest_version).toMatch(/5\./);
32-
console.log(scVersion.download_url);
31+
32+
expect(response.download.version).toEqual('5.2.2');
33+
expect(response.download.url).toMatch(/5\.2\.2/);
34+
console.log(response.download.url);
3335
});
3436

3537
test('should not be able to run Sauce Connect due to invalid credentials', async () => {
3638
if (SKIP_TEST) {
3739
return;
3840
}
39-
const api = new SauceLabs({key: 'foobar'});
41+
const api = new SauceLabs({key: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'});
4042
const err = await api
4143
.startSauceConnect({
4244
logger: console.log.bind(console),
4345
tunnelName: `node-saucelabs E2E test - ${ID}`,
4446
})
4547
.catch((err) => err);
46-
expect(err.message).toContain('Unauthorized');
48+
expect(err.message).toContain('Not authorized');
49+
});
50+
51+
test('should not be able to run Sauce Connect due to missing tunnel-name', async () => {
52+
if (SKIP_TEST) {
53+
return;
54+
}
55+
const api = new SauceLabs();
56+
const err = await api
57+
.startSauceConnect({
58+
logger: console.log.bind(console),
59+
})
60+
.catch((err) => err);
61+
expect(err.message).toContain('Missing tunnel-name');
4762
});
4863

4964
test('should be able to run Sauce Connect', async () => {

src/commands/sc.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ import SauceLabs from './..';
22
import {DEFAULT_OPTIONS, SAUCE_CONNECT_CLI_PARAMS} from '../constants';
33

44
export const command = 'sc [flags]';
5-
export const describe = 'Sauce Connect interface';
5+
export const describe = `Sauce Connect Proxy interface.
6+
- Only the 'sc run' command is currently supported
7+
- See https://docs.saucelabs.com/dev/cli/sauce-connect-5/run/ for detailed CLI documentation.
8+
- Sauce Connect Proxy 4.x.x cannot be used with the library version 9.0.0 and newer
9+
- Some Sauce Connect CLI option aliases differ from the 'sc' binary
10+
- Some CLI options differ from the 'sc' binary:
11+
- '--proxy' corresponds to https://docs.saucelabs.com/dev/cli/sauce-connect-5/run/#proxy-sauce
12+
- '--sc-upstream-proxy' corresponds to https://docs.saucelabs.com/dev/cli/sauce-connect-5/run/#proxy
13+
`;
614
export const builder = (yargs) => {
715
for (const option of SAUCE_CONNECT_CLI_PARAMS) {
816
yargs.option(option.name, option);

0 commit comments

Comments
 (0)