From cb21303f952bb91088213b047c35716c87d084a1 Mon Sep 17 00:00:00 2001 From: juligasa <11684004+juligasa@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:37:07 +0200 Subject: [PATCH] fix(daemon): return empty list on unitialised keyring --- backend/core/keystore.go | 2 +- backend/core/keystore_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/core/keystore.go b/backend/core/keystore.go index 6f2d19e45..c8510a894 100644 --- a/backend/core/keystore.go +++ b/backend/core/keystore.go @@ -139,7 +139,7 @@ func (ks *osKeyStore) ListKeys(ctx context.Context) ([]NamedKey, error) { secret, err := keyring.Get(ks.serviceName, collectionName) if err != nil { - return ret, errEmptyEnvironment + return ret, nil } collection := keyCollection{} diff --git a/backend/core/keystore_test.go b/backend/core/keystore_test.go index a82749135..b20c18c1d 100644 --- a/backend/core/keystore_test.go +++ b/backend/core/keystore_test.go @@ -39,7 +39,8 @@ func TestOSKeyStore(t *testing.T) { emptyKey, err := ks.GetKey(ctx, "keyName") require.Error(t, err) keys, err := ks.ListKeys(ctx) - require.Error(t, err) + require.NoError(t, err) + require.Len(t, keys, 0) require.NoError(t, ks.StoreKey(ctx, "keyName", kp)) key, err := ks.GetKey(ctx, "keyName") require.NoError(t, err)