Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ignore] Testing branch with useSraAuth=true #4478

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
10d4407
Set TIME_OFFSET attribtue in SRA signin methods (#4483)
zoewangg Sep 26, 2023
f76a4cd
Add missing dependency for transcribestreaming (#4486)
zoewangg Sep 26, 2023
9f6282b
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
zoewangg Sep 27, 2023
01fc8c8
Set useSraAuth to true
zoewangg Sep 27, 2023
1ae9ac9
Verify that execution attributes set by old interceptors can be read …
millems Sep 28, 2023
fa59e55
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
zoewangg Sep 28, 2023
ad0c81a
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
zoewangg Sep 28, 2023
b55a20f
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
zoewangg Sep 28, 2023
ec19254
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
zoewangg Sep 29, 2023
ba2eab9
Merge branch 'feature/master/sra-identity-auth' into feature/master/s…
zoewangg Oct 2, 2023
0adf153
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
zoewangg Oct 2, 2023
7c50e83
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
zoewangg Oct 3, 2023
c70ee2b
Commenting out codegen tests
zoewangg Oct 3, 2023
0293109
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
gosar Oct 4, 2023
50fa109
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
gosar Oct 4, 2023
d269d6b
Uncomment codegen tests and use useSraAuth=false/true
gosar Oct 4, 2023
9ecc9c7
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
gosar Oct 4, 2023
360ce83
Merge remote-tracking branch 'origin/feature/master/sra-identity-auth…
gosar Oct 4, 2023
e0ebe0e
Update codegen-generated-classes-test for SRA (#4548)
gosar Oct 4, 2023
8e1a09e
Temporarily comment failing BlockingAsyncRequestResponseBodyTest test…
gosar Oct 4, 2023
bcd9dba
Merge branch 'feature/master/sra-identity-auth' into feature/master/s…
gosar Oct 5, 2023
0e3d265
Removed @Disabled from test that was missed earlier
gosar Oct 5, 2023
41a1e64
Merge branch 'feature/master/sra-identity-auth' into feature/master/s…
gosar Oct 6, 2023
730de26
Merge branch 'feature/master/sra-identity-auth' into feature/master/s…
gosar Oct 6, 2023
5c24787
Merge branch 'feature/master/sra-identity-auth' into feature/master/s…
gosar Oct 12, 2023
9a690e1
Merge remote-tracking branch 'origin/master' into sra-identity-auth-t…
gosar Oct 13, 2023
977ff49
Merge branch 'master' into feature/master/sra-identity-auth-testing
gosar Oct 13, 2023
1b0216b
Ignore auth maven-dependency-plugin failure
gosar Oct 13, 2023
30db162
Revert "Temporarily comment failing BlockingAsyncRequestResponseBodyT…
gosar Oct 13, 2023
f1d348a
Specify protocol-tests->http-auth dependency (#4594)
gosar Oct 13, 2023
7d22755
Move S3Presigner fully to SRA with HttpSigner (#4569)
gosar Oct 14, 2023
7a49a84
Merge branch 'master' into feature/master/sra-identity-auth-testing
gosar Oct 16, 2023
5f0f441
Remove derived attribute logic for PRESIGNER_EXPIRATION (#4602)
gosar Oct 17, 2023
01127a7
Merge remote-tracking branch 'upstream/master' into sugmanue/sra-iden…
sugmanue Oct 18, 2023
da25b08
Merge remote-tracking branch 'origin/master' into gosar/sra-ia-merge-…
gosar Oct 18, 2023
c88c5fb
Merge remote-tracking branch 'upstream/master' into sugmanue/sra-iden…
sugmanue Oct 25, 2023
824b498
Merge remote-tracking branch 'upstream/master' into sugmanue/sra-iden…
sugmanue Oct 26, 2023
f4356ee
Merge remote-tracking branch 'upstream/master' into sugmanue/sra-iden…
sugmanue Oct 31, 2023
af30cba
(1 of ?) Improve plugin's ability to affect configuration.
millems Oct 4, 2023
ff6b074
Merge remote-tracking branch 'upstream/master' into sugmanue/sra-iden…
sugmanue Nov 1, 2023
8bd22d4
Remove TODO's for useSraAuth true
sugmanue Nov 7, 2023
5c536b7
(2 of 3) Allow plugins to modify configuration specified on the client
millems Nov 2, 2023
c501472
Addressed PR comments from https://github.com/aws/aws-sdk-java-v2/pul…
millems Nov 10, 2023
a12a862
Fixed weird NPE in test that happens on newer JDKs.
millems Nov 10, 2023
85ad37c
Merge branch 'millem/better-config-mirroring' into test-better-config…
sugmanue Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-6fbd668.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "SdkPlugins can now see and modify all configuration set on the client, including default values"
}
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-f70427b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "The `serviceClientConfiguration` from SDK clients now includes the defaults set by the SDK."
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@

<!-- Allow non-java.base usage in tests -->
<suppress checks="software.amazon.awssdk.buildtools.checkstyle.NonJavaBaseModuleCheck" files=".*testutils.*"/>

<!-- Allow private field declaration before public, to have correct initialization order -->
<suppress checks="DeclarationOrder"
files=".*SdkAdvancedClientOption\.java$"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
package software.amazon.awssdk.codegen.emitters.tasks;

import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
import software.amazon.awssdk.codegen.poet.model.SdkClientConfigurationUtilGeneratorTask;

/**
* Common generator tasks.
*/
class CommonGeneratorTasks extends CompositeGeneratorTask {
CommonGeneratorTasks(GeneratorTaskParams params) {
super(new CommonClientGeneratorTasks(params),
new SdkClientConfigurationUtilGeneratorTask(params),
new SyncClientGeneratorTasks(params),
new MarshallerGeneratorTasks(params),
new ModelClassGeneratorTasks(params),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public class CustomizationConfig {
/**
* Whether SRA based auth logic should be used.
*/
private boolean useSraAuth = false;
private boolean useSraAuth = true;

/**
* Whether to generate auth scheme params based on endpoint params.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import software.amazon.awssdk.codegen.model.config.customization.MultipartCustomization;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.PoetExtension;
import software.amazon.awssdk.codegen.poet.PoetUtils;
import software.amazon.awssdk.codegen.poet.rules.EndpointRulesSpecUtils;
import software.amazon.awssdk.codegen.utils.AuthUtils;
Expand All @@ -43,7 +42,6 @@ public class AsyncClientBuilderClass implements ClassSpec {
private final ClassName builderInterfaceName;
private final ClassName builderClassName;
private final ClassName builderBaseClassName;
private final ClassName serviceConfigClassName;
private final EndpointRulesSpecUtils endpointRulesSpecUtils;

public AsyncClientBuilderClass(IntermediateModel model) {
Expand All @@ -55,7 +53,6 @@ public AsyncClientBuilderClass(IntermediateModel model) {
this.builderClassName = ClassName.get(basePackage, model.getMetadata().getAsyncBuilder());
this.builderBaseClassName = ClassName.get(basePackage, model.getMetadata().getBaseBuilder());
this.endpointRulesSpecUtils = new EndpointRulesSpecUtils(model);
this.serviceConfigClassName = new PoetExtension(model).getServiceConfigClass();
}

@Override
Expand Down Expand Up @@ -89,7 +86,6 @@ public TypeSpec poetSpec() {
}

builder.addMethod(buildClientMethod());
builder.addMethod(SyncClientBuilderClass.initializeServiceClientConfigMethod(serviceConfigClassName));

return builder.build();
}
Expand Down Expand Up @@ -137,12 +133,9 @@ private MethodSpec buildClientMethod() {
.returns(clientInterfaceName)
.addStatement("$T clientConfiguration = super.asyncClientConfiguration()",
SdkClientConfiguration.class)
.addStatement("this.validateClientOptions(clientConfiguration)")
.addStatement("$T serviceClientConfiguration = initializeServiceClientConfig"
+ "(clientConfiguration)",
serviceConfigClassName);
.addStatement("this.validateClientOptions(clientConfiguration)");

builder.addStatement("$1T client = new $2T(serviceClientConfiguration, clientConfiguration)",
builder.addStatement("$1T client = new $2T(clientConfiguration)",
clientInterfaceName, clientClassName);
if (model.asyncClientDecoratorClassName().isPresent()) {
builder.addStatement("return new $T().decorate(client, clientConfiguration, clientContextParams.copy().build())",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.Set;
import javax.lang.model.element.Modifier;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.auth.credentials.TokenUtils;
import software.amazon.awssdk.auth.signer.Aws4Signer;
import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider;
import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner;
Expand All @@ -54,7 +55,6 @@
import software.amazon.awssdk.codegen.poet.rules.EndpointRulesSpecUtils;
import software.amazon.awssdk.codegen.utils.AuthUtils;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
Expand Down Expand Up @@ -82,7 +82,6 @@ public class BaseClientBuilderClass implements ClassSpec {
private final IntermediateModel model;
private final ClassName builderInterfaceName;
private final ClassName builderClassName;
private final ClassName sdkClientConfigurationUtilClassName;
private final String basePackage;
private final EndpointRulesSpecUtils endpointRulesSpecUtils;
private final AuthSchemeSpecUtils authSchemeSpecUtils;
Expand All @@ -93,8 +92,6 @@ public BaseClientBuilderClass(IntermediateModel model) {
this.basePackage = model.getMetadata().getFullClientPackageName();
this.builderInterfaceName = ClassName.get(basePackage, model.getMetadata().getBaseBuilderInterface());
this.builderClassName = ClassName.get(basePackage, model.getMetadata().getBaseBuilder());
this.sdkClientConfigurationUtilClassName = ClassName.get(model.getMetadata().getFullClientInternalPackageName(),
"SdkClientConfigurationUtil");
this.endpointRulesSpecUtils = new EndpointRulesSpecUtils(model);
this.authSchemeSpecUtils = new AuthSchemeSpecUtils(model);
this.configurationUtils = new ServiceClientConfigurationUtils(model);
Expand Down Expand Up @@ -175,7 +172,6 @@ public TypeSpec poetSpec() {
builder.addMethod(defaultTokenAuthSignerMethod());
}
}
builder.addMethod(setOverridesMethod());
addServiceHttpConfigIfNeeded(builder, model);
builder.addMethod(invokePluginsMethod());
builder.addMethod(validateClientOptionsMethod());
Expand Down Expand Up @@ -256,6 +252,8 @@ private MethodSpec mergeServiceDefaultsMethod() {
}

if (AuthUtils.usesBearerAuth(model)) {
builder.addCode(".lazyOption($1T.TOKEN_PROVIDER, p -> $2T.toSdkTokenProvider(p.get($1T.TOKEN_IDENTITY_PROVIDER)))",
AwsClientOption.class, TokenUtils.class);
builder.addCode(".option($T.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())\n", AwsClientOption.class);
if (!authSchemeSpecUtils.useSraAuth()) {
builder.addCode(".option($T.TOKEN_SIGNER, defaultTokenSigner())", SdkAdvancedClientOption.class);
Expand Down Expand Up @@ -362,18 +360,24 @@ private MethodSpec finalizeServiceConfigurationMethod() {

// Update configuration
builder.addStatement("$T builder = config.toBuilder()", SdkClientConfiguration.Builder.class);
builder.addCode("builder.lazyOption($T.IDENTITY_PROVIDERS, c -> {", SdkClientOption.class)
.addStatement("$1T.Builder result = $1T.builder()", IdentityProviders.class);
if (AuthUtils.usesBearerAuth(model)) {
builder.addStatement("$T<? extends $T> identityProvider = config.option($T.TOKEN_IDENTITY_PROVIDER)",
IdentityProvider.class, TokenIdentity.class, AwsClientOption.class);
builder.beginControlFlow("if (identityProvider != null)");
builder.addStatement("$T identityProviders = config.option($T.IDENTITY_PROVIDERS)",
IdentityProviders.class, SdkClientOption.class);

builder.addStatement("builder.option($T.IDENTITY_PROVIDERS, identityProviders.toBuilder()"
+ ".putIdentityProvider(identityProvider).build())", SdkClientOption.class);

builder.addStatement("$T<?> tokenIdentityProvider = c.get($T.TOKEN_IDENTITY_PROVIDER)",
IdentityProvider.class, AwsClientOption.class);
builder.beginControlFlow("if (tokenIdentityProvider != null)");
builder.addStatement("result.putIdentityProvider(tokenIdentityProvider)");
builder.endControlFlow();
}
if (AuthUtils.usesAwsAuth(model)) {
builder.addStatement("$T<?> credentialsIdentityProvider = c.get($T.CREDENTIALS_IDENTITY_PROVIDER)",
IdentityProvider.class, AwsClientOption.class);
builder.beginControlFlow("if (credentialsIdentityProvider != null)", AwsClientOption.class);
builder.addStatement("result.putIdentityProvider(credentialsIdentityProvider)");
builder.endControlFlow();
}
builder.addStatement("return result.build()")
.addCode("});");

builder.addCode("builder.option($1T.EXECUTION_INTERCEPTORS, interceptors)", SdkClientOption.class);

Expand Down Expand Up @@ -715,7 +719,7 @@ private MethodSpec authSchemesMethod() {
builder.addStatement("schemes.put($1N.schemeId(), $1N)", instanceVariable);
}
builder.addStatement("schemes.putAll(this.additionalAuthSchemes)");
builder.addStatement("return $T.unmodifiableMap(schemes)", Collections.class);
builder.addStatement("return schemes", Collections.class);
return builder.build();
}

Expand All @@ -730,34 +734,18 @@ private MethodSpec invokePluginsMethod() {
.beginControlFlow("if (plugins.isEmpty())")
.addStatement("return config")
.endControlFlow();
builder.addStatement("$1T.BuilderInternal serviceConfigBuilder = $1T.builder(config.toBuilder())",
configurationUtils.serviceClientConfigurationBuilderClassName());
builder.addStatement("serviceConfigBuilder.overrideConfiguration(overrideConfiguration())");
builder.beginControlFlow("for ($T plugin : plugins)", SdkPlugin.class)


builder.addStatement("$T configuration = config.toBuilder()", SdkClientConfiguration.Builder.class)
.addStatement("$1T serviceConfigBuilder = new $1T(configuration)",
configurationUtils.serviceClientConfigurationBuilderClassName())
.beginControlFlow("for ($T plugin : plugins)", SdkPlugin.class)
.addStatement("plugin.configureClient(serviceConfigBuilder)")
.endControlFlow();
builder.addStatement("overrideConfiguration(serviceConfigBuilder.overrideConfiguration())");
builder.addStatement("return serviceConfigBuilder.buildSdkClientConfiguration()");
.endControlFlow()
.addStatement("return configuration.build()");
return builder.build();
}

private MethodSpec setOverridesMethod() {
return MethodSpec.methodBuilder("setOverrides")
.addModifiers(PROTECTED)
.addAnnotation(Override.class)
.addParameter(SdkClientConfiguration.class, "configuration")
.returns(SdkClientConfiguration.class)
.addStatement("$T overrideConfiguration = overrideConfiguration()",
ClientOverrideConfiguration.class)
.beginControlFlow("if (overrideConfiguration == null)")
.addStatement("return configuration")
.endControlFlow()
.addStatement("return $T.copyOverridesToConfiguration(overrideConfiguration, configuration.toBuilder())"
+ ".build()",
sdkClientConfigurationUtilClassName)
.build();
}

@Override
public ClassName className() {
return builderClassName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeSpec;
import com.squareup.javapoet.WildcardTypeName;
import java.net.URI;
import javax.lang.model.element.Modifier;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.config.AwsClientOption;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.poet.ClassSpec;
import software.amazon.awssdk.codegen.poet.PoetExtension;
import software.amazon.awssdk.codegen.poet.PoetUtils;
import software.amazon.awssdk.codegen.poet.rules.EndpointRulesSpecUtils;
import software.amazon.awssdk.codegen.utils.AuthUtils;
Expand All @@ -42,7 +40,6 @@ public class SyncClientBuilderClass implements ClassSpec {
private final ClassName builderInterfaceName;
private final ClassName builderClassName;
private final ClassName builderBaseClassName;
private final ClassName serviceConfigClassName;
private final EndpointRulesSpecUtils endpointRulesSpecUtils;

public SyncClientBuilderClass(IntermediateModel model) {
Expand All @@ -54,7 +51,6 @@ public SyncClientBuilderClass(IntermediateModel model) {
this.builderClassName = ClassName.get(basePackage, model.getMetadata().getSyncBuilder());
this.builderBaseClassName = ClassName.get(basePackage, model.getMetadata().getBaseBuilder());
this.endpointRulesSpecUtils = new EndpointRulesSpecUtils(model);
this.serviceConfigClassName = new PoetExtension(model).getServiceConfigClass();
}

@Override
Expand Down Expand Up @@ -82,7 +78,6 @@ public TypeSpec poetSpec() {
}

builder.addMethod(buildClientMethod());
builder.addMethod(initializeServiceClientConfigMethod(serviceConfigClassName));

return builder.build();
}
Expand Down Expand Up @@ -130,12 +125,9 @@ private MethodSpec buildClientMethod() {
.returns(clientInterfaceName)
.addStatement("$T clientConfiguration = super.syncClientConfiguration()",
SdkClientConfiguration.class)
.addStatement("this.validateClientOptions(clientConfiguration)")
.addStatement("$T serviceClientConfiguration = initializeServiceClientConfig"
+ "(clientConfiguration)",
serviceConfigClassName);
.addStatement("this.validateClientOptions(clientConfiguration)");

builder.addStatement("$1T client = new $2T(serviceClientConfiguration, clientConfiguration)",
builder.addStatement("$1T client = new $2T(clientConfiguration)",
clientInterfaceName, clientClassName);
if (model.syncClientDecoratorClassName().isPresent()) {
builder.addStatement("return new $T().decorate(client, clientConfiguration, clientContextParams.copy().build())",
Expand All @@ -159,26 +151,6 @@ private MethodSpec tokenProviderMethodImpl() {
.build();
}

// TODO(sra-plugins) Move this method to a commons class or move it to the base class
public static MethodSpec initializeServiceClientConfigMethod(ClassName serviceConfigClassName) {
return MethodSpec.methodBuilder("initializeServiceClientConfig").addModifiers(Modifier.PRIVATE)
.addParameter(SdkClientConfiguration.class, "clientConfig")
.returns(serviceConfigClassName)
.addStatement("$T endpointOverride = null", URI.class)
.beginControlFlow("if ($T.TRUE.equals(clientConfig.option($T.ENDPOINT_OVERRIDDEN)))", Boolean.class,
SdkClientOption.class)
.addStatement("endpointOverride = clientConfig.option($T.ENDPOINT)", SdkClientOption.class)
.endControlFlow()
.addStatement("return $T.builder()"
+ ".overrideConfiguration(overrideConfiguration())"
+ ".region(clientConfig.option($T.AWS_REGION))"
+ ".endpointOverride(endpointOverride)"
+ ".endpointProvider(clientConfig.option($T.ENDPOINT_PROVIDER))"
+ ".build()",
serviceConfigClassName, AwsClientOption.class, SdkClientOption.class)
.build();
}

@Override
public ClassName className() {
return builderClassName;
Expand Down
Loading
Loading