Skip to content

Commit

Permalink
Add some minor secretsmanager tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Duchesne committed Jul 30, 2019
1 parent a4fc538 commit 0734fa8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions credentials/source_secretsmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,28 @@ func TestGetCredentialsFromSecretsManagerSourceWithID(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, testCredentials, credentials)
}

func TestGetCredentialsFromSecretsManagerSourceWithUnknownPrefix(t *testing.T) {
// Third credentials crashes the GetSecretValue call
secretsManagerSource := &AWSSecretsManagerSource{
SecretPrefix: "bad",
client: &mockSecretsManagerClient{t: t},
}

credentials, err := secretsManagerSource.Credentials()
assert.EqualError(t, err, "No secrets found with the 'bad' prefix")
assert.Nil(t, credentials)
}

func TestGetCredentialsFromSecretsManagerSourceWithBadPrefix(t *testing.T) {
// Third credentials crashes the GetSecretValue call
secretsManagerSource := &AWSSecretsManagerSource{
SecretPrefix: thirdSecretName,
client: &mockSecretsManagerClient{t: t},
}

credentials, err := secretsManagerSource.Credentials()
assert.Error(t, err)
assert.Contains(t, err.Error(), "Error while fetching secret "+thirdSecretARN)
assert.Nil(t, credentials)
}

0 comments on commit 0734fa8

Please sign in to comment.