ContainerCredentialsProvider implements AWSCredentialsProvider { @Override public AWSCredentials getCredentials() { return credentialsFetcher.getCredentials(); } @Deprecated  ContainerCredentialsProvider();  ContainerCredentialsProvider(CredentialsEndpointProvider credentialsEndpointProvider); @Override AWSCredentials getCredentials(); @Override void refresh(); Date getCredentialsExpiration();  }
@Test (expected = AmazonClientException.class) public void testEnvVariableNotSet() { ContainerCredentialsProvider credentialsProvider = new ContainerCredentialsProvider(); credentialsProvider.getCredentials(); }
@Test public void getCredentialsWithCorruptResponseDoesNotIncludeCredentialsInExceptionMessage() { stubForCorruptedSuccessResponse(); try { containerCredentialsProvider.getCredentials(); Assert.fail(); } catch (Exception e) { String stackTrace = ExceptionUtils.getStackTrace(e); Assert.assertFalse(stackTrace.contains("ACCESS_KEY_ID")); Assert.assertFalse(stackTrace.contains("SECRET_ACCESS_KEY")); Assert.assertFalse(stackTrace.contains("TOKEN_TOKEN_TOKEN")); } }
@Test public void testGetCredentialsThrowsAceFor404ErrorResponse() { stubForErrorResponse(404); try { containerCredentialsProvider.getCredentials(); fail("The test should throw an exception"); } catch (AmazonClientException exception) { assertNotNull(exception.getMessage()); } }
@Test public void testGetCredentialsThrowsAseForNon200AndNon404ErrorResponse() { stubForErrorResponse(401); try { containerCredentialsProvider.getCredentials(); fail("The test should have thrown an exception"); } catch (AmazonServiceException exception) { assertEquals(401, exception.getStatusCode()); assertNotNull(exception.getMessage()); } }