@Test public void testClientClosedAndCredentialsDecoded(@Mocked final CloseableHttpClient closeableHttpClient, @Mocked final CloseableHttpResponse closeableHttpResponse, @Mocked final StatusLine statusLine) throws IOException, MojoExecutionException { final HttpEntity entity = new StringEntity("{\"authorizationData\": [{" + "\"authorizationToken\": \"QVdTOnBhc3N3b3Jk\"," + "\"expiresAt\": 1448878779.809," + "\"proxyEndpoint\": \"https: new Expectations() {{ statusLine.getStatusCode(); result = 200; closeableHttpResponse.getEntity(); result = entity; }}; EcrExtendedAuth eea = new EcrExtendedAuth(logger, "123456789012.dkr.ecr.eu-west-1.amazonaws.com") { CloseableHttpClient createClient() { return closeableHttpClient; } }; AuthConfig localCredentials = new AuthConfig.Builder() .username("username") .password("password") .build(); AuthConfig awsCredentials = eea.extendedAuth(localCredentials); assertEquals("AWS", awsCredentials.getUsername()); assertEquals("password", awsCredentials.getPassword()); new Verifications() {{ closeableHttpClient.close(); }}; }
public AuthConfig extendedAuth(AuthConfig localCredentials) throws IOException { JsonObject jo = getAuthorizationToken(localCredentials); JsonArray authorizationDatas = jo.getAsJsonArray("authorizationData"); JsonObject authorizationData = authorizationDatas.get(0).getAsJsonObject(); String authorizationToken = authorizationData.get("authorizationToken").getAsString(); return new AuthConfig(authorizationToken, "none"); }
EcrExtendedAuth { public AuthConfig extendedAuth(AuthConfig localCredentials) throws IOException { JsonObject jo = getAuthorizationToken(localCredentials); JsonArray authorizationDatas = jo.getAsJsonArray("authorizationData"); JsonObject authorizationData = authorizationDatas.get(0).getAsJsonObject(); String authorizationToken = authorizationData.get("authorizationToken").getAsString(); return new AuthConfig(authorizationToken, "none"); } }
EcrExtendedAuth { public AuthConfig extendedAuth(AuthConfig localCredentials) throws IOException { JsonObject jo = getAuthorizationToken(localCredentials); JsonArray authorizationDatas = jo.getAsJsonArray("authorizationData"); JsonObject authorizationData = authorizationDatas.get(0).getAsJsonObject(); String authorizationToken = authorizationData.get("authorizationToken").getAsString(); return new AuthConfig(authorizationToken, "none"); } EcrExtendedAuth(KitLogger logger, String registry); }
EcrExtendedAuth { public AuthConfig extendedAuth(AuthConfig localCredentials) throws IOException { JsonObject jo = getAuthorizationToken(localCredentials); JsonArray authorizationDatas = jo.getAsJsonArray("authorizationData"); JsonObject authorizationData = authorizationDatas.get(0).getAsJsonObject(); String authorizationToken = authorizationData.get("authorizationToken").getAsString(); return new AuthConfig(authorizationToken, "none"); } EcrExtendedAuth(KitLogger logger, String registry); static boolean isAwsRegistry(String registry); boolean isAwsRegistry(); AuthConfig extendedAuth(AuthConfig localCredentials); }
EcrExtendedAuth { public AuthConfig extendedAuth(AuthConfig localCredentials) throws IOException { JsonObject jo = getAuthorizationToken(localCredentials); JsonArray authorizationDatas = jo.getAsJsonArray("authorizationData"); JsonObject authorizationData = authorizationDatas.get(0).getAsJsonObject(); String authorizationToken = authorizationData.get("authorizationToken").getAsString(); return new AuthConfig(authorizationToken, "none"); } EcrExtendedAuth(KitLogger logger, String registry); static boolean isAwsRegistry(String registry); boolean isAwsRegistry(); AuthConfig extendedAuth(AuthConfig localCredentials);  }