Skip to content

Commit

Permalink
Clear the Kubernetes auth-info in cf api --unset
Browse files Browse the repository at this point in the history
  • Loading branch information
gcapizzi committed Nov 10, 2021
1 parent 192a120 commit 9e6ad82
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions actor/v7action/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ func (actor Actor) SetTarget(settings TargetSettings) (Warnings, error) {
func (actor Actor) ClearTarget() {
actor.Config.SetTargetInformation(configv3.TargetInformationArgs{})
actor.Config.SetTokenInformation("", "", "")
actor.Config.SetKubernetesAuthInfo("")
}
9 changes: 9 additions & 0 deletions actor/v7action/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,14 @@ var _ = Describe("Targeting", func() {
Expect(refreshToken).To(BeEmpty())
Expect(sshOAuthClient).To(BeEmpty())
})

It("clears the Kubernetes auth-info", func() {
actor.ClearTarget()

Expect(fakeConfig.SetKubernetesAuthInfoCallCount()).To(Equal(1))
authInfo := fakeConfig.SetKubernetesAuthInfoArgsForCall(0)

Expect(authInfo).To(BeEmpty())
})
})
})
20 changes: 20 additions & 0 deletions integration/v7/selfcontained/api_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,23 @@ var _ = Describe("cf api", func() {
})
})
})

var _ = Describe("cf api --unset", func() {
BeforeEach(func() {
helpers.SetConfig(func(config *configv3.Config) {
config.ConfigFile.CFOnK8s.Enabled = true
config.ConfigFile.CFOnK8s.AuthInfo = "something"
})
})

JustBeforeEach(func() {
Eventually(helpers.CF("api", "--unset")).Should(gexec.Exit(0))
})

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

0 comments on commit 9e6ad82

Please sign in to comment.