Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to SC 5.2.2 #304

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading