//Hacky assert but we know that this mockServer will create an exception that will be logged, if there's no log entry
//then there's no exception, which means that getCredentials didn't get called on the fetcher
@Test(expected = AmazonClientException.class)
    public void canBeConfiguredToOnlyRefreshCredentialsAfterFirstCallToGetCredentials() throws InterruptedException {
        mockServer.setResponseFileName("sessionResponseExpired");
        mockServer.setAvailableSecurityCredentials("test-credentials");
        InstanceProfileCredentialsProvider credentialsProvider = InstanceProfileCredentialsProvider.createAsyncRefreshingProvider(false);
        Thread.sleep(1000);
        //Hacky assert but we know that this mockServer will create an exception that will be logged, if there's no log entry
        //then there's no exception, which means that getCredentials didn't get called on the fetcher
        assertThat(loggedEvents(), is(empty()));
        credentialsProvider.getCredentials();
    }
InstanceProfileCredentialsProvider credentialsProvider = InstanceProfileCredentialsProvider.createAsyncRefreshingProvider(false);
Thread.sleep(1000);
//Hacky assert but we know that this mockServer will create an exception that will be logged, if there's no log entry
//then there's no exception, which means that getCredentials didn't get called on the fetcher
assertThat(loggedEvents(), is(empty()));
credentialsProvider.getCredentials();
@Test(expected = AmazonClientException.class)
public void canBeConfiguredToOnlyRefreshCredentialsAfterFirstCallToGetCredentials() throws InterruptedException {
mockServer.setResponseFileName("sessionResponseExpired");
mockServer.setAvailableSecurityCredentials("test-credentials");
InstanceProfileCredentialsProvider credentialsProvider = InstanceProfileCredentialsProvider.createAsyncRefreshingProvider(false);
Thread.sleep(1000);
//Hacky assert but we know that this mockServer will create an exception that will be logged, if there's no log entry
//then there's no exception, which means that getCredentials didn't get called on the fetcher
assertThat(loggedEvents(), is(empty()));
credentialsProvider.getCredentials();
}
@Test(expected = AmazonClientException.class)
public void canBeConfiguredToOnlyRefreshCredentialsAfterFirstCallToGetCredentials() throws InterruptedException {
mockServer.setResponseFileName("sessionResponseExpired");
mockServer.setAvailableSecurityCredentials("test-credentials");
InstanceProfileCredentialsProvider credentialsProvider = InstanceProfileCredentialsProvider.createAsyncRefreshingProvider(false);
Thread.sleep(1000);
//Hacky assert but we know that this mockServer will create an exception that will be logged, if there's no log entry
//then there's no exception, which means that getCredentials didn't get called on the fetcher
assertThat(loggedEvents(), is(empty()));
credentialsProvider.getCredentials();
}