Skip to content

Commit

Permalink
test(kms-key): fix tests for new alias property and list aliases call
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Oct 11, 2024
1 parent 27e65bd commit 54b15be
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions resources/kms-key_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ func Test_Mock_KMSKey_List(t *testing.T) {
},
)

mockKMS.EXPECT().ListAliases(&kms.ListAliasesInput{
KeyId: aws.String("test-key-id"),
}).Return(&kms.ListAliasesOutput{
Aliases: []*kms.AliasListEntry{
{AliasName: aws.String("alias/test-key-id")},
},
}, nil)

lister := KMSKeyLister{
mockSvc: mockKMS,
}
Expand Down Expand Up @@ -123,6 +131,14 @@ func Test_Mock_KMSKey_List_WithAccessDenied(t *testing.T) {
},
)

mockKMS.EXPECT().ListAliases(&kms.ListAliasesInput{
KeyId: aws.String("test-key-id-1"),
}).Return(&kms.ListAliasesOutput{
Aliases: []*kms.AliasListEntry{
{AliasName: aws.String("alias/test-key-id-1")},
},
}, nil)

lister := KMSKeyLister{
mockSvc: mockKMS,
}
Expand Down Expand Up @@ -180,6 +196,7 @@ func Test_Mock_KMSKey_Properties(t *testing.T) {
ID: ptr.String("test-key-id"),
State: ptr.String(kms.KeyStateEnabled),
Manager: ptr.String(kms.KeyManagerTypeCustomer),
Alias: ptr.String("alias/test-key-id"),
Tags: []*kms.Tag{
{TagKey: aws.String("Environment"), TagValue: aws.String("Test")},
},
Expand All @@ -189,6 +206,7 @@ func Test_Mock_KMSKey_Properties(t *testing.T) {
assert.Equal(t, kms.KeyStateEnabled, kmsKey.Properties().Get("State"))
assert.Equal(t, kms.KeyManagerTypeCustomer, kmsKey.Properties().Get("Manager"))
assert.Equal(t, "Test", kmsKey.Properties().Get("tag:Environment"))
assert.Equal(t, "alias/test-key-id", kmsKey.Properties().Get("Alias"))
}

func Test_Mock_KMSKey_Remove(t *testing.T) {
Expand Down

0 comments on commit 54b15be

Please sign in to comment.