(t *testing.T)
| 31 | ) |
| 32 | |
| 33 | func Test_passPlugin(t *testing.T) { |
| 34 | t.Parallel() |
| 35 | t.Run("ok", func(t *testing.T) { |
| 36 | mock := teststore.NewMockStore(teststore.WithStore(map[store.ID]store.Secret{ |
| 37 | store.MustParseID("foo"): pass.NewPassValue([]byte("bar")), |
| 38 | })) |
| 39 | p := &passPlugin{kc: mock, logger: testhelper.TestLogger(t)} |
| 40 | e, err := p.GetSecrets(t.Context(), secrets.MustParsePattern("foo")) |
| 41 | require.NoError(t, err) |
| 42 | require.NotEmpty(t, e) |
| 43 | assert.Equal(t, "bar", string(e[0].Value)) |
| 44 | }) |
| 45 | t.Run("no secrets", func(t *testing.T) { |
| 46 | mock := teststore.NewMockStore(teststore.WithStore(map[store.ID]store.Secret{})) |
| 47 | p := &passPlugin{kc: mock} |
| 48 | _, err := p.GetSecrets(t.Context(), secrets.MustParsePattern("foo")) |
| 49 | assert.ErrorIs(t, err, secrets.ErrNotFound) |
| 50 | }) |
| 51 | t.Run("store error", func(t *testing.T) { |
| 52 | errFilter := errors.New("filter error") |
| 53 | mock := teststore.NewMockStore(teststore.WithStoreFilterErr(errFilter)) |
| 54 | p := &passPlugin{kc: mock, logger: testhelper.TestLogger(t)} |
| 55 | _, err := p.GetSecrets(t.Context(), secrets.MustParsePattern("foo")) |
| 56 | assert.ErrorIs(t, err, errFilter) |
| 57 | }) |
| 58 | t.Run("unwrap error", func(*testing.T) { |
| 59 | mock := teststore.NewMockStore(teststore.WithStore(map[store.ID]store.Secret{ |
| 60 | store.MustParseID("foo"): &MockMyOtherValue{Value: 7}, |
| 61 | })) |
| 62 | p := &passPlugin{kc: mock, logger: testhelper.TestLogger(t)} |
| 63 | _, err := p.GetSecrets(t.Context(), secrets.MustParsePattern("foo")) |
| 64 | assert.ErrorIs(t, err, secrets.ErrNotFound) |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | var _ store.Secret = &MockMyOtherValue{} |
| 69 |
nothing calls this directly
no test coverage detected