From 0734fa84726aad996152103fcb99e49c488a7083 Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Mon, 29 Jul 2019 20:02:13 -0400 Subject: [PATCH] Add some minor secretsmanager tests --- credentials/source_secretsmanager_test.go | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/credentials/source_secretsmanager_test.go b/credentials/source_secretsmanager_test.go index cb3e9ba..30c82cd 100644 --- a/credentials/source_secretsmanager_test.go +++ b/credentials/source_secretsmanager_test.go @@ -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) +}