Skip to content

Commit

Permalink
Merge branch 'main' into cli-61-filter-logs-by-clientid
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Mar 12, 2021
2 parents 56e256a + 2e15176 commit 65c3f3e
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions internal/auth/secrets_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package auth

import (
"testing"

"github.com/zalando/go-keyring"
)

func TestSecrets(t *testing.T) {
t.Run("fail: not found", func(t *testing.T) {
// init underlying keychain manager
keyring.MockInit()

kr := &Keyring{}
_, err := kr.Get("mynamespace", "foo")

if got, want := err, keyring.ErrNotFound; got != want {
t.Fatalf("wanted error: %v, got: %v", want, got)
}
})

t.Run("succeed: get secret", func(t *testing.T) {
// init underlying keychain manager
keyring.MockInit()

// set with the underlying manager:
err := keyring.Set("mynamespace", "foo", "bar")
if err != nil {
t.Fatal(err)
}

kr := &Keyring{}
v, err := kr.Get("mynamespace", "foo")
if err != nil {
t.Fatal(err)
}

if got, want := v, "bar"; got != want {
t.Fatalf("wanted error: %v, got: %v", want, got)
}
})

t.Run("succeed: set secret", func(t *testing.T) {
// init underlying keychain manager
keyring.MockInit()

kr := &Keyring{}
err := kr.Set("mynamespace", "foo", "bar")
if err != nil {
t.Fatal(err)
}

// get with the underlying manager:
v, err := keyring.Get("mynamespace", "foo")
if err != nil {
t.Fatal(err)
}

if got, want := v, "bar"; got != want {
t.Fatalf("wanted secret: %v, got: %v", want, got)
}
})
}

0 comments on commit 65c3f3e

Please sign in to comment.