From c523b35deb6c32d09b1bc0450a61812d63c82e83 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 27 May 2024 16:23:11 +0200 Subject: [PATCH] Add ability to retrieve all the tunnels info at once (#520) (#523) * Add ability to retrieve all the tunnels info at once * Update SauceConnectEndpointTest.java --------- Co-authored-by: Valery Yatsynovich --- .../saucerest/api/SauceConnectEndpoint.java | 30 +++++++++++++++---- .../integration/SauceConnectEndpointTest.java | 14 +++++++-- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/saucelabs/saucerest/api/SauceConnectEndpoint.java b/src/main/java/com/saucelabs/saucerest/api/SauceConnectEndpoint.java index 838a3ab9..1ff7fa11 100644 --- a/src/main/java/com/saucelabs/saucerest/api/SauceConnectEndpoint.java +++ b/src/main/java/com/saucelabs/saucerest/api/SauceConnectEndpoint.java @@ -27,18 +27,24 @@ public SauceConnectEndpoint(String username, String accessKey, DataCenter dataCe } /** - * Returns Tunnel IDs or Tunnels Info for any currently running tunnels launched by or shared with the specified user. - * Documentation is - * here + * Returns Tunnel IDs for any currently running tunnels launched by the specified user. + * Documentation is here. */ public List getTunnelsForAUser() throws IOException { return getTunnelsForAUser(this.username); } /** - * Returns Tunnel IDs or Tunnels Info for any currently running tunnels launched by or shared with the specified user. - * Documentation is - * here + * Returns Tunnels Info for any currently running tunnels launched by the specified user. + * Documentation is here. + */ + public List getTunnelsInformationForAUser() throws IOException { + return getTunnelsInformationForAUser(this.username); + } + + /** + * Returns Tunnel IDs for any currently running tunnels launched by the specified user. + * Documentation is here. * * @param username Sauce Labs username */ @@ -48,6 +54,18 @@ public List getTunnelsForAUser(String username) throws IOException { return deserializeJSONArray(request(url, HttpMethod.GET), String.class); } + /** + * Returns Tunnels Info for any currently running tunnels launched by the specified user. + * Documentation is here. + * + * @param username Sauce Labs username + */ + public List getTunnelsInformationForAUser(String username) throws IOException { + String url = getBaseEndpoint() + username + "/tunnels?full=true"; + + return deserializeJSONArray(request(url, HttpMethod.GET), TunnelInformation.class); + } + /** * Returns information about the specified tunnel. * diff --git a/src/test/java/com/saucelabs/saucerest/integration/SauceConnectEndpointTest.java b/src/test/java/com/saucelabs/saucerest/integration/SauceConnectEndpointTest.java index 51807e2f..1a10869d 100644 --- a/src/test/java/com/saucelabs/saucerest/integration/SauceConnectEndpointTest.java +++ b/src/test/java/com/saucelabs/saucerest/integration/SauceConnectEndpointTest.java @@ -91,6 +91,17 @@ public void getTunnelsForAUserTest(DataCenter dataCenter) throws IOException { Assertions.assertFalse(tunnelIDs.isEmpty()); } + @ParameterizedTest + @EnumSource(DataCenter.class) + public void getTunnelsInformationForAUserTest(DataCenter dataCenter) throws IOException { + SauceREST sauceREST = new SauceREST(dataCenter); + SauceConnectEndpoint sauceConnectEndpoint = sauceREST.getSauceConnectEndpoint(); + + List tunnelsInfo = sauceConnectEndpoint.getTunnelsInformationForAUser(); + + Assertions.assertFalse(tunnelsInfo.isEmpty()); + } + @ParameterizedTest @EnumSource(DataCenter.class) public void getTunnelInformationTest(DataCenter dataCenter) throws IOException { @@ -99,10 +110,9 @@ public void getTunnelInformationTest(DataCenter dataCenter) throws IOException { List tunnelIDs = sauceConnectEndpoint.getTunnelsForAUser(); + Assertions.assertFalse(tunnelIDs.isEmpty()); for (String tunnelID : tunnelIDs) { TunnelInformation tunnelInformation = sauceConnectEndpoint.getTunnelInformation(tunnelID); - - Assertions.assertFalse(tunnelIDs.isEmpty()); Assertions.assertNotNull(tunnelInformation); } }