Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prompt aws profile and fallback to input
- Loading branch information
1 parent
74528df
commit b1e8ec6
Showing
5 changed files
with
164 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package credentials_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/commitdev/zero/internal/config/globalconfig" | ||
"github.com/commitdev/zero/pkg/credentials" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFillAWSProfileCredentials(t *testing.T) { | ||
mockAwsCredentialFilePath := "../../tests/test_data/aws/mock_credentials.yml" | ||
t.Run("fills project credentials", func(t *testing.T) { | ||
projectCreds := globalconfig.ProjectCredential{} | ||
projectCreds = credentials.GetAWSProfileCredentials(mockAwsCredentialFilePath, "default", projectCreds) | ||
assert.Equal(t, "MOCK1_ACCESS_KEY", projectCreds.AWSResourceConfig.AccessKeyId) | ||
assert.Equal(t, "MOCK1_SECRET_ACCESS_KEY", projectCreds.AWSResourceConfig.SecretAccessKey) | ||
}) | ||
|
||
t.Run("supports non-default profiles", func(t *testing.T) { | ||
projectCreds := globalconfig.ProjectCredential{} | ||
projectCreds = credentials.GetAWSProfileCredentials(mockAwsCredentialFilePath, "foobar", projectCreds) | ||
assert.Equal(t, "MOCK2_ACCESS_KEY", projectCreds.AWSResourceConfig.AccessKeyId) | ||
assert.Equal(t, "MOCK2_SECRET_ACCESS_KEY", projectCreds.AWSResourceConfig.SecretAccessKey) | ||
}) | ||
} |
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,7 @@ | ||
[default] | ||
aws_access_key_id=MOCK1_ACCESS_KEY | ||
aws_secret_access_key=MOCK1_SECRET_ACCESS_KEY | ||
|
||
[foobar] | ||
aws_access_key_id=MOCK2_ACCESS_KEY | ||
aws_secret_access_key=MOCK2_SECRET_ACCESS_KEY |