Simplify TestCLIGetKubeconfigStaticToken now that there's only a single table case.
Signed-off-by: Matt Moyer <moyerm@vmware.com>
This commit is contained in:
parent
2e79664f3d
commit
9501168265
|
@ -49,34 +49,16 @@ func TestCLIGetKubeconfigStaticToken(t *testing.T) {
|
||||||
// Build pinniped CLI.
|
// Build pinniped CLI.
|
||||||
pinnipedExe := library.PinnipedCLIPath(t)
|
pinnipedExe := library.PinnipedCLIPath(t)
|
||||||
|
|
||||||
for _, tt := range []struct {
|
stdout, stderr := runPinnipedCLI(t, nil, pinnipedExe, "get", "kubeconfig",
|
||||||
name string
|
|
||||||
args []string
|
|
||||||
expectStderrContains []string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "newer command, but still using static parameters",
|
|
||||||
args: []string{
|
|
||||||
"get", "kubeconfig",
|
|
||||||
"--static-token", env.TestUser.Token,
|
"--static-token", env.TestUser.Token,
|
||||||
"--concierge-api-group-suffix", env.APIGroupSuffix,
|
"--concierge-api-group-suffix", env.APIGroupSuffix,
|
||||||
"--concierge-authenticator-type", "webhook",
|
"--concierge-authenticator-type", "webhook",
|
||||||
"--concierge-authenticator-name", authenticator.Name,
|
"--concierge-authenticator-name", authenticator.Name,
|
||||||
},
|
)
|
||||||
expectStderrContains: []string{
|
assert.Contains(t, stderr, "discovered CredentialIssuer")
|
||||||
"discovered CredentialIssuer",
|
assert.Contains(t, stderr, "discovered Concierge endpoint")
|
||||||
"discovered Concierge endpoint",
|
assert.Contains(t, stderr, "discovered Concierge certificate authority bundle")
|
||||||
"discovered Concierge certificate authority bundle",
|
assert.Contains(t, stderr, "validated connection to the cluster")
|
||||||
"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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Even the deprecated command should now generate a kubeconfig with the new "pinniped login static" command.
|
// Even the deprecated command should now generate a kubeconfig with the new "pinniped login static" command.
|
||||||
restConfig := library.NewRestConfigFromKubeconfig(t, stdout)
|
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("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.
|
// Validate that `pinniped whoami` returns the correct identity.
|
||||||
kubeconfigPath := filepath.Join(testutil.TempDir(t), "whoami-kubeconfig")
|
kubeconfigPath := filepath.Join(testutil.TempDir(t), "whoami-kubeconfig")
|
||||||
require.NoError(t, ioutil.WriteFile(kubeconfigPath, []byte(stdout), 0600))
|
require.NoError(t, ioutil.WriteFile(kubeconfigPath, []byte(stdout), 0600))
|
||||||
|
@ -120,7 +103,6 @@ func TestCLIGetKubeconfigStaticToken(t *testing.T) {
|
||||||
append(env.TestUser.ExpectedGroups, "system:authenticated"),
|
append(env.TestUser.ExpectedGroups, "system:authenticated"),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPinnipedCLI(t *testing.T, envVars []string, pinnipedExe string, args ...string) (string, string) {
|
func runPinnipedCLI(t *testing.T, envVars []string, pinnipedExe string, args ...string) (string, string) {
|
||||||
|
|
Loading…
Reference in New Issue