Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/app/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ func TestAppAddCommand(t *testing.T) {
func prepareAddMocks(t *testing.T, clients *shared.ClientFactory, clientsMock *shared.ClientsMock) {
clientsMock.AddDefaultMocks()

clientsMock.AuthInterface.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).
clientsMock.Auth.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Updating our mocks to clientsMock.Auth

Return("api host")
clientsMock.AuthInterface.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).
clientsMock.Auth.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).
Return("logstash host")

manifestMock := &app.ManifestMockObject{}
Expand Down
4 changes: 2 additions & 2 deletions cmd/app/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ func TestAppsDeleteCommand(t *testing.T) {
func prepareCommonDeleteMocks(t *testing.T, cf *shared.ClientFactory, cm *shared.ClientsMock) {
cm.AddDefaultMocks()

cm.AuthInterface.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).
cm.Auth.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).
Return("api host")
cm.AuthInterface.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).
cm.Auth.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).
Return("logstash host")

// Mock list command
Expand Down
6 changes: 3 additions & 3 deletions cmd/app/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func promptExistingApp(ctx context.Context, clients *shared.ClientFactory) (type

// promptTeamSlackAuth retrieves an authenticated team from input
func promptTeamSlackAuth(ctx context.Context, clients *shared.ClientFactory) (*types.SlackAuth, error) {
allAuths, err := clients.AuthInterface().Auths(ctx)
allAuths, err := clients.Auth().Auths(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Updating our client to clients.Auth()

if err != nil {
return &types.SlackAuth{}, err
}
Expand Down Expand Up @@ -322,7 +322,7 @@ func promptTeamSlackAuth(ctx context.Context, clients *shared.ClientFactory) (*t
return &types.SlackAuth{}, err
}
if selection.Prompt {
clients.AuthInterface().SetSelectedAuth(ctx, allAuths[selection.Index], clients.Config, clients.Os)
clients.Auth().SetSelectedAuth(ctx, allAuths[selection.Index], clients.Config, clients.Os)
return &allAuths[selection.Index], nil
}
teamMatch := false
Expand All @@ -341,7 +341,7 @@ func promptTeamSlackAuth(ctx context.Context, clients *shared.ClientFactory) (*t
if !teamMatch {
return &types.SlackAuth{}, slackerror.New(slackerror.ErrCredentialsNotFound)
}
clients.AuthInterface().SetSelectedAuth(ctx, allAuths[teamIndex], clients.Config, clients.Os)
clients.Auth().SetSelectedAuth(ctx, allAuths[teamIndex], clients.Config, clients.Os)
return &allAuths[teamIndex], nil
}

Expand Down
18 changes: 9 additions & 9 deletions cmd/app/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func Test_Apps_Link(t *testing.T) {
testutil.TableTestCommand(t, testutil.CommandTests{
"saves information about the provided deployed app": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth2,
mockLinkSlackAuth1,
}, nil)
Expand Down Expand Up @@ -114,7 +114,7 @@ func Test_Apps_Link(t *testing.T) {
},
"saves information about the provided local app": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth2,
mockLinkSlackAuth1,
}, nil)
Expand Down Expand Up @@ -173,7 +173,7 @@ func Test_Apps_Link(t *testing.T) {
},
"avoids overwriting an app saved in json without confirmation": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth1,
mockLinkSlackAuth2,
}, nil)
Expand Down Expand Up @@ -242,7 +242,7 @@ func Test_Apps_Link(t *testing.T) {
},
"avoids overwriting a matching app id for the team without confirmation": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth1,
mockLinkSlackAuth2,
}, nil)
Expand Down Expand Up @@ -317,7 +317,7 @@ func Test_Apps_Link(t *testing.T) {
},
"completes overwriting an app saved in json with confirmation": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth1,
mockLinkSlackAuth2,
}, nil)
Expand Down Expand Up @@ -385,7 +385,7 @@ func Test_Apps_Link(t *testing.T) {
},
"refuses to write an app with app id not existing upstream": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth1,
mockLinkSlackAuth2,
}, nil)
Expand Down Expand Up @@ -433,7 +433,7 @@ func Test_Apps_Link(t *testing.T) {
},
"accepting manifest source prompt should save information about the provided deployed app": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth2,
mockLinkSlackAuth1,
}, nil)
Expand Down Expand Up @@ -540,7 +540,7 @@ func Test_Apps_Link(t *testing.T) {
},
"manifest source prompt should not display for Run-on-Slack apps with local manifest source": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth1,
mockLinkSlackAuth2,
}, nil)
Expand Down Expand Up @@ -617,7 +617,7 @@ func Test_Apps_Link(t *testing.T) {
},
"manifest source prompt should display for GBP apps with local manifest source": {
Setup: func(t *testing.T, ctx context.Context, cm *shared.ClientsMock, cf *shared.ClientFactory) {
cm.AuthInterface.On("Auths", mock.Anything).Return([]types.SlackAuth{
cm.Auth.On("Auths", mock.Anything).Return([]types.SlackAuth{
mockLinkSlackAuth1,
mockLinkSlackAuth2,
}, nil)
Expand Down
4 changes: 2 additions & 2 deletions cmd/app/uninstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ func prepareCommonUninstallMocks(ctx context.Context, clients *shared.ClientFact
appSelectMock.On("AppSelectPrompt").Return(selectedProdApp, nil)

// Mock API calls
clientsMock.AuthInterface.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).
clientsMock.Auth.On("ResolveAPIHost", mock.Anything, mock.Anything, mock.Anything).
Return("api host")
clientsMock.AuthInterface.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).
clientsMock.Auth.On("ResolveLogstashHost", mock.Anything, mock.Anything, mock.Anything).
Return("logstash host")

clientsMock.API.On("ValidateSession", mock.Anything, mock.Anything).Return(api.AuthSession{
Expand Down
16 changes: 8 additions & 8 deletions cmd/auth/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func TestLoginCommand(t *testing.T) {
TeamName: &mockOrgAuth.TeamDomain,
URL: &mockOrgAuthURL,
}, nil)
cm.AuthInterface.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.AuthInterface.On(
cm.Auth.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.Auth.On(
"AuthWithTeamDomain",
mock.Anything,
mock.Anything,
Expand Down Expand Up @@ -94,8 +94,8 @@ func TestLoginCommand(t *testing.T) {
},
nil,
)
cm.AuthInterface.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.AuthInterface.On(
cm.Auth.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.Auth.On(
"SetAuth",
mock.Anything,
mock.Anything,
Expand Down Expand Up @@ -124,8 +124,8 @@ func TestLoginCommand(t *testing.T) {
},
nil,
)
cm.AuthInterface.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.AuthInterface.On(
cm.Auth.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.Auth.On(
"SetAuth",
mock.Anything,
mock.Anything,
Expand All @@ -146,8 +146,8 @@ func TestLoginCommand(t *testing.T) {
Required: true,
}).Return(mockChallengeCode, nil)
cm.API.On("ExchangeAuthTicket", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(api.ExchangeAuthTicketResult{}, nil)
cm.AuthInterface.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.AuthInterface.On(
cm.Auth.On("IsAPIHostSlackProd", mock.Anything).Return(true)
cm.Auth.On(
"SetAuth",
mock.Anything,
mock.Anything,
Expand Down
16 changes: 8 additions & 8 deletions cmd/auth/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,31 @@ func handleAuthRemoval(ctx context.Context, clients *shared.ClientFactory, auth
defer span.Finish()

// Update the API Host and Logstash Host to be the selected/default auth
clients.Config.APIHostResolved = clients.AuthInterface().ResolveAPIHost(ctx, clients.Config.APIHostFlag, &auth)
clients.Config.LogstashHostResolved = clients.AuthInterface().ResolveLogstashHost(ctx, clients.Config.APIHostResolved, clients.Config.Version)
clients.Config.APIHostResolved = clients.Auth().ResolveAPIHost(ctx, clients.Config.APIHostFlag, &auth)
clients.Config.LogstashHostResolved = clients.Auth().ResolveLogstashHost(ctx, clients.Config.APIHostResolved, clients.Config.Version)

// First, try to revoke the xoxe-xoxp (auth) token credential
var xoxpToken = auth.Token
if err := clients.AuthInterface().RevokeToken(ctx, xoxpToken); err != nil {
if err := clients.Auth().RevokeToken(ctx, xoxpToken); err != nil {
return err
}

// Next, try to revoke the refresh token xoxe-1 credential
var refreshToken = auth.RefreshToken
if refreshToken != "" {
if err := clients.AuthInterface().RevokeToken(ctx, refreshToken); err != nil {
if err := clients.Auth().RevokeToken(ctx, refreshToken); err != nil {
return err
}
}

// Once successfully revoked, remove from credentials.json
if _, err := clients.AuthInterface().DeleteAuth(ctx, auth); err != nil {
if _, err := clients.Auth().DeleteAuth(ctx, auth); err != nil {
return err
}

// Update the API Host and Logstash Host to be the selected/default auth
clients.Config.APIHostResolved = clients.AuthInterface().ResolveAPIHost(ctx, clients.Config.APIHostFlag, nil)
clients.Config.LogstashHostResolved = clients.AuthInterface().ResolveLogstashHost(ctx, clients.Config.APIHostResolved, clients.Config.Version)
clients.Config.APIHostResolved = clients.Auth().ResolveAPIHost(ctx, clients.Config.APIHostFlag, nil)
clients.Config.LogstashHostResolved = clients.Auth().ResolveLogstashHost(ctx, clients.Config.APIHostResolved, clients.Config.Version)

return nil
}
Expand All @@ -136,7 +136,7 @@ func promptUserLogout(ctx context.Context, clients *shared.ClientFactory, cmd *c
}

// Gather all available auths
auths, err := clients.AuthInterface().Auths(ctx)
auths, err := clients.Auth().Auths(ctx)
if err != nil {
return []types.SlackAuth{}, err
}
Expand Down
Loading
Loading