-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: allow endpoint overrides in AwsSecretsManagerVault #485
base: main
Are you sure you want to change the base?
feat: allow endpoint overrides in AwsSecretsManagerVault #485
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are always happy to welcome new contributors ❤️ To make things easier for everyone, please make sure to follow our contribution guidelines, check if you have already signed the ECA, and relate this pull request to an existing issue or discussion.
@chlorochrule do NOT submit surprise PRs. Committers will then triage the issue and approve it for implementation by removing the |
@paullatzelsperger I apologize for the breaking etiquette, and thank you for pointing that out! I created a ticket #486 |
This pull request is stale because it has been open for 7 days with no activity. |
@Setting | ||
private static final String AWS_ENDPOINT_OVERRIDE = "edc.aws.endpoint.override"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this setting should be different than the one used to create the S3 client, and be called edc.vault.aws.endpoint.override
, to align with the region setting.
plus, settings can be injected in a different way, as described in this DR
Please adapt and add some description
to the annotation
@@ -47,4 +47,15 @@ void configOptionRegionProvided_shouldNotThrowException() { | |||
extension.createVault(validContext); | |||
} | |||
|
|||
@Test | |||
void configOptionEndpointOverrideProvided_shouldNotThrowException() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is asserting nothing. I know that you inherited from the already existing tests, but tests without assertions should be avoided.
Demonstration: if you try to add a proper assertion like:
var vault = extension.createVault(validContext);
assertThat(vault).extracting("smClient", type(SecretsManagerClient.class)).satisfies(client -> {
assertThat(client.serviceClientConfiguration().endpointOverride()).contains(URI.create("http://localhost:4566"));
});
it won't pass, that's because you set the mock to respond a call where only the setting key is passed, but not the default value.
Another suggestion would be not to mock the config object but to create one using ConfigFactory.fromMap
, that will make everything easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ndr-brt Thank you for reviewing! I fixed!
@Setting(key = "edc.vault.aws.region", | ||
description = "The AWS Secrets Manager client will point to the specified region") | ||
String vaultRegion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AwsClientBuilder#region
can identify the endpoint automatically, so it might be better to support required = false
https://github.com/aws/aws-sdk-java-v2/blob/891cf4fb6f37ac671fa91663c23965585fbdd504/core/aws-core/src/main/java/software/amazon/awssdk/awscore/client/builder/AwsClientBuilder.java#L85-L97
@Setting(key = "edc.vault.aws.region", | ||
description = "The AWS Secrets Manager client will point to the specified region") | ||
String vaultRegion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private for testing
@Setting(key = "edc.vault.aws.endpoint.override", | ||
description = "If valued, the AWS Secrets Manager client will point to the specified endpoint", | ||
required = false) | ||
String vaultAwsEndpointOverride; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private for testing
private static ServiceExtensionContext context; | ||
|
||
@BeforeAll | ||
public static void beforeAll() { | ||
context = mock(ServiceExtensionContext.class); | ||
when(context.getMonitor()).thenReturn(mock(Monitor.class)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AwsSecretsManagerVaultExtension
uses only monitor
, does not use ServiceExtensionContext
extension.vaultRegion = "eu-west-1"; | ||
extension.vaultAwsEndpointOverride = "http://localhost:4566"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to use key
of @Setting
, but I can't find the way to inject the testing value to the field variable. Please let me know how to test @Setting
annotated value with key
overrides if you know a better way!
@chlorochrule when you are ready for another review please re-request my review, so this will be listed on my "review-to-be-done" tab ;) |
What this PR changes/adds
AwsSecretsManagerVaultExtension
do not allow to override AWS endpoint. However,S3CoreExtension
allows it. So, I implements endpoint overrides inAwsSecretsManagerVault
usingedc.aws.endpoint.override
the same param ofS3CoreExtension
.Why it does that
For AWS-compatible services like localstack.
Closes #486