-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove emptyMap case that would miss additionalAuthSchemes (#4364)
* Remove emptyMap case that would miss additionalAuthSchemes * Add test case with service level authType=none
- Loading branch information
Showing
9 changed files
with
195 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
103 changes: 103 additions & 0 deletions
103
...oftware/amazon/awssdk/codegen/poet/builder/test-no-auth-service-client-builder-class.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package software.amazon.awssdk.services.database; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import software.amazon.awssdk.annotations.Generated; | ||
import software.amazon.awssdk.annotations.SdkInternalApi; | ||
import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; | ||
import software.amazon.awssdk.core.client.config.SdkClientConfiguration; | ||
import software.amazon.awssdk.core.client.config.SdkClientOption; | ||
import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; | ||
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; | ||
import software.amazon.awssdk.http.auth.spi.AuthScheme; | ||
import software.amazon.awssdk.http.auth.spi.NoAuthAuthScheme; | ||
import software.amazon.awssdk.services.database.auth.scheme.DatabaseAuthSchemeProvider; | ||
import software.amazon.awssdk.services.database.auth.scheme.internal.DatabaseAuthSchemeInterceptor; | ||
import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider; | ||
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor; | ||
import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor; | ||
import software.amazon.awssdk.utils.CollectionUtils; | ||
|
||
/** | ||
* Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}. | ||
*/ | ||
@Generated("software.amazon.awssdk:codegen") | ||
@SdkInternalApi | ||
abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends | ||
AwsDefaultClientBuilder<B, C> { | ||
private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); | ||
|
||
@Override | ||
protected final String serviceEndpointPrefix() { | ||
return "database-service-endpoint"; | ||
} | ||
|
||
@Override | ||
protected final String serviceName() { | ||
return "Database"; | ||
} | ||
|
||
@Override | ||
protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { | ||
return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) | ||
.option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) | ||
.option(SdkClientOption.AUTH_SCHEMES, authSchemes()) | ||
.option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)); | ||
} | ||
|
||
@Override | ||
protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { | ||
List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); | ||
endpointInterceptors.add(new DatabaseAuthSchemeInterceptor()); | ||
endpointInterceptors.add(new DatabaseResolveEndpointInterceptor()); | ||
endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor()); | ||
ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); | ||
List<ExecutionInterceptor> interceptors = interceptorFactory | ||
.getInterceptors("software/amazon/awssdk/services/database/execution.interceptors"); | ||
List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); | ||
interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); | ||
interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); | ||
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); | ||
SdkClientConfiguration.Builder builder = config.toBuilder(); | ||
builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); | ||
return builder.build(); | ||
} | ||
|
||
@Override | ||
protected final String signingName() { | ||
return "database-service"; | ||
} | ||
|
||
private DatabaseEndpointProvider defaultEndpointProvider() { | ||
return DatabaseEndpointProvider.defaultProvider(); | ||
} | ||
|
||
public B authSchemeProvider(DatabaseAuthSchemeProvider authSchemeProvider) { | ||
clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); | ||
return thisBuilder(); | ||
} | ||
|
||
private DatabaseAuthSchemeProvider defaultAuthSchemeProvider() { | ||
return DatabaseAuthSchemeProvider.defaultProvider(); | ||
} | ||
|
||
@Override | ||
public B putAuthScheme(AuthScheme<?> authScheme) { | ||
additionalAuthSchemes.put(authScheme.schemeId(), authScheme); | ||
return thisBuilder(); | ||
} | ||
|
||
private Map<String, AuthScheme<?>> authSchemes() { | ||
Map<String, AuthScheme<?>> schemes = new HashMap<>(1 + this.additionalAuthSchemes.size()); | ||
NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); | ||
schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); | ||
schemes.putAll(this.additionalAuthSchemes); | ||
return Collections.unmodifiableMap(schemes); | ||
} | ||
|
||
protected static void validateClientOptions(SdkClientConfiguration c) { | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
.../software/amazon/awssdk/codegen/poet/client/c2j/service-with-no-auth/customization.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
55 changes: 55 additions & 0 deletions
55
...ources/software/amazon/awssdk/codegen/poet/client/c2j/service-with-no-auth/service-2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"version": "2.0", | ||
"metadata": { | ||
"apiVersion": "2023-06-08", | ||
"endpointPrefix": "database-service-endpoint", | ||
"globalEndpoint": "database-service.amazonaws.com", | ||
"protocol": "rest-json", | ||
"serviceAbbreviation": "Database Service", | ||
"serviceFullName": "Some Service That Has No Auth At All", | ||
"serviceId": "Database Service", | ||
"signingName": "database-service", | ||
"signatureVersion": "none", | ||
"auth": [], | ||
"uid": "database-service-2023-06-08", | ||
"xmlNamespace": "https://database-service.amazonaws.com/doc/2023-06-08/" | ||
}, | ||
"operations": { | ||
"GetDatabaseVersion": { | ||
"name": "GetDatabaseVersion", | ||
"http": { | ||
"method": "GET", | ||
"requestUri": "/get-version/" | ||
}, | ||
"input": { | ||
"shape": "GetDatabaseVersionRequest" | ||
}, | ||
"output": { | ||
"shape": "GetDatabaseVersionResponse" | ||
}, | ||
"documentation": "<p>Performs a get database version operation</p>" | ||
} | ||
}, | ||
"shapes": { | ||
"GetDatabaseVersionRequest": { | ||
"type": "structure", | ||
"members": { | ||
"StringMember": { | ||
"shape": "String", | ||
"documentation": "<p>A string Member</p>" | ||
} | ||
} | ||
}, | ||
"GetDatabaseVersionResponse": { | ||
"type": "structure", | ||
"members": { | ||
"StringMember": { | ||
"shape": "String", | ||
"documentation": "<p>A string Member</p>" | ||
} | ||
} | ||
}, | ||
"String":{"type":"string"} | ||
}, | ||
"documentation": "A Database Service with no auth on the service at all" | ||
} |