Skip to content

Commit 119009d

Browse files
authored
Merge pull request #201 from saucelabs/1.1.0_master
Prepare release
2 parents 1dea747 + a389c77 commit 119009d

File tree

10 files changed

+431
-394
lines changed

10 files changed

+431
-394
lines changed

.github/workflows/java-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v2
11-
- name: Set up JDK 8
11+
- name: Set up JDK 11
1212
uses: actions/setup-java@v2
1313
with:
14-
java-version: '8'
14+
java-version: '11'
1515
distribution: 'zulu'
1616
- name: Build with Maven
1717
run: mvn clean install -Dgpg.skip -B -V

src/main/java/com/saucelabs/saucerest/ErrorExplainers.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@ static String LogNotFound() {
6161
" * A error occurred where the job was created on Sauce Labs but no test were executed."
6262
);
6363
}
64+
65+
static String TunnelNotFound() {
66+
return String.join(System.lineSeparator(),
67+
" * Tunnel id could not be found. Possible reasons:",
68+
" * The tunnel id requested does not exist in this data center. Ensure the data center endpoint is correct.",
69+
" * A tunnel with this id never existed."
70+
);
71+
}
6472
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.saucelabs.saucerest;
2+
3+
public enum HttpMethod {
4+
GET("GET"),
5+
POST("POST"),
6+
PUT("PUT"),
7+
DELETE("DELETE"),
8+
PATCH("PATCH"),
9+
HEAD("HEAD"),
10+
OPTIONS("OPTIONS");
11+
12+
public final String label;
13+
14+
HttpMethod(String label) {
15+
this.label = label;
16+
}
17+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.saucelabs.saucerest;
2+
3+
public enum JobSource {
4+
RDC,
5+
VDC,
6+
}

src/main/java/com/saucelabs/saucerest/SauceException.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ public NotAuthorized() {
3232
}
3333
}
3434

35+
public static class NotFound extends SauceException {
36+
37+
public NotFound(String message) {
38+
super(message);
39+
}
40+
41+
public NotFound() {
42+
}
43+
}
44+
3545
public static class TooManyRequests extends SauceException {
3646
}
3747

src/main/java/com/saucelabs/saucerest/SauceREST.java

Lines changed: 176 additions & 219 deletions
Large diffs are not rendered by default.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.saucelabs.saucerest;
2+
3+
import javax.crypto.Mac;
4+
import javax.crypto.spec.SecretKeySpec;
5+
import java.security.InvalidKeyException;
6+
import java.security.NoSuchAlgorithmException;
7+
8+
import static java.nio.charset.StandardCharsets.US_ASCII;
9+
10+
/**
11+
* Class providing a method to create a shareable test results link of a test executed on Sauce Labs.
12+
*/
13+
public class SauceShareableLink {
14+
/**
15+
* Based on the code from here: https://docs.saucelabs.com/test-results/sharing-test-results/index.html#example---java
16+
* @param username Sauce Labs username
17+
* @param accessKey Sauce Labs access key
18+
* @param sauceJobId Sauce Labs job id
19+
* @param server Sauce Labs data center endpoint
20+
* @return A url of the test result with an authentication token, so it can be accessed without Sauce Labs credentials.
21+
* @throws NoSuchAlgorithmException
22+
* @throws InvalidKeyException
23+
*/
24+
public static String getShareableLink(String username, String accessKey, String sauceJobId, String server) throws NoSuchAlgorithmException, InvalidKeyException {
25+
String key = String.format("%s:%s", username , accessKey);
26+
SecretKeySpec sks = new SecretKeySpec(key.getBytes(US_ASCII), "HmacMD5");
27+
Mac mac = Mac.getInstance("HmacMD5");
28+
mac.init(sks);
29+
byte[] result = mac.doFinal(sauceJobId.getBytes(US_ASCII));
30+
StringBuilder hash = new StringBuilder();
31+
for (byte b : result) {
32+
String hex = Integer.toHexString(0xFF & b);
33+
if (hex.length() == 1) {
34+
hash.append('0');
35+
}
36+
hash.append(hex);
37+
}
38+
String digest = hash.toString();
39+
return String.format("%s%s/%s?auth=%s", server, "tests", sauceJobId, digest);
40+
}
41+
}

src/main/java/com/saucelabs/saucerest/SecurityUtils.java

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.saucelabs.saucerest;
2+
3+
public enum TestAsset {
4+
SAUCE_LOG("log.json"),
5+
VIDEO("video.mp4"),
6+
SELENIUM_LOG("selenium-server.log"),
7+
AUTOMATOR_LOG("automator.log"),
8+
LOGCAT_LOG("logcat.log"),
9+
SYSLOG_LOG("ios-syslog.log"),
10+
HAR("network.har"),
11+
PERFORMANCE("performance.json"),
12+
CONSOLE_LOG("console.json"),
13+
SCREENSHOTS("screenshots.zip"),
14+
APPIUM_LOG("appium-server.log");
15+
16+
public final String label;
17+
18+
TestAsset(String label) {
19+
this.label = label;
20+
}
21+
}

0 commit comments

Comments
 (0)