@Test public void token404_shouldFallbackInsecureWorkflow() { generateErrorTokenStub(404); generateStub(200, SUCCESS_BODY); assertEquals(SUCCESS_BODY, resourceFetcher.readResource(endpoint)); verifyInsecureWorkflowHeaders(); }
@Override public String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers) { if (SDKGlobalConfiguration.isEc2MetadataDisabled()) { throw new AmazonClientException("EC2 Instance Metadata Service is disabled"); } Map<String, String> newHeaders = addDefaultHeaders(headers); String token = getToken(); if (token != null) { newHeaders.put(TOKEN_HEADER, token); } return doReadResource(endpoint, retryPolicy, newHeaders); }
InstanceMetadataServiceResourceFetcher extends EC2ResourceFetcher { @Override public String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers) { if (SDKGlobalConfiguration.isEc2MetadataDisabled()) { throw new AmazonClientException("EC2 Instance Metadata Service is disabled"); } Map<String, String> newHeaders = addDefaultHeaders(headers); String token = getToken(); if (token != null) { newHeaders.put(TOKEN_HEADER, token); } return doReadResource(endpoint, retryPolicy, newHeaders); } }
InstanceMetadataServiceResourceFetcher extends EC2ResourceFetcher { @Override public String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers) { if (SDKGlobalConfiguration.isEc2MetadataDisabled()) { throw new AmazonClientException("EC2 Instance Metadata Service is disabled"); } Map<String, String> newHeaders = addDefaultHeaders(headers); String token = getToken(); if (token != null) { newHeaders.put(TOKEN_HEADER, token); } return doReadResource(endpoint, retryPolicy, newHeaders); } private  InstanceMetadataServiceResourceFetcher(); @SdkTestInternalApi  InstanceMetadataServiceResourceFetcher(ConnectionUtils connectionUtils); }
InstanceMetadataServiceResourceFetcher extends EC2ResourceFetcher { @Override public String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers) { if (SDKGlobalConfiguration.isEc2MetadataDisabled()) { throw new AmazonClientException("EC2 Instance Metadata Service is disabled"); } Map<String, String> newHeaders = addDefaultHeaders(headers); String token = getToken(); if (token != null) { newHeaders.put(TOKEN_HEADER, token); } return doReadResource(endpoint, retryPolicy, newHeaders); } private  InstanceMetadataServiceResourceFetcher(); @SdkTestInternalApi  InstanceMetadataServiceResourceFetcher(ConnectionUtils connectionUtils); static InstanceMetadataServiceResourceFetcher getInstance(); @Override String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers); }
InstanceMetadataServiceResourceFetcher extends EC2ResourceFetcher { @Override public String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers) { if (SDKGlobalConfiguration.isEc2MetadataDisabled()) { throw new AmazonClientException("EC2 Instance Metadata Service is disabled"); } Map<String, String> newHeaders = addDefaultHeaders(headers); String token = getToken(); if (token != null) { newHeaders.put(TOKEN_HEADER, token); } return doReadResource(endpoint, retryPolicy, newHeaders); } private  InstanceMetadataServiceResourceFetcher(); @SdkTestInternalApi  InstanceMetadataServiceResourceFetcher(ConnectionUtils connectionUtils); static InstanceMetadataServiceResourceFetcher getInstance(); @Override String readResource(URI endpoint, CredentialsEndpointRetryPolicy retryPolicy, Map<String, String> headers);  }