-
Notifications
You must be signed in to change notification settings - Fork 972
Adding service endpoint section in config file #5944
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
Merged
RanVaknin
merged 9 commits into
master
from
rvaknin/add-services-section-in-ini-file-for-endpoint-url-support
Mar 18, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8b40330
Adding service endpoint section in ini file
RanVaknin e9131eb
Adding INI file services section parsing
RanVaknin 8f39c61
Removed not needed file
RanVaknin f8416ac
Fixing test names and adding changelog
RanVaknin 262f9da
Fix checkstyle
RanVaknin 4a58904
Adding java doc
RanVaknin bf63b8e
Relocating test to decrease generated test case count
RanVaknin 92b9370
Adding comment about current behavior deviating from the standard
RanVaknin 71423c7
Fix comments on the PR
RanVaknin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
| { | ||
| "type": "feature", | ||
| "category": "AWS SDK for Java v2", | ||
| "contributor": "", | ||
| "description": "Added functionality to be able to configure an endpoint override through the [services] section in the aws config file for specific services. \nhttps://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html" | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
127 changes: 127 additions & 0 deletions
127
...d-classes-test/src/test/java/software/amazon/awssdk/services/ProfileFileServicesTest.java
This file contains hidden or 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,127 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| package software.amazon.awssdk.services; | ||
|
|
||
| import java.util.Optional; | ||
| import org.junit.jupiter.api.Test; | ||
| import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider; | ||
| import software.amazon.awssdk.awscore.endpoint.AwsClientEndpointProvider; | ||
| import software.amazon.awssdk.profiles.Profile; | ||
| import software.amazon.awssdk.profiles.ProfileFile; | ||
| import software.amazon.awssdk.regions.Region; | ||
| import software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonClient; | ||
| import software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonClientBuilder; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class ProfileFileServicesTest { | ||
|
|
||
| @Test | ||
| public void servicesSection_shouldRecognizeServicesSection() { | ||
| String profileContent = | ||
| "[services dev]\n" + | ||
| "s3 = \n" + | ||
| " endpoint_url = https://foo.bar:9000\n"; | ||
|
|
||
| ProfileFile profileFile = ProfileFile.builder() | ||
| .content(profileContent) | ||
| .type(ProfileFile.Type.CONFIGURATION) | ||
| .build(); | ||
|
|
||
| Optional<Profile> servicesSection = profileFile.getSection("services", "dev"); | ||
| assertThat(servicesSection).isPresent(); | ||
| } | ||
|
|
||
| @Test | ||
| public void servicesSection_canParseServicesSectionProperties() { | ||
| String profileContent = | ||
| "[services dev]\n" + | ||
| "s3 = \n" + | ||
| " endpoint_url = https://foo.bar:9000\n" + | ||
| " foo = bar\n" + | ||
| "\n" + | ||
| "[profile test-profile]\n" + | ||
| "services = dev"; | ||
|
|
||
| ProfileFile profileFile = ProfileFile.builder() | ||
| .content(profileContent) | ||
| .type(ProfileFile.Type.CONFIGURATION) | ||
| .build(); | ||
|
|
||
| Optional<Profile> servicesSection = profileFile.getSection("services", "dev"); | ||
| assertThat(servicesSection).isPresent(); | ||
|
|
||
| Profile services = servicesSection.get(); | ||
| assertThat(services.properties()) | ||
| .containsEntry("s3.endpoint_url", "https://foo.bar:9000"); | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void servicesSection_canParseMultipleServicesInSection() { | ||
| String profileContent = | ||
| "[services testing-s3-and-eb]\n" + | ||
| "s3 = \n" + | ||
| " endpoint_url = http://localhost:4567\n" + | ||
| "elastic_beanstalk = \n" + | ||
| " endpoint_url = http://localhost:8000\n" + | ||
| "\n" + | ||
| "[profile dev]\n" + | ||
| "services = testing-s3-and-eb"; | ||
|
|
||
| ProfileFile profileFile = ProfileFile.builder() | ||
| .content(profileContent) | ||
| .type(ProfileFile.Type.CONFIGURATION) | ||
| .build(); | ||
|
|
||
| Optional<Profile> servicesSection = profileFile.getSection("services", "testing-s3-and-eb"); | ||
| assertThat(servicesSection).isPresent(); | ||
|
|
||
| Profile services = servicesSection.get(); | ||
| assertThat(services.properties()) | ||
| .containsEntry("s3.endpoint_url", "http://localhost:4567") | ||
| .containsEntry("elastic_beanstalk.endpoint_url", "http://localhost:8000"); | ||
| } | ||
|
|
||
| @org.junit.Test(expected = EndpointCapturingInterceptor.CaptureCompletedException.class) | ||
| public void invalidNestedBlockFormat_shouldThrowCaptureCompletedException() { | ||
| StringBuilder profileFileContent = new StringBuilder(); | ||
| profileFileContent.append("[default] \n") | ||
| .append("services = dev \n") | ||
| .append("\n") | ||
| .append("[services dev] \n") | ||
| .append("amazonprotocolrestjson =\n") | ||
| .append("endpoint_url ="); | ||
|
|
||
| ProfileFile profileFile = ProfileFile.builder() | ||
| .type(ProfileFile.Type.CONFIGURATION) | ||
| .content(profileFileContent.toString()) | ||
| .build(); | ||
|
|
||
| ProtocolRestJsonClientBuilder builder = ProtocolRestJsonClient.builder() | ||
| .region(Region.US_WEST_2) | ||
| .credentialsProvider(AnonymousCredentialsProvider.create()) | ||
| .overrideConfiguration(c -> c.defaultProfileFile(profileFile) | ||
| .defaultProfileName("default")); | ||
|
|
||
| EndpointCapturingInterceptor interceptor = new EndpointCapturingInterceptor(); | ||
| builder.overrideConfiguration(b -> b.addExecutionInterceptor(interceptor)); | ||
|
|
||
| ProtocolRestJsonClient client = builder.build(); | ||
|
|
||
| client.allTypes(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.