Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit c1f2527

Browse files
committed
Rewrite test to not depend on unauthenticated client
This no longer is available. As this test does not care about actually sending an authenticated request to the API, we just set some dummy credential that does not actually do anything.
1 parent 120cabd commit c1f2527

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

internals/secrethub/client_factory_test.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/secrethub/secrethub-go/internals/api"
910
"github.com/secrethub/secrethub-go/internals/assert"
11+
"github.com/secrethub/secrethub-go/internals/auth"
1012
"github.com/secrethub/secrethub-go/pkg/secrethub/credentials"
13+
httpclient "github.com/secrethub/secrethub-go/pkg/secrethub/internals/http"
1114

1215
"github.com/secrethub/secrethub-cli/internals/cli/ui"
1316
)
@@ -42,10 +45,24 @@ func TestNewClientFactory_ProxyAddress(t *testing.T) {
4245
proxyAddress: proxyAddress,
4346
}
4447

45-
client, err := factory.NewUnauthenticatedClient()
48+
client, err := factory.NewClientWithCredentials(dummyCredential{})
4649
assert.OK(t, err)
4750

48-
_, _ = client.Users().Create("test", "test@test.test", "test", credentials.CreateKey())
51+
_, _ = client.Me().GetUser()
4952
assert.OK(t, err)
5053
assert.Equal(t, proxyReceivedRequest, true)
5154
}
55+
56+
type dummyCredential struct {
57+
}
58+
59+
type nopDecrypter struct {
60+
}
61+
62+
func (n nopDecrypter) Unwrap(ciphertext *api.EncryptedData) ([]byte, error) {
63+
return nil, nil
64+
}
65+
66+
func (d dummyCredential) Provide(client *httpclient.Client) (auth.Authenticator, credentials.Decrypter, error) {
67+
return auth.NopAuthenticator{}, nopDecrypter{}, nil
68+
}

0 commit comments

Comments
 (0)