-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Detect CF-on-K8s in `cf api` * Unpin protobuf * Implement `cf login` for CF-on-K8s * Use the latest cloudfoundry/go-log-cache * Introduce a `ConnectionWrapper` for Kubernetes * Refactor the creation of the wrapped CC client * Support Kubernetes inline client certificates * Support Kubernetes client certificates of any kind * Test Kubernetes exec plugins * Support inline and filepath Kubernetes tokens * Clear the Kubernetes auth information in `cf api` * Clear the Kubernetes auth information in `cf api --unset` * Clear the Kubernetes auth information in `cf logout` * Use the real Kubernetes username when creating a space role * Use the real Kubernetes username everywhere Co-authored-by: Giuseppe Capizzi <[email protected]> Co-authored-by: Danail Branekov <[email protected]> Co-authored-by: Georgi Sabev <[email protected]> Co-authored-by: Kieron Browne <[email protected]> Co-authored-by: Mario Nitchev <[email protected]>
- Loading branch information
1 parent
685c102
commit f743425
Showing
399 changed files
with
4,762 additions
and
1,198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package sharedaction | ||
|
||
type DefaultAuthActor struct { | ||
config Config | ||
} | ||
|
||
func NewDefaultAuthActor(config Config) DefaultAuthActor { | ||
return DefaultAuthActor{ | ||
config: config, | ||
} | ||
} | ||
|
||
func (a DefaultAuthActor) IsLoggedIn() bool { | ||
return a.config.AccessToken() != "" || a.config.RefreshToken() != "" | ||
} | ||
|
||
type K8sAuthActor struct { | ||
config Config | ||
} | ||
|
||
func NewK8sAuthActor(config Config) K8sAuthActor { | ||
return K8sAuthActor{ | ||
config: config, | ||
} | ||
} | ||
|
||
func (a K8sAuthActor) IsLoggedIn() bool { | ||
name, err := a.config.CurrentUserName() | ||
|
||
return err == nil && name != "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package sharedaction_test | ||
|
||
import ( | ||
"errors" | ||
|
||
. "code.cloudfoundry.org/cli/actor/sharedaction" | ||
"code.cloudfoundry.org/cli/actor/sharedaction/sharedactionfakes" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("AuthActor", func() { | ||
var ( | ||
actor *Actor | ||
fakeConfig *sharedactionfakes.FakeConfig | ||
) | ||
|
||
BeforeEach(func() { | ||
fakeConfig = new(sharedactionfakes.FakeConfig) | ||
}) | ||
|
||
Context("Default CF on VMs", func() { | ||
BeforeEach(func() { | ||
actor = NewActor(fakeConfig) | ||
}) | ||
|
||
When("only the access token is set", func() { | ||
BeforeEach(func() { | ||
fakeConfig.AccessTokenReturns("some-access-token") | ||
}) | ||
|
||
It("returns true", func() { | ||
Expect(actor.IsLoggedIn()).To(BeTrue()) | ||
}) | ||
}) | ||
|
||
When("only the refresh token is set", func() { | ||
BeforeEach(func() { | ||
fakeConfig.RefreshTokenReturns("some-refresh-token") | ||
}) | ||
|
||
It("returns true", func() { | ||
Expect(actor.IsLoggedIn()).To(BeTrue()) | ||
}) | ||
}) | ||
|
||
When("both access and refresh token are set", func() { | ||
BeforeEach(func() { | ||
fakeConfig.AccessTokenReturns("some-access-token") | ||
fakeConfig.RefreshTokenReturns("some-refresh-token") | ||
}) | ||
|
||
It("returns true", func() { | ||
Expect(actor.IsLoggedIn()).To(BeTrue()) | ||
}) | ||
}) | ||
|
||
When("neither access nor refresh token are set", func() { | ||
BeforeEach(func() { | ||
fakeConfig.AccessTokenReturns("") | ||
fakeConfig.RefreshTokenReturns("") | ||
}) | ||
|
||
It("returns false", func() { | ||
Expect(actor.IsLoggedIn()).To(BeFalse()) | ||
}) | ||
}) | ||
}) | ||
|
||
Context("CF on K8s", func() { | ||
BeforeEach(func() { | ||
fakeConfig.IsCFOnK8sReturns(true) | ||
actor = NewActor(fakeConfig) | ||
}) | ||
|
||
When("the auth info is set", func() { | ||
BeforeEach(func() { | ||
fakeConfig.CurrentUserNameReturns("non-empty", nil) | ||
}) | ||
|
||
It("returns true", func() { | ||
Expect(actor.IsLoggedIn()).To(BeTrue()) | ||
}) | ||
}) | ||
|
||
When("the auth info is not set", func() { | ||
BeforeEach(func() { | ||
fakeConfig.CurrentUserNameReturns("", nil) | ||
}) | ||
|
||
It("returns false", func() { | ||
Expect(actor.IsLoggedIn()).To(BeFalse()) | ||
}) | ||
}) | ||
|
||
When("getting the current user name fails", func() { | ||
BeforeEach(func() { | ||
fakeConfig.CurrentUserNameReturns("", errors.New("boom!")) | ||
}) | ||
|
||
It("returns false", func() { | ||
Expect(actor.IsLoggedIn()).To(BeFalse()) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.