Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear the Kubernetes auth-info in cf api
Browse files Browse the repository at this point in the history
gcapizzi committed Nov 10, 2021

Unverified

This user has not yet uploaded their public signing key.
1 parent f4ce8cf commit 192a120
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions actor/v7action/target.go
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) {
})

actor.Config.SetTokenInformation("", "", "")
actor.Config.SetKubernetesAuthInfo("")

return allWarnings, nil
}
7 changes: 7 additions & 0 deletions actor/v7action/target_test.go
Original file line number Diff line number Diff line change
@@ -131,6 +131,13 @@ var _ = Describe("Targeting", func() {
Expect(sshOAuthClient).To(BeEmpty())
})

It("clears the Kubernetes auth-info", func() {
Expect(fakeConfig.SetKubernetesAuthInfoCallCount()).To(Equal(1))
authInfo := fakeConfig.SetKubernetesAuthInfoArgsForCall(0)

Expect(authInfo).To(BeEmpty())
})

It("succeeds and returns all warnings", func() {
Expect(err).ToNot(HaveOccurred())
Expect(warnings).To(ConsistOf(Warnings{"info-warning"}))
33 changes: 33 additions & 0 deletions integration/v7/selfcontained/api_command_test.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
"code.cloudfoundry.org/cli/integration/helpers"
"code.cloudfoundry.org/cli/integration/v7/selfcontained/fake"
"code.cloudfoundry.org/cli/util/configv3"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
@@ -43,4 +44,36 @@ var _ = Describe("cf api", func() {
Expect(loadConfig().CFOnK8s.Enabled).To(BeTrue())
})
})

When("already logged into a cf-on-k8s", func() {
BeforeEach(func() {
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.CFOnK8s.Enabled = true
config.ConfigFile.CFOnK8s.AuthInfo = "something"
})
})

It("disables cf-on-k8s in config and clears the auth-info", func() {
Expect(loadConfig().CFOnK8s).To(Equal(configv3.CFOnK8s{
Enabled: false,
AuthInfo: "",
}))
})

When("pointed to cf-on-k8s", func() {
BeforeEach(func() {
apiConfig.Routes["GET /"] = fake.Response{
Code: http.StatusOK, Body: ccv3.Info{CFOnK8s: true},
}
apiServer.SetConfiguration(apiConfig)
})

It("clears the auth-info", func() {
Expect(loadConfig().CFOnK8s).To(Equal(configv3.CFOnK8s{
Enabled: true,
AuthInfo: "",
}))
})
})
})
})

0 comments on commit 192a120

Please sign in to comment.