Skip to content

Commit 0197130

Browse files
Add missing app role auth test case (spiffe#5058)
1 parent 0adbae3 commit 0197130

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pkg/server/plugin/keymanager/hashicorpvault/vault_client_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,32 @@ func TestNewAuthenticatedClientAppRoleAuth(t *testing.T) {
213213
}
214214
}
215215

216+
func TestNewAuthenticatedClientAppRoleAuthFailed(t *testing.T) {
217+
fakeVaultServer := newFakeVaultServer()
218+
fakeVaultServer.AppRoleAuthResponseCode = 500
219+
220+
s, addr, err := fakeVaultServer.NewTLSServer()
221+
require.NoError(t, err)
222+
223+
s.Start()
224+
defer s.Close()
225+
226+
retry := 0 // Disable retry
227+
cp := &ClientParams{
228+
MaxRetries: &retry,
229+
VaultAddr: fmt.Sprintf("https://%v/", addr),
230+
CACertPath: testRootCert,
231+
AppRoleID: "test-approle-id",
232+
AppRoleSecretID: "test-approle-secret-id",
233+
}
234+
cc, err := NewClientConfig(cp, hclog.Default())
235+
require.NoError(t, err)
236+
237+
renewCh := make(chan struct{})
238+
_, err = cc.NewAuthenticatedClient(APPROLE, renewCh)
239+
spiretest.RequireGRPCStatusHasPrefix(t, err, codes.Unauthenticated, "authentication failed auth/approle/login: Error making API request.")
240+
}
241+
216242
func TestNewAuthenticatedClientCertAuth(t *testing.T) {
217243
fakeVaultServer := newFakeVaultServer()
218244
fakeVaultServer.CertAuthResponseCode = 200

0 commit comments

Comments
 (0)