Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/credentialhelper/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (s *credentialHelperStore) GetSecrets(_ context.Context, pattern plugin.Pat

func (s *credentialHelperStore) Run(ctx context.Context) error {
<-ctx.Done()
return nil
return ctx.Err()
}

var _ plugin.Plugin = &credentialHelperStore{}
Expand Down
27 changes: 27 additions & 0 deletions plugins/credentialhelper/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package credentialhelper

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -219,6 +220,32 @@ func TestCredentialHelper(t *testing.T) {
})
}

func TestRun(t *testing.T) {
t.Run("returns context cancelled when context is cancelled", func(t *testing.T) {
c, err := New(testhelper.TestLogger(t),
WithShellProgramFunc(func(args ...string) client.Program {
return &mockCredentialHelper{
t: t,
operation: args[0],
store: map[string]credentials.Credentials{},
}
}),
)
require.NoError(t, err)

ctx, cancel := context.WithCancel(t.Context())

done := make(chan error, 1)
go func() {
done <- c.Run(ctx)
}()

cancel()

require.ErrorIs(t, <-done, context.Canceled)
})
}

func TestDefaultKeyRewriter(t *testing.T) {
for _, tc := range []struct {
desc string
Expand Down
Loading