From dbf6238029e58cd5a69ae249ed31669b50171f0c Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Mon, 28 Oct 2019 20:02:59 +0900 Subject: [PATCH] Refactor: rename auth package (#172) --- e2e_test/credetial_plugin_test.go | 4 +-- e2e_test/standalone_test.go | 6 ++-- pkg/di/di.go | 10 +++---- pkg/di/wire_gen.go | 22 +++++++-------- .../authentication.go} | 4 +-- .../authentication_test.go} | 2 +- .../mock_authentication.go} | 14 ++++++---- pkg/usecases/credentialplugin/get_token.go | 8 +++--- .../credentialplugin/get_token_test.go | 20 ++++++------- pkg/usecases/setup/setup.go | 4 +-- pkg/usecases/setup/stage2.go | 4 +-- pkg/usecases/setup/stage2_test.go | 10 +++---- pkg/usecases/standalone/standalone.go | 6 ++-- pkg/usecases/standalone/standalone_test.go | 28 +++++++++---------- 14 files changed, 72 insertions(+), 70 deletions(-) rename pkg/usecases/{auth/auth.go => authentication/authentication.go} (97%) rename pkg/usecases/{auth/auth_test.go => authentication/authentication_test.go} (99%) rename pkg/usecases/{auth/mock_auth/mock_auth.go => authentication/mock_authentication/mock_authentication.go} (71%) diff --git a/e2e_test/credetial_plugin_test.go b/e2e_test/credetial_plugin_test.go index 5cbb222..0a48563 100644 --- a/e2e_test/credetial_plugin_test.go +++ b/e2e_test/credetial_plugin_test.go @@ -15,7 +15,7 @@ import ( "github.com/int128/kubelogin/pkg/adaptors/credentialplugin/mock_credentialplugin" "github.com/int128/kubelogin/pkg/adaptors/logger/mock_logger" "github.com/int128/kubelogin/pkg/di" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" ) // Run the integration tests of the credential plugin use-case. @@ -74,7 +74,7 @@ func TestCmd_Run_CredentialPlugin(t *testing.T) { }) } -func runGetTokenCmd(t *testing.T, ctx context.Context, localServerReadyFunc auth.LocalServerReadyFunc, interaction credentialplugin.Interface, args ...string) { +func runGetTokenCmd(t *testing.T, ctx context.Context, localServerReadyFunc authentication.LocalServerReadyFunc, interaction credentialplugin.Interface, args ...string) { t.Helper() cmd := di.NewCmdForHeadless(mock_logger.New(t), localServerReadyFunc, interaction) exitCode := cmd.Run(ctx, append([]string{"kubelogin", "get-token", "--v=1"}, args...), "HEAD") diff --git a/e2e_test/standalone_test.go b/e2e_test/standalone_test.go index 96fcd50..e953cc3 100644 --- a/e2e_test/standalone_test.go +++ b/e2e_test/standalone_test.go @@ -17,7 +17,7 @@ import ( "github.com/int128/kubelogin/e2e_test/localserver" "github.com/int128/kubelogin/pkg/adaptors/logger/mock_logger" "github.com/int128/kubelogin/pkg/di" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" ) var ( @@ -312,7 +312,7 @@ func setupMockIDPForCodeFlow(t *testing.T, service *mock_idp.MockService, server }) } -func runCmd(t *testing.T, ctx context.Context, localServerReadyFunc auth.LocalServerReadyFunc, args ...string) { +func runCmd(t *testing.T, ctx context.Context, localServerReadyFunc authentication.LocalServerReadyFunc, args ...string) { t.Helper() cmd := di.NewCmdForHeadless(mock_logger.New(t), localServerReadyFunc, nil) exitCode := cmd.Run(ctx, append([]string{"kubelogin", "--v=1"}, args...), "HEAD") @@ -321,7 +321,7 @@ func runCmd(t *testing.T, ctx context.Context, localServerReadyFunc auth.LocalSe } } -func openBrowserOnReadyFunc(t *testing.T, ctx context.Context, clientConfig *tls.Config) auth.LocalServerReadyFunc { +func openBrowserOnReadyFunc(t *testing.T, ctx context.Context, clientConfig *tls.Config) authentication.LocalServerReadyFunc { return func(url string) { client := http.Client{Transport: &http.Transport{TLSClientConfig: clientConfig}} req, err := http.NewRequest("GET", url, nil) diff --git a/pkg/di/di.go b/pkg/di/di.go index 6ba4e0c..246bb28 100644 --- a/pkg/di/di.go +++ b/pkg/di/di.go @@ -12,7 +12,7 @@ import ( "github.com/int128/kubelogin/pkg/adaptors/logger" "github.com/int128/kubelogin/pkg/adaptors/oidc" "github.com/int128/kubelogin/pkg/adaptors/tokencache" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" credentialPluginUseCase "github.com/int128/kubelogin/pkg/usecases/credentialplugin" "github.com/int128/kubelogin/pkg/usecases/setup" "github.com/int128/kubelogin/pkg/usecases/standalone" @@ -22,8 +22,8 @@ import ( func NewCmd() cmd.Interface { wire.Build( // use-cases - auth.Set, - wire.Value(auth.DefaultLocalServerReadyFunc), + authentication.Set, + wire.Value(authentication.DefaultLocalServerReadyFunc), standalone.Set, credentialPluginUseCase.Set, setup.Set, @@ -41,9 +41,9 @@ func NewCmd() cmd.Interface { } // NewCmdForHeadless returns an instance of adaptors.Cmd for headless testing. -func NewCmdForHeadless(logger.Interface, auth.LocalServerReadyFunc, credentialPluginAdaptor.Interface) cmd.Interface { +func NewCmdForHeadless(logger.Interface, authentication.LocalServerReadyFunc, credentialPluginAdaptor.Interface) cmd.Interface { wire.Build( - auth.Set, + authentication.Set, standalone.Set, credentialPluginUseCase.Set, setup.Set, diff --git a/pkg/di/wire_gen.go b/pkg/di/wire_gen.go index 3c22ada..198c428 100644 --- a/pkg/di/wire_gen.go +++ b/pkg/di/wire_gen.go @@ -13,7 +13,7 @@ import ( "github.com/int128/kubelogin/pkg/adaptors/logger" "github.com/int128/kubelogin/pkg/adaptors/oidc" "github.com/int128/kubelogin/pkg/adaptors/tokencache" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" credentialplugin2 "github.com/int128/kubelogin/pkg/usecases/credentialplugin" "github.com/int128/kubelogin/pkg/usecases/setup" "github.com/int128/kubelogin/pkg/usecases/standalone" @@ -29,7 +29,7 @@ func NewCmd() cmd.Interface { decoder := &oidc.Decoder{} envEnv := &env.Env{} localServerReadyFunc := _wireLocalServerReadyFuncValue - authentication := &auth.Authentication{ + authenticationAuthentication := &authentication.Authentication{ OIDCFactory: factory, OIDCDecoder: decoder, Env: envEnv, @@ -38,7 +38,7 @@ func NewCmd() cmd.Interface { } kubeconfigKubeconfig := &kubeconfig.Kubeconfig{} standaloneStandalone := &standalone.Standalone{ - Authentication: authentication, + Authentication: authenticationAuthentication, Kubeconfig: kubeconfigKubeconfig, Logger: loggerInterface, } @@ -49,7 +49,7 @@ func NewCmd() cmd.Interface { repository := &tokencache.Repository{} interaction := &credentialplugin.Interaction{} getToken := &credentialplugin2.GetToken{ - Authentication: authentication, + Authentication: authenticationAuthentication, TokenCacheRepository: repository, Interaction: interaction, Logger: loggerInterface, @@ -59,7 +59,7 @@ func NewCmd() cmd.Interface { Logger: loggerInterface, } setupSetup := &setup.Setup{ - Authentication: authentication, + Authentication: authenticationAuthentication, Logger: loggerInterface, } cmdSetup := &cmd.Setup{ @@ -75,16 +75,16 @@ func NewCmd() cmd.Interface { } var ( - _wireLocalServerReadyFuncValue = auth.DefaultLocalServerReadyFunc + _wireLocalServerReadyFuncValue = authentication.DefaultLocalServerReadyFunc ) -func NewCmdForHeadless(loggerInterface logger.Interface, localServerReadyFunc auth.LocalServerReadyFunc, credentialpluginInterface credentialplugin.Interface) cmd.Interface { +func NewCmdForHeadless(loggerInterface logger.Interface, localServerReadyFunc authentication.LocalServerReadyFunc, credentialpluginInterface credentialplugin.Interface) cmd.Interface { factory := &oidc.Factory{ Logger: loggerInterface, } decoder := &oidc.Decoder{} envEnv := &env.Env{} - authentication := &auth.Authentication{ + authenticationAuthentication := &authentication.Authentication{ OIDCFactory: factory, OIDCDecoder: decoder, Env: envEnv, @@ -93,7 +93,7 @@ func NewCmdForHeadless(loggerInterface logger.Interface, localServerReadyFunc au } kubeconfigKubeconfig := &kubeconfig.Kubeconfig{} standaloneStandalone := &standalone.Standalone{ - Authentication: authentication, + Authentication: authenticationAuthentication, Kubeconfig: kubeconfigKubeconfig, Logger: loggerInterface, } @@ -103,7 +103,7 @@ func NewCmdForHeadless(loggerInterface logger.Interface, localServerReadyFunc au } repository := &tokencache.Repository{} getToken := &credentialplugin2.GetToken{ - Authentication: authentication, + Authentication: authenticationAuthentication, TokenCacheRepository: repository, Interaction: credentialpluginInterface, Logger: loggerInterface, @@ -113,7 +113,7 @@ func NewCmdForHeadless(loggerInterface logger.Interface, localServerReadyFunc au Logger: loggerInterface, } setupSetup := &setup.Setup{ - Authentication: authentication, + Authentication: authenticationAuthentication, Logger: loggerInterface, } cmdSetup := &cmd.Setup{ diff --git a/pkg/usecases/auth/auth.go b/pkg/usecases/authentication/authentication.go similarity index 97% rename from pkg/usecases/auth/auth.go rename to pkg/usecases/authentication/authentication.go index 2570d89..5e70518 100644 --- a/pkg/usecases/auth/auth.go +++ b/pkg/usecases/authentication/authentication.go @@ -1,4 +1,4 @@ -package auth +package authentication import ( "context" @@ -13,7 +13,7 @@ import ( "golang.org/x/xerrors" ) -//go:generate mockgen -destination mock_auth/mock_auth.go github.com/int128/kubelogin/pkg/usecases/auth Interface +//go:generate mockgen -destination mock_authentication/mock_authentication.go github.com/int128/kubelogin/pkg/usecases/authentication Interface // Set provides the use-case of Authentication. var Set = wire.NewSet( diff --git a/pkg/usecases/auth/auth_test.go b/pkg/usecases/authentication/authentication_test.go similarity index 99% rename from pkg/usecases/auth/auth_test.go rename to pkg/usecases/authentication/authentication_test.go index 269a095..d168996 100644 --- a/pkg/usecases/auth/auth_test.go +++ b/pkg/usecases/authentication/authentication_test.go @@ -1,4 +1,4 @@ -package auth +package authentication import ( "context" diff --git a/pkg/usecases/auth/mock_auth/mock_auth.go b/pkg/usecases/authentication/mock_authentication/mock_authentication.go similarity index 71% rename from pkg/usecases/auth/mock_auth/mock_auth.go rename to pkg/usecases/authentication/mock_authentication/mock_authentication.go index 7924b05..61cdf5d 100644 --- a/pkg/usecases/auth/mock_auth/mock_auth.go +++ b/pkg/usecases/authentication/mock_authentication/mock_authentication.go @@ -1,13 +1,13 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/int128/kubelogin/pkg/usecases/auth (interfaces: Interface) +// Source: github.com/int128/kubelogin/pkg/usecases/authentication (interfaces: Interface) -// Package mock_auth is a generated GoMock package. -package mock_auth +// Package mock_authentication is a generated GoMock package. +package mock_authentication import ( context "context" gomock "github.com/golang/mock/gomock" - auth "github.com/int128/kubelogin/pkg/usecases/auth" + authentication "github.com/int128/kubelogin/pkg/usecases/authentication" reflect "reflect" ) @@ -35,14 +35,16 @@ func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { } // Do mocks base method -func (m *MockInterface) Do(arg0 context.Context, arg1 auth.Input) (*auth.Output, error) { +func (m *MockInterface) Do(arg0 context.Context, arg1 authentication.Input) (*authentication.Output, error) { + m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Do", arg0, arg1) - ret0, _ := ret[0].(*auth.Output) + ret0, _ := ret[0].(*authentication.Output) ret1, _ := ret[1].(error) return ret0, ret1 } // Do indicates an expected call of Do func (mr *MockInterfaceMockRecorder) Do(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockInterface)(nil).Do), arg0, arg1) } diff --git a/pkg/usecases/credentialplugin/get_token.go b/pkg/usecases/credentialplugin/get_token.go index 0371c92..a2c2161 100644 --- a/pkg/usecases/credentialplugin/get_token.go +++ b/pkg/usecases/credentialplugin/get_token.go @@ -11,7 +11,7 @@ import ( "github.com/int128/kubelogin/pkg/adaptors/kubeconfig" "github.com/int128/kubelogin/pkg/adaptors/logger" "github.com/int128/kubelogin/pkg/adaptors/tokencache" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" "golang.org/x/xerrors" ) @@ -42,7 +42,7 @@ type Input struct { } type GetToken struct { - Authentication auth.Interface + Authentication authentication.Interface TokenCacheRepository tokencache.Interface Interaction credentialplugin.Interface Logger logger.Interface @@ -61,7 +61,7 @@ func (u *GetToken) Do(ctx context.Context, in Input) error { return nil } -func (u *GetToken) getTokenFromCacheOrProvider(ctx context.Context, in Input) (*auth.Output, error) { +func (u *GetToken) getTokenFromCacheOrProvider(ctx context.Context, in Input) (*authentication.Output, error) { u.Logger.V(1).Infof("finding a token from cache directory %s", in.TokenCacheDir) cacheKey := tokencache.Key{IssuerURL: in.IssuerURL, ClientID: in.ClientID} cache, err := u.TokenCacheRepository.FindByKey(in.TokenCacheDir, cacheKey) @@ -70,7 +70,7 @@ func (u *GetToken) getTokenFromCacheOrProvider(ctx context.Context, in Input) (* cache = &tokencache.TokenCache{} } - out, err := u.Authentication.Do(ctx, auth.Input{ + out, err := u.Authentication.Do(ctx, authentication.Input{ OIDCConfig: kubeconfig.OIDCConfig{ IDPIssuerURL: in.IssuerURL, ClientID: in.ClientID, diff --git a/pkg/usecases/credentialplugin/get_token_test.go b/pkg/usecases/credentialplugin/get_token_test.go index 43a7d6b..a1e3c36 100644 --- a/pkg/usecases/credentialplugin/get_token_test.go +++ b/pkg/usecases/credentialplugin/get_token_test.go @@ -12,8 +12,8 @@ import ( "github.com/int128/kubelogin/pkg/adaptors/logger/mock_logger" "github.com/int128/kubelogin/pkg/adaptors/tokencache" "github.com/int128/kubelogin/pkg/adaptors/tokencache/mock_tokencache" - "github.com/int128/kubelogin/pkg/usecases/auth" - "github.com/int128/kubelogin/pkg/usecases/auth/mock_auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" + "github.com/int128/kubelogin/pkg/usecases/authentication/mock_authentication" "golang.org/x/xerrors" ) @@ -37,9 +37,9 @@ func TestGetToken_Do(t *testing.T) { CACertFilename: "/path/to/cert", SkipTLSVerify: true, } - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{ + Do(ctx, authentication.Input{ OIDCConfig: kubeconfig.OIDCConfig{ IDPIssuerURL: "https://accounts.google.com", ClientID: "YOUR_CLIENT_ID", @@ -52,7 +52,7 @@ func TestGetToken_Do(t *testing.T) { CACertFilename: "/path/to/cert", SkipTLSVerify: true, }). - Return(&auth.Output{ + Return(&authentication.Output{ IDToken: "YOUR_ID_TOKEN", RefreshToken: "YOUR_REFRESH_TOKEN", IDTokenExpiry: futureTime, @@ -102,9 +102,9 @@ func TestGetToken_Do(t *testing.T) { ClientSecret: "YOUR_CLIENT_SECRET", TokenCacheDir: "/path/to/token-cache", } - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{ + Do(ctx, authentication.Input{ OIDCConfig: kubeconfig.OIDCConfig{ IDPIssuerURL: "https://accounts.google.com", ClientID: "YOUR_CLIENT_ID", @@ -112,7 +112,7 @@ func TestGetToken_Do(t *testing.T) { IDToken: "VALID_ID_TOKEN", }, }). - Return(&auth.Output{ + Return(&authentication.Output{ AlreadyHasValidIDToken: true, IDToken: "VALID_ID_TOKEN", IDTokenExpiry: futureTime, @@ -154,9 +154,9 @@ func TestGetToken_Do(t *testing.T) { ClientSecret: "YOUR_CLIENT_SECRET", TokenCacheDir: "/path/to/token-cache", } - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{ + Do(ctx, authentication.Input{ OIDCConfig: kubeconfig.OIDCConfig{ IDPIssuerURL: "https://accounts.google.com", ClientID: "YOUR_CLIENT_ID", diff --git a/pkg/usecases/setup/setup.go b/pkg/usecases/setup/setup.go index eb427b1..ed704c2 100644 --- a/pkg/usecases/setup/setup.go +++ b/pkg/usecases/setup/setup.go @@ -6,7 +6,7 @@ import ( "github.com/google/wire" "github.com/int128/kubelogin/pkg/adaptors/logger" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" ) var Set = wire.NewSet( @@ -20,6 +20,6 @@ type Interface interface { } type Setup struct { - Authentication auth.Interface + Authentication authentication.Interface Logger logger.Interface } diff --git a/pkg/usecases/setup/stage2.go b/pkg/usecases/setup/stage2.go index da23a05..bebaf9b 100644 --- a/pkg/usecases/setup/stage2.go +++ b/pkg/usecases/setup/stage2.go @@ -7,7 +7,7 @@ import ( "text/template" "github.com/int128/kubelogin/pkg/adaptors/kubeconfig" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" "golang.org/x/xerrors" ) @@ -79,7 +79,7 @@ type Stage2Input struct { func (u *Setup) DoStage2(ctx context.Context, in Stage2Input) error { u.Logger.Printf(`## 2. Verify authentication`) - out, err := u.Authentication.Do(ctx, auth.Input{ + out, err := u.Authentication.Do(ctx, authentication.Input{ OIDCConfig: kubeconfig.OIDCConfig{ IDPIssuerURL: in.IssuerURL, ClientID: in.ClientID, diff --git a/pkg/usecases/setup/stage2_test.go b/pkg/usecases/setup/stage2_test.go index f34b45d..128a465 100644 --- a/pkg/usecases/setup/stage2_test.go +++ b/pkg/usecases/setup/stage2_test.go @@ -8,8 +8,8 @@ import ( "github.com/golang/mock/gomock" "github.com/int128/kubelogin/pkg/adaptors/kubeconfig" "github.com/int128/kubelogin/pkg/adaptors/logger/mock_logger" - "github.com/int128/kubelogin/pkg/usecases/auth" - "github.com/int128/kubelogin/pkg/usecases/auth/mock_auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" + "github.com/int128/kubelogin/pkg/usecases/authentication/mock_authentication" ) func TestSetup_DoStage2(t *testing.T) { @@ -28,9 +28,9 @@ func TestSetup_DoStage2(t *testing.T) { SkipTLSVerify: true, } - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{ + Do(ctx, authentication.Input{ OIDCConfig: kubeconfig.OIDCConfig{ IDPIssuerURL: "https://accounts.google.com", ClientID: "YOUR_CLIENT_ID", @@ -42,7 +42,7 @@ func TestSetup_DoStage2(t *testing.T) { CACertFilename: "/path/to/cert", SkipTLSVerify: true, }). - Return(&auth.Output{ + Return(&authentication.Output{ IDToken: "YOUR_ID_TOKEN", RefreshToken: "YOUR_REFRESH_TOKEN", IDTokenSubject: "YOUR_SUBJECT", diff --git a/pkg/usecases/standalone/standalone.go b/pkg/usecases/standalone/standalone.go index c0cc334..6884752 100644 --- a/pkg/usecases/standalone/standalone.go +++ b/pkg/usecases/standalone/standalone.go @@ -8,7 +8,7 @@ import ( "github.com/google/wire" "github.com/int128/kubelogin/pkg/adaptors/kubeconfig" "github.com/int128/kubelogin/pkg/adaptors/logger" - "github.com/int128/kubelogin/pkg/usecases/auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" "golang.org/x/xerrors" ) @@ -48,7 +48,7 @@ See https://github.com/int128/kubelogin for more. // Otherwise, update the kubeconfig. // type Standalone struct { - Authentication auth.Interface + Authentication authentication.Interface Kubeconfig kubeconfig.Interface Logger logger.Interface } @@ -67,7 +67,7 @@ func (u *Standalone) Do(ctx context.Context, in Input) error { u.Logger.V(1).Infof("using the authentication provider of the user %s", authProvider.UserName) u.Logger.V(1).Infof("a token will be written to %s", authProvider.LocationOfOrigin) - out, err := u.Authentication.Do(ctx, auth.Input{ + out, err := u.Authentication.Do(ctx, authentication.Input{ OIDCConfig: authProvider.OIDCConfig, SkipOpenBrowser: in.SkipOpenBrowser, BindAddress: in.BindAddress, diff --git a/pkg/usecases/standalone/standalone_test.go b/pkg/usecases/standalone/standalone_test.go index aa96bf8..04b1fed 100644 --- a/pkg/usecases/standalone/standalone_test.go +++ b/pkg/usecases/standalone/standalone_test.go @@ -9,8 +9,8 @@ import ( "github.com/int128/kubelogin/pkg/adaptors/kubeconfig" "github.com/int128/kubelogin/pkg/adaptors/kubeconfig/mock_kubeconfig" "github.com/int128/kubelogin/pkg/adaptors/logger/mock_logger" - "github.com/int128/kubelogin/pkg/usecases/auth" - "github.com/int128/kubelogin/pkg/usecases/auth/mock_auth" + "github.com/int128/kubelogin/pkg/usecases/authentication" + "github.com/int128/kubelogin/pkg/usecases/authentication/mock_authentication" "golang.org/x/xerrors" ) @@ -58,9 +58,9 @@ func TestStandalone_Do(t *testing.T) { RefreshToken: "YOUR_REFRESH_TOKEN", }, }) - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{ + Do(ctx, authentication.Input{ OIDCConfig: currentAuthProvider.OIDCConfig, BindAddress: []string{"127.0.0.1:8000"}, SkipOpenBrowser: true, @@ -69,7 +69,7 @@ func TestStandalone_Do(t *testing.T) { CACertFilename: "/path/to/cert", SkipTLSVerify: true, }). - Return(&auth.Output{ + Return(&authentication.Output{ IDToken: "YOUR_ID_TOKEN", RefreshToken: "YOUR_REFRESH_TOKEN", IDTokenExpiry: futureTime, @@ -103,10 +103,10 @@ func TestStandalone_Do(t *testing.T) { mockKubeconfig.EXPECT(). GetCurrentAuthProvider("", kubeconfig.ContextName(""), kubeconfig.UserName("")). Return(currentAuthProvider, nil) - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{OIDCConfig: currentAuthProvider.OIDCConfig}). - Return(&auth.Output{ + Do(ctx, authentication.Input{OIDCConfig: currentAuthProvider.OIDCConfig}). + Return(&authentication.Output{ AlreadyHasValidIDToken: true, IDToken: "VALID_ID_TOKEN", IDTokenExpiry: futureTime, @@ -131,7 +131,7 @@ func TestStandalone_Do(t *testing.T) { mockKubeconfig.EXPECT(). GetCurrentAuthProvider("", kubeconfig.ContextName(""), kubeconfig.UserName("")). Return(nil, xerrors.New("no oidc config")) - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) u := Standalone{ Authentication: mockAuthentication, Kubeconfig: mockKubeconfig, @@ -160,9 +160,9 @@ func TestStandalone_Do(t *testing.T) { mockKubeconfig.EXPECT(). GetCurrentAuthProvider("", kubeconfig.ContextName(""), kubeconfig.UserName("")). Return(currentAuthProvider, nil) - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{OIDCConfig: currentAuthProvider.OIDCConfig}). + Do(ctx, authentication.Input{OIDCConfig: currentAuthProvider.OIDCConfig}). Return(nil, xerrors.New("authentication error")) u := Standalone{ Authentication: mockAuthentication, @@ -205,10 +205,10 @@ func TestStandalone_Do(t *testing.T) { }, }). Return(xerrors.New("I/O error")) - mockAuthentication := mock_auth.NewMockInterface(ctrl) + mockAuthentication := mock_authentication.NewMockInterface(ctrl) mockAuthentication.EXPECT(). - Do(ctx, auth.Input{OIDCConfig: currentAuthProvider.OIDCConfig}). - Return(&auth.Output{ + Do(ctx, authentication.Input{OIDCConfig: currentAuthProvider.OIDCConfig}). + Return(&authentication.Output{ IDToken: "YOUR_ID_TOKEN", RefreshToken: "YOUR_REFRESH_TOKEN", IDTokenExpiry: futureTime,