From aca9af748b7e55be7e64154225bcd6917f7f151d Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Tue, 15 Dec 2020 12:23:52 -0600 Subject: [PATCH] Cleanup TestSuccessfulCredentialRequest and TestCLILoginOIDC a little. Signed-off-by: Matt Moyer --- test/integration/cli_test.go | 4 ++-- .../concierge_credentialrequest_test.go | 18 +++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/test/integration/cli_test.go b/test/integration/cli_test.go index 1259ccce..8de33728 100644 --- a/test/integration/cli_test.go +++ b/test/integration/cli_test.go @@ -129,7 +129,7 @@ func TestCLILoginOIDC(t *testing.T) { pinnipedExe := library.PinnipedCLIPath(t) // Run "pinniped login oidc" to get an ExecCredential struct with an OIDC ID token. - credOutput, sessionCachePath := runPinniedLoginOIDC(ctx, t, pinnipedExe) + credOutput, sessionCachePath := runPinnipedLoginOIDC(ctx, t, pinnipedExe) // Assert some properties of the ExecCredential. t.Logf("validating ExecCredential") @@ -195,7 +195,7 @@ func TestCLILoginOIDC(t *testing.T) { require.NotEqual(t, credOutput2.Status.Token, credOutput3.Status.Token) } -func runPinniedLoginOIDC( +func runPinnipedLoginOIDC( ctx context.Context, t *testing.T, pinnipedExe string, diff --git a/test/integration/concierge_credentialrequest_test.go b/test/integration/concierge_credentialrequest_test.go index 1a53ef38..8e3e6a99 100644 --- a/test/integration/concierge_credentialrequest_test.go +++ b/test/integration/concierge_credentialrequest_test.go @@ -47,26 +47,22 @@ func TestSuccessfulCredentialRequest(t *testing.T) { tests := []struct { name string - authenticator func(t *testing.T) corev1.TypedLocalObjectReference + authenticator func(context.Context, *testing.T) corev1.TypedLocalObjectReference token func(t *testing.T) (token string, username string, groups []string) }{ { - name: "webhook", - authenticator: func(t *testing.T) corev1.TypedLocalObjectReference { - return library.CreateTestWebhookAuthenticator(ctx, t) - }, + name: "webhook", + authenticator: library.CreateTestWebhookAuthenticator, token: func(t *testing.T) (string, string, []string) { return library.IntegrationEnv(t).TestUser.Token, env.TestUser.ExpectedUsername, env.TestUser.ExpectedGroups }, }, { - name: "jwt authenticator", - authenticator: func(t *testing.T) corev1.TypedLocalObjectReference { - return library.CreateTestJWTAuthenticator(ctx, t) - }, + name: "jwt authenticator", + authenticator: library.CreateTestJWTAuthenticator, token: func(t *testing.T) (string, string, []string) { pinnipedExe := library.PinnipedCLIPath(t) - credOutput, _ := runPinniedLoginOIDC(ctx, t, pinnipedExe) + credOutput, _ := runPinnipedLoginOIDC(ctx, t, pinnipedExe) token := credOutput.Status.Token // By default, the JWTAuthenticator expects the username to be in the "sub" claim and the @@ -80,7 +76,7 @@ func TestSuccessfulCredentialRequest(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { - authenticator := test.authenticator(t) + authenticator := test.authenticator(ctx, t) token, username, groups := test.token(t) var response *loginv1alpha1.TokenCredentialRequest