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

Contains Ignorecase Check for ProfileCredentials property keys read from ~/.aws/credentials file. #4164

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package software.amazon.awssdk.profiles;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.TreeMap;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.utils.SystemSetting;
import software.amazon.awssdk.utils.ToString;
Expand Down Expand Up @@ -190,7 +190,10 @@ public void setName(String name) {

@Override
public Builder properties(Map<String, String> properties) {
this.properties = Collections.unmodifiableMap(new LinkedHashMap<>(properties));
Map<String, String> keyCaseInsensitiveMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
keyCaseInsensitiveMap.putAll(properties);
//Why LinkedHashMap being used here, should we really consider insertion order?
this.properties = Collections.unmodifiableMap(keyCaseInsensitiveMap);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ public void profilesCanContainProperties() {
.isEqualTo(profiles(profile("foo", property("name", "value"))));
}

@Test
public void profilesCanContainPropertiesWithMixedCase() {
Map<String, Profile> profiles = profiles(profile("foo", property("name", "value")));
assertThat(configFileProfiles("[profile foo]\n" +
"Name = value"))
.isEqualTo(profiles);

profiles.forEach((s, profile) -> {
assertThat(s).isEqualTo("foo");
assertThat(profile.properties().containsKey("NAME")).isTrue();
assertThat(profile.properties().containsKey("Name")).isTrue();
assertThat(profile.properties().containsKey("naMe")).isTrue();
assertThat(profile.properties().containsKey("name")).isTrue();
});
}

@Test
public void windowsStyleLineEndingsAreSupported() {
assertThat(configFileProfiles("[profile foo]\r\n" +
Expand Down