Skip to content

Commit 176bb58

Browse files
committed
e2e tests for cached auth + --save-cluster-auth
1 parent d6927ff commit 176bb58

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

e2e/e2e_core_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,4 +474,46 @@ func TestCore_DeployWithCachedAuth(t *testing.T) {
474474
if err := newCmd(t, "deploy", "--build=false", "--push=false").Run(); err != nil {
475475
t.Fatalf("expected redeploy with cached auth to succeed, got: %v", err)
476476
}
477+
478+
// Step 4: the pinned cluster and cached auth survive the broken-kubeconfig
479+
// redeploy (the target did not silently follow the active kubeconfig).
480+
if f, err = fn.NewFunction(root); err != nil {
481+
t.Fatal(err)
482+
}
483+
if f.Deploy.Cluster == "" {
484+
t.Fatal("expected Deploy.Cluster to remain pinned after redeploy with cached auth")
485+
}
486+
if f.Local.FindAuth(f.Deploy.Cluster) == nil {
487+
t.Fatalf("expected cached auth for %q to persist after redeploy", f.Deploy.Cluster)
488+
}
489+
}
490+
491+
// TestCore_DeploySaveAuthFalse verifies that `deploy --save-cluster-auth=false` still
492+
// deploys via the active kubeconfig (the "old way") and pins the cluster, but
493+
// does NOT cache credentials into .func/local.yaml.
494+
func TestCore_DeploySaveAuthFalse(t *testing.T) {
495+
name := "func-e2e-test-save-auth-false"
496+
root := fromCleanEnv(t, name)
497+
defer clean(t, name, Namespace)
498+
499+
if err := newCmd(t, "init", "-l=go").Run(); err != nil {
500+
t.Fatal(err)
501+
}
502+
if err := newCmd(t, "deploy", "--save-cluster-auth=false").Run(); err != nil {
503+
t.Fatal(err)
504+
}
505+
if !waitFor(t, ksvcUrl(name)) {
506+
t.Fatal("function did not deploy with --save-cluster-auth=false")
507+
}
508+
509+
f, err := fn.NewFunction(root)
510+
if err != nil {
511+
t.Fatal(err)
512+
}
513+
if f.Deploy.Cluster == "" {
514+
t.Fatal("expected Deploy.Cluster to be pinned even with --save-cluster-auth=false")
515+
}
516+
if len(f.Local.Auth) != 0 {
517+
t.Fatalf("expected no cached credentials with --save-cluster-auth=false, got %d entries", len(f.Local.Auth))
518+
}
477519
}

0 commit comments

Comments
 (0)