diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/NoneAuthTypeRequestTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/NoneAuthTypeRequestTest.java index f11901ef1fa6..aa4b8d3fefd1 100644 --- a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/NoneAuthTypeRequestTest.java +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/NoneAuthTypeRequestTest.java @@ -42,6 +42,8 @@ import software.amazon.awssdk.http.SdkHttpResponse; import software.amazon.awssdk.http.async.AsyncExecuteRequest; import software.amazon.awssdk.http.async.SdkAsyncHttpClient; +import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; +import software.amazon.awssdk.identity.spi.ResolveIdentityRequest; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonAsyncClient; import software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonClient; @@ -65,7 +67,8 @@ public class NoneAuthTypeRequestTest { @Before public void setup() throws IOException { credentialsProvider = mock(AwsCredentialsProvider.class); - when(credentialsProvider.resolveIdentity()).thenAnswer( + when(credentialsProvider.identityType()).thenReturn(AwsCredentialsIdentity.class); + when(credentialsProvider.resolveIdentity(any(ResolveIdentityRequest.class))).thenAnswer( invocationOnMock -> CompletableFuture.completedFuture(AwsBasicCredentials.create("123", "12344"))); httpClient = mock(SdkHttpClient.class); @@ -98,56 +101,56 @@ public void setup() throws IOException { public void sync_json_authorization_is_absent_for_noneAuthType() { jsonClient.operationWithNoneAuthType(o -> o.booleanMember(true)); assertThat(getSyncRequest().firstMatchingHeader("Authorization")).isNotPresent(); - verify(credentialsProvider, times(0)).resolveIdentity(); + verify(credentialsProvider, times(0)).resolveIdentity(any(ResolveIdentityRequest.class)); } @Test public void sync_json_authorization_is_present_for_defaultAuth() { jsonClient.jsonValuesOperation(); assertThat(getSyncRequest().firstMatchingHeader("Authorization")).isPresent(); - verify(credentialsProvider, times(1)).resolveIdentity(); + verify(credentialsProvider, times(1)).resolveIdentity(any(ResolveIdentityRequest.class)); } @Test public void async_json_authorization_is_absent_for_noneAuthType() { jsonAsyncClient.operationWithNoneAuthType(o -> o.booleanMember(true)); assertThat(getAsyncRequest().firstMatchingHeader("Authorization")).isNotPresent(); - verify(credentialsProvider, times(0)).resolveIdentity(); + verify(credentialsProvider, times(0)).resolveIdentity(any(ResolveIdentityRequest.class)); } @Test public void async_json_authorization_is_present_for_defaultAuth() { jsonAsyncClient.jsonValuesOperation(); assertThat(getAsyncRequest().firstMatchingHeader("Authorization")).isPresent(); - verify(credentialsProvider, times(1)).resolveIdentity(); + verify(credentialsProvider, times(1)).resolveIdentity(any(ResolveIdentityRequest.class)); } @Test public void sync_xml_authorization_is_absent_for_noneAuthType() { xmlClient.operationWithNoneAuthType(o -> o.booleanMember(true)); assertThat(getSyncRequest().firstMatchingHeader("Authorization")).isNotPresent(); - verify(credentialsProvider, times(0)).resolveIdentity(); + verify(credentialsProvider, times(0)).resolveIdentity(any(ResolveIdentityRequest.class)); } @Test public void sync_xml_authorization_is_present_for_defaultAuth() { xmlClient.jsonValuesOperation(json -> json.jsonValueMember("one")); assertThat(getSyncRequest().firstMatchingHeader("Authorization")).isPresent(); - verify(credentialsProvider, times(1)).resolveIdentity(); + verify(credentialsProvider, times(1)).resolveIdentity(any(ResolveIdentityRequest.class)); } @Test public void async_xml_authorization_is_absent_for_noneAuthType() { xmlAsyncClient.operationWithNoneAuthType(o -> o.booleanMember(true)); assertThat(getAsyncRequest().firstMatchingHeader("Authorization")).isNotPresent(); - verify(credentialsProvider, times(0)).resolveIdentity(); + verify(credentialsProvider, times(0)).resolveIdentity(any(ResolveIdentityRequest.class)); } @Test public void async_xml_authorization_is_present_for_defaultAuth() { xmlAsyncClient.jsonValuesOperation(json -> json.jsonValueMember("one")); assertThat(getAsyncRequest().firstMatchingHeader("Authorization")).isPresent(); - verify(credentialsProvider, times(1)).resolveIdentity(); + verify(credentialsProvider, times(1)).resolveIdentity(any(ResolveIdentityRequest.class)); } private SdkHttpRequest getSyncRequest() { diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/bearerauth/ClientBuilderTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/bearerauth/ClientBuilderTest.java index f60762bee1a4..746ea32ffce2 100644 --- a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/bearerauth/ClientBuilderTest.java +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/bearerauth/ClientBuilderTest.java @@ -24,7 +24,6 @@ import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; -import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; @@ -34,6 +33,8 @@ import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.regions.Region; +// TODO(sra-identity-auth): assert client is configured with SRA types like AUTH_SCHEMES, AUTH_SCHEME_PROVIDER, +// IDENTITY_PROVIDERS. public class ClientBuilderTest { @Test public void syncClient_includesDefaultProvider_includesDefaultSigner() { @@ -42,8 +43,7 @@ public void syncClient_includesDefaultProvider_includesDefaultSigner() { assertThat(config.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER)) .isInstanceOf(DefaultAwsTokenProvider.class); - assertThat(config.option(SdkAdvancedClientOption.TOKEN_SIGNER)) - .isInstanceOf(BearerTokenSigner.class); + assertThat(config.option(SdkAdvancedClientOption.TOKEN_SIGNER)).isNull();; } @Test @@ -90,8 +90,7 @@ public void asyncClient_includesDefaultProvider_includesDefaultSigner() { assertThat(config.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER)) .isInstanceOf(DefaultAwsTokenProvider.class); - assertThat(config.option(SdkAdvancedClientOption.TOKEN_SIGNER)) - .isInstanceOf(BearerTokenSigner.class); + assertThat(config.option(SdkAdvancedClientOption.TOKEN_SIGNER)).isNull(); } @Test diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/mixedauth/ClientBuilderTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/mixedauth/ClientBuilderTest.java index 86ec7b4b6039..b65e4d8de8a8 100644 --- a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/mixedauth/ClientBuilderTest.java +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/mixedauth/ClientBuilderTest.java @@ -21,7 +21,8 @@ import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; import software.amazon.awssdk.regions.Region; - +// TODO(sra-identity-auth): assert client is configured with SRA types like AUTH_SCHEMES, AUTH_SCHEME_PROVIDER, +// IDENTITY_PROVIDERS. For mixed auth, assert AUTH_SCHEMES has all expected. public class ClientBuilderTest { @Test public void syncClient_buildWithDefaults_validationsSucceed() { diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/protocolrestjson/ClientBuilderTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/protocolrestjson/ClientBuilderTest.java index 01fdb1d0606e..23fd39d1af95 100644 --- a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/protocolrestjson/ClientBuilderTest.java +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/protocolrestjson/ClientBuilderTest.java @@ -21,6 +21,8 @@ import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; import software.amazon.awssdk.regions.Region; +// TODO(sra-identity-auth): assert client is configured with SRA types like AUTH_SCHEMES, AUTH_SCHEME_PROVIDER, +// IDENTITY_PROVIDERS. public class ClientBuilderTest { @Test public void syncClient_buildWithDefaults_validationsSucceed() {