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

internal/ini: Normalize Section keys to lowercase #495

Merged
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ SDK Features

SDK Enhancements
---
* `internal/ini`: Normalize Section keys to lowercase ([#495](https://github.com/aws/aws-sdk-go-v2/pull/495))
* Update's SDK's ini utility to store all keys as lowercase. This brings the SDK inline with the AWS CLI's behavior.

SDK Bugs
---
10 changes: 10 additions & 0 deletions aws/external/shared_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,16 @@ func TestLoadSharedConfigFromFile(t *testing.T) {
Err: nil,
},
},
{
Profile: "with_mixed_case_keys",
Expected: SharedConfig{
Credentials: aws.Credentials{
AccessKeyID: "accessKey",
SecretAccessKey: "secret",
Source: fmt.Sprintf("SharedConfigCredentials: %s", testConfigFilename),
},
},
},
}

for i, c := range cases {
Expand Down
5 changes: 5 additions & 0 deletions aws/external/testdata/shared_config
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ s3_use_arn_region=true
[endpoint_discovery]
endpoint_discovery_enabled=true


[with_mixed_case_keys]
aWs_AcCeSs_kEy_ID = accessKey
aWs_SecrEt_AccEsS_kEY = secret

[assume_role_with_credential_source]
role_arn = assume_role_with_credential_source_role_arn
credential_source = Ec2InstanceMetadata
Expand Down
4 changes: 4 additions & 0 deletions internal/ini/testdata/valid/mixed_case_keys
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[with_mixed_case_keys]
sTring_Value = secret
iNt_Value = 60
flOAt_Value = 12.3
7 changes: 7 additions & 0 deletions internal/ini/testdata/valid/mixed_case_keys_expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"with_mixed_case_keys": {
"int_value": 60,
"string_value": "secret",
"float_value": 12.3
}
}
2 changes: 1 addition & 1 deletion internal/ini/testdata/valid/utf_8_profile_expected
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ʃʉʍΡιξ": {
"ϰϪϧ": "Ϯϴϖ",
"ϰϫϧ": "Ϯϴϖ",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wish I didn't have to change this, but, it has a capitalized UTF-8 character.

"ϝϧ": "ϟΞ΅"
}
}
3 changes: 2 additions & 1 deletion internal/ini/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ini
import (
"fmt"
"sort"
"strings"
)

// Visitor is an interface used by walkers that will
Expand Down Expand Up @@ -60,7 +61,7 @@ func (v *DefaultVisitor) VisitExpr(expr AST) error {
return err
}

t.values[key] = v
t.values[strings.ToLower(key)] = v
default:
return NewParseError(fmt.Sprintf("unsupported expression %v", expr))
}
Expand Down