Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/maven/org.apache.maven.plugins-ma…
Browse files Browse the repository at this point in the history
…ven-javadoc-plugin-3.11.2
  • Loading branch information
alexh-sauce authored Dec 12, 2024
2 parents da6e4c0 + 9094d0c commit ef72aff
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.saucelabs</groupId>
<artifactId>ci-sauce</artifactId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
<packaging>jar</packaging>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public String getDefaultSauceConnectLogDirectory() {

private static final String WINDOWS_TEMP_DIR = System.getProperty("java.io.tmpdir");

public static final String CURRENT_SC_VERSION = "5.2.1";
public static final String CURRENT_SC_VERSION = "5.2.2";
public static final LazyInitializer<String> LATEST_SC_VERSION = new Builder<LazyInitializer<String>, String>()
.setInitializer(SauceConnectManager::getLatestSauceConnectVersion)
.get();
Expand Down Expand Up @@ -308,10 +308,30 @@ public void setCleanUpOnExit(boolean cleanUpOnExit) {

public static String getLatestSauceConnectVersion() {
try {
URI url = URI.create("https://saucelabs.com/versions.json");
OperatingSystem operatingSystem = OperatingSystem.getOperatingSystem();
String os = System.getProperty("os.name").toLowerCase();
String arch = System.getProperty("os.arch").toLowerCase();

String query;

if (operatingSystem.isArm(arch)) {
query = "arch=arm64&";
} else {
query = "arch=x86_64&";
}

if (operatingSystem.isWindows(os)) {
query += "os=windows";
} else if (operatingSystem.isMac(os)) {
query += "os=macos";
} else {
query += "os=linux";
}

URI url = URI.create("https://api.us-west-1.saucelabs.com/rest/v1/public/tunnels/sauce-connect/download?" + query);
HttpRequest request = HttpRequest.newBuilder(url).build();
String versionsJson = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()).body();
return new JSONObject(versionsJson).getJSONObject("Sauce Connect").getString("version");
return new JSONObject(versionsJson).getJSONObject("download").getString("version");
} catch (IOException | InterruptedException e) {
return null;
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void shouldInitLatestVersionLazilyAndOnce() throws IOException, InterruptedExcep
HttpClient httpClient = mock();
HttpResponse<String> httpResponse = mock();
String version = "5.99.99";
when(httpResponse.body()).thenReturn("{\"Sauce Connect\": {\"version\": \"" + version + "\"}}");
when(httpResponse.body()).thenReturn("{\"download\": {\"version\": \"" + version + "\"}}");
when(httpClient.send(any(), argThat((ArgumentMatcher<BodyHandler<String>>) argument -> true))).thenReturn(
httpResponse);
httpClientStaticMock.when(HttpClient::newHttpClient).thenReturn(httpClient);
Expand Down

0 comments on commit ef72aff

Please sign in to comment.