From 35f70fc98ab8f045b7902f45e7a5cc54acb351cd Mon Sep 17 00:00:00 2001 From: Francis Chuang Date: Tue, 26 Mar 2024 10:07:23 +1100 Subject: [PATCH] Clean up rotated test keys --- path_config_rotate_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/path_config_rotate_test.go b/path_config_rotate_test.go index c818dc2..f941545 100644 --- a/path_config_rotate_test.go +++ b/path_config_rotate_test.go @@ -35,9 +35,8 @@ func TestPathConfigRotateRoot(t *testing.T) { defer func() { err := key.Delete(context.Background()) - if err != nil { - t.Fatalf("Unable to delete test rotation key: %s", err) + t.Errorf("Unable to delete test rotation key: %s", err) } }() @@ -88,4 +87,13 @@ func TestPathConfigRotateRoot(t *testing.T) { if config.ApplicationKey == key.Secret() { t.Fatal("old and new application keys are equal after rotate-root, it shouldn't be") } + + keys, _, err := client.ListKeys(context.Background(), 1, config.ApplicationKeyId) + for _, currentKey := range keys { + if currentKey.ID() == config.ApplicationKeyId { + if err = currentKey.Delete(context.Background()); err != nil { + t.Errorf("Unable to delete rotated key: %s", err) + } + } + } }