Use new HasActiveToken method in trustedroot.go
This commit is contained in:
parent
88d48f2365
commit
d8e77d256f
2 changed files with 8 additions and 8 deletions
|
|
@ -74,7 +74,7 @@ func NewTrustedRootCmd(f *cmdutil.Factory, runF func(*Options) error) *cobra.Com
|
|||
return err
|
||||
}
|
||||
|
||||
if token, _ := c.Authentication().ActiveToken(opts.Hostname); token == "" {
|
||||
if !c.Authentication().HasActiveToken(opts.Hostname) {
|
||||
return fmt.Errorf("not authenticated with %s", opts.Hostname)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ func TestNewTrustedRootWithTenancy(t *testing.T) {
|
|||
Config: func() (gh.Config, error) {
|
||||
return &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
return &MockAuthConfig{Token: ""}
|
||||
return &stubAuthConfig{hasActiveToken: false}
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
|
|
@ -136,7 +136,7 @@ func TestNewTrustedRootWithTenancy(t *testing.T) {
|
|||
Config: func() (gh.Config, error) {
|
||||
return &ghmock.ConfigMock{
|
||||
AuthenticationFunc: func() gh.AuthConfig {
|
||||
return &MockAuthConfig{Token: "TOKEN"}
|
||||
return &stubAuthConfig{hasActiveToken: true}
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
|
|
@ -186,13 +186,13 @@ func TestGetTrustedRoot(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
type MockAuthConfig struct {
|
||||
type stubAuthConfig struct {
|
||||
config.AuthConfig
|
||||
Token string
|
||||
hasActiveToken bool
|
||||
}
|
||||
|
||||
var _ gh.AuthConfig = (*MockAuthConfig)(nil)
|
||||
var _ gh.AuthConfig = (*stubAuthConfig)(nil)
|
||||
|
||||
func (c *MockAuthConfig) ActiveToken(host string) (string, string) {
|
||||
return c.Token, ""
|
||||
func (c *stubAuthConfig) HasActiveToken(host string) bool {
|
||||
return c.hasActiveToken
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue