Simplify TestCLIGetKubeconfigStaticToken now that there's only a single table case.

Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
Matt Moyer 2021-03-23 10:26:04 -05:00
parent 2e79664f3d
commit 9501168265
No known key found for this signature in database
GPG Key ID: EAE88AD172C5AE2D
1 changed files with 51 additions and 69 deletions

View File

@ -49,34 +49,16 @@ func TestCLIGetKubeconfigStaticToken(t *testing.T) {
// Build pinniped CLI.
pinnipedExe := library.PinnipedCLIPath(t)
for _, tt := range []struct {
name string
args []string
expectStderrContains []string
}{
{
name: "newer command, but still using static parameters",
args: []string{
"get", "kubeconfig",
stdout, stderr := runPinnipedCLI(t, nil, pinnipedExe, "get", "kubeconfig",
"--static-token", env.TestUser.Token,
"--concierge-api-group-suffix", env.APIGroupSuffix,
"--concierge-authenticator-type", "webhook",
"--concierge-authenticator-name", authenticator.Name,
},
expectStderrContains: []string{
"discovered CredentialIssuer",
"discovered Concierge endpoint",
"discovered Concierge certificate authority bundle",
"validated connection to the cluster",
},
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
stdout, stderr := runPinnipedCLI(t, nil, pinnipedExe, tt.args...)
for _, s := range tt.expectStderrContains {
assert.Contains(t, stderr, s)
}
)
assert.Contains(t, stderr, "discovered CredentialIssuer")
assert.Contains(t, stderr, "discovered Concierge endpoint")
assert.Contains(t, stderr, "discovered Concierge certificate authority bundle")
assert.Contains(t, stderr, "validated connection to the cluster")
// Even the deprecated command should now generate a kubeconfig with the new "pinniped login static" command.
restConfig := library.NewRestConfigFromKubeconfig(t, stdout)
@ -107,6 +89,7 @@ func TestCLIGetKubeconfigStaticToken(t *testing.T) {
t.Run("access as group "+group+" with client-go", library.AccessAsGroupTest(ctx, group, kubeClient))
}
t.Run("whoami", func(t *testing.T) {
// Validate that `pinniped whoami` returns the correct identity.
kubeconfigPath := filepath.Join(testutil.TempDir(t), "whoami-kubeconfig")
require.NoError(t, ioutil.WriteFile(kubeconfigPath, []byte(stdout), 0600))
@ -120,7 +103,6 @@ func TestCLIGetKubeconfigStaticToken(t *testing.T) {
append(env.TestUser.ExpectedGroups, "system:authenticated"),
)
})
}
}
func runPinnipedCLI(t *testing.T, envVars []string, pinnipedExe string, args ...string) (string, string) {