From ae1e682c55e776f9bb7c0b365218461e584c5531 Mon Sep 17 00:00:00 2001 From: mazrean Date: Wed, 26 Oct 2022 03:55:51 +0900 Subject: [PATCH 1/4] =?UTF-8?q?config=E3=81=ABFeatureV1Write=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/app.go | 1 + src/config/v1/app.go | 15 +++++++++++++++ src/config/v1/env.go | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/config/app.go b/src/config/app.go index 184c7876..12253a1f 100644 --- a/src/config/app.go +++ b/src/config/app.go @@ -12,4 +12,5 @@ const ( type App interface { Status() (AppStatus, error) FeatureV2() bool + FeatureV1Write() bool } diff --git a/src/config/v1/app.go b/src/config/v1/app.go index fb0df9a2..8612bb3e 100644 --- a/src/config/v1/app.go +++ b/src/config/v1/app.go @@ -45,3 +45,18 @@ func (*App) FeatureV2() bool { return v2 } + +func (*App) FeatureV1Write() bool { + env, ok := os.LookupEnv(envKeyFeatureV1Write) + if !ok { + return true + } + + v2, err := strconv.ParseBool(env) + if err != nil { + log.Printf("failed to parse %s: %v\n", envKeyFeatureV2, err) + return true + } + + return v2 +} diff --git a/src/config/v1/env.go b/src/config/v1/env.go index 6605f54e..9c957116 100644 --- a/src/config/v1/env.go +++ b/src/config/v1/env.go @@ -3,8 +3,9 @@ package v1 type envKey = string const ( - envKeyCollectionEnv envKey = "COLLECTION_ENV" - envKeyFeatureV2 envKey = "FEATURE_V2" + envKeyCollectionEnv envKey = "COLLECTION_ENV" + envKeyFeatureV2 envKey = "FEATURE_V2" + envKeyFeatureV1Write envKey = "FEATURE_V1_WRITE" envKeyStorage envKey = "STORAGE" From c68f7cc69bdd1de649d25d1e73bbaf10334446d7 Mon Sep 17 00:00:00 2001 From: mazrean Date: Wed, 26 Oct 2022 03:56:43 +0900 Subject: [PATCH 2/4] =?UTF-8?q?v1=E3=81=AE=E6=9B=B8=E3=81=8D=E8=BE=BC?= =?UTF-8?q?=E3=81=BF=E7=B3=BBapi=E3=81=AB=E3=83=95=E3=83=A9=E3=82=B0?= =?UTF-8?q?=E5=9F=8B=E3=82=81=E8=BE=BC=E3=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handler/v1/game.go | 24 ++++++++++++++++++++---- src/handler/v1/game_file.go | 9 ++++++++- src/handler/v1/game_file_test.go | 7 +++++-- src/handler/v1/game_image.go | 9 ++++++++- src/handler/v1/game_image_test.go | 7 +++++-- src/handler/v1/game_role.go | 9 ++++++++- src/handler/v1/game_role_test.go | 6 ++++-- src/handler/v1/game_test.go | 15 ++++++++++----- src/handler/v1/game_url.go | 9 ++++++++- src/handler/v1/game_url_test.go | 7 +++++-- src/handler/v1/game_version.go | 9 ++++++++- src/handler/v1/game_version_test.go | 7 +++++-- src/handler/v1/game_video.go | 9 ++++++++- src/handler/v1/game_video_test.go | 7 +++++-- src/handler/v1/launcher_auth.go | 13 ++++++++++++- src/handler/v1/launcher_auth_test.go | 16 +++++++++++----- src/handler/v1/launcher_version.go | 13 ++++++++++++- src/handler/v1/launcher_version_test.go | 16 +++++++++++----- 18 files changed, 153 insertions(+), 39 deletions(-) diff --git a/src/handler/v1/game.go b/src/handler/v1/game.go index 71d197cc..22a79178 100644 --- a/src/handler/v1/game.go +++ b/src/handler/v1/game.go @@ -8,27 +8,35 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" "github.com/traPtitech/trap-collection-server/src/service" ) type Game struct { - session *Session - gameService service.Game + featureWrite bool + session *Session + gameService service.Game } func NewGame( + appConf config.App, session *Session, gameService service.Game, ) *Game { return &Game{ - session: session, - gameService: gameService, + featureWrite: appConf.FeatureV1Write(), + session: session, + gameService: gameService, } } func (g *Game) PostGame(c echo.Context, newGame *openapi.NewGame) (*openapi.GameInfo, error) { + if !g.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "write feature is disabled") + } + session, err := getSession(c) if err != nil { return nil, echo.NewHTTPError(http.StatusInternalServerError, "failed to get session") @@ -112,6 +120,10 @@ func (g *Game) GetGame(c echo.Context, strGameID string) (*openapi.Game, error) } func (g *Game) PutGame(c echo.Context, strGameID string, gameMeta *openapi.NewGame) (*openapi.GameInfo, error) { + if !g.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "write feature is disabled") + } + ctx := c.Request().Context() uuidGameID, err := uuid.Parse(strGameID) @@ -219,6 +231,10 @@ func (g *Game) GetGames(c echo.Context, strAll string) ([]*openapi.Game, error) } func (g *Game) DeleteGames(c echo.Context, strGameID string) error { + if !g.featureWrite { + return echo.NewHTTPError(http.StatusForbidden, "write feature is disabled") + } + ctx := c.Request().Context() uuidGameID, err := uuid.Parse(strGameID) diff --git a/src/handler/v1/game_file.go b/src/handler/v1/game_file.go index 8b5e9c6c..8888d8ce 100644 --- a/src/handler/v1/game_file.go +++ b/src/handler/v1/game_file.go @@ -11,22 +11,29 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" "github.com/traPtitech/trap-collection-server/src/service" ) type GameFile struct { + featureWrite bool gameFileService service.GameFile } -func NewGameFile(gameFileService service.GameFile) *GameFile { +func NewGameFile(appConf config.App, gameFileService service.GameFile) *GameFile { return &GameFile{ + featureWrite: appConf.FeatureV1Write(), gameFileService: gameFileService, } } func (gf *GameFile) PostFile(c echo.Context, strGameID string, strEntryPoint string, strFileType string, file multipart.File) (*openapi.GameFile, error) { + if !gf.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "v1 write is disabled") + } + ctx := c.Request().Context() uuidGameID, err := uuid.Parse(strGameID) diff --git a/src/handler/v1/game_file_test.go b/src/handler/v1/game_file_test.go index e99c8aaf..8a35a609 100644 --- a/src/handler/v1/game_file_test.go +++ b/src/handler/v1/game_file_test.go @@ -14,6 +14,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" + mockConfig "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" @@ -27,9 +28,10 @@ func TestPostFile(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameFileService := mock.NewMockGameFile(ctrl) - gameFileHandler := NewGameFile(mockGameFileService) + gameFileHandler := NewGameFile(mockAppConfig, mockGameFileService) type test struct { description string @@ -256,9 +258,10 @@ func TestGetGameFile(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameFileService := mock.NewMockGameFile(ctrl) - gameFileHandler := NewGameFile(mockGameFileService) + gameFileHandler := NewGameFile(mockAppConfig, mockGameFileService) type test struct { description string diff --git a/src/handler/v1/game_image.go b/src/handler/v1/game_image.go index 31095c80..4610b8eb 100644 --- a/src/handler/v1/game_image.go +++ b/src/handler/v1/game_image.go @@ -10,21 +10,28 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/service" ) type GameImage struct { + featureWrite bool gameImageService service.GameImage } -func NewGameImage(gameImageService service.GameImage) *GameImage { +func NewGameImage(appConf config.App, gameImageService service.GameImage) *GameImage { return &GameImage{ + featureWrite: appConf.FeatureV1Write(), gameImageService: gameImageService, } } func (gi *GameImage) PostImage(c echo.Context, strGameID string, image multipart.File) error { + if !gi.featureWrite { + return echo.NewHTTPError(http.StatusForbidden, "v1 write is disabled") + } + ctx := c.Request().Context() uuidGameID, err := uuid.Parse(strGameID) diff --git a/src/handler/v1/game_image_test.go b/src/handler/v1/game_image_test.go index 819e0df9..49b824e8 100644 --- a/src/handler/v1/game_image_test.go +++ b/src/handler/v1/game_image_test.go @@ -13,6 +13,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" + mockConf "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/service" "github.com/traPtitech/trap-collection-server/src/service/mock" @@ -24,9 +25,10 @@ func TestPostImage(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConf.NewMockApp(ctrl) mockGameImageService := mock.NewMockGameImage(ctrl) - gameImageHandler := NewGameImage(mockGameImageService) + gameImageHandler := NewGameImage(mockAppConfig, mockGameImageService) type test struct { description string @@ -136,9 +138,10 @@ func TestGetImage(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConf.NewMockApp(ctrl) mockGameImageService := mock.NewMockGameImage(ctrl) - gameImageHandler := NewGameImage(mockGameImageService) + gameImageHandler := NewGameImage(mockAppConfig, mockGameImageService) type test struct { description string diff --git a/src/handler/v1/game_role.go b/src/handler/v1/game_role.go index 2f00a2a3..f0cac207 100644 --- a/src/handler/v1/game_role.go +++ b/src/handler/v1/game_role.go @@ -7,24 +7,31 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" "github.com/traPtitech/trap-collection-server/src/service" ) type GameRole struct { + featureWrite bool session *Session gameAuthService service.GameAuth } -func NewGameRole(session *Session, gameAuthService service.GameAuth) *GameRole { +func NewGameRole(appConf config.App, session *Session, gameAuthService service.GameAuth) *GameRole { return &GameRole{ + featureWrite: appConf.FeatureV1Write(), session: session, gameAuthService: gameAuthService, } } func (gr *GameRole) PostMaintainer(c echo.Context, strGameID string, maintainers *openapi.Maintainers) error { + if !gr.featureWrite { + return echo.NewHTTPError(http.StatusForbidden, "write is disabled") + } + session, err := getSession(c) if err != nil { log.Printf("error: failed to get session: %v\n", err) diff --git a/src/handler/v1/game_role_test.go b/src/handler/v1/game_role_test.go index c0ec76ed..e61fc9eb 100644 --- a/src/handler/v1/game_role_test.go +++ b/src/handler/v1/game_role_test.go @@ -26,6 +26,7 @@ func TestPostMaintainer(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameAuthService := mock.NewMockGameAuth(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. @@ -47,7 +48,7 @@ func TestPostMaintainer(t *testing.T) { return } - gameRoleHandler := NewGameRole(session, mockGameAuthService) + gameRoleHandler := NewGameRole(mockAppConfig, session, mockGameAuthService) type test struct { description string @@ -270,6 +271,7 @@ func TestGetMaintainer(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameAuthService := mock.NewMockGameAuth(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. @@ -291,7 +293,7 @@ func TestGetMaintainer(t *testing.T) { return } - gameRoleHandler := NewGameRole(session, mockGameAuthService) + gameRoleHandler := NewGameRole(mockAppConfig, session, mockGameAuthService) type test struct { description string diff --git a/src/handler/v1/game_test.go b/src/handler/v1/game_test.go index 0712644e..0cb9c2ee 100644 --- a/src/handler/v1/game_test.go +++ b/src/handler/v1/game_test.go @@ -27,6 +27,7 @@ func TestPostGame(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -48,7 +49,7 @@ func TestPostGame(t *testing.T) { } mockGameService := mock.NewMockGame(ctrl) - gameHandler := NewGame(session, mockGameService) + gameHandler := NewGame(mockAppConfig, session, mockGameService) type test struct { description string @@ -250,6 +251,7 @@ func TestGetGame(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -271,7 +273,7 @@ func TestGetGame(t *testing.T) { } mockGameService := mock.NewMockGame(ctrl) - gameHandler := NewGame(session, mockGameService) + gameHandler := NewGame(mockAppConfig, session, mockGameService) type test struct { description string @@ -412,6 +414,7 @@ func TestPutGame(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -433,7 +436,7 @@ func TestPutGame(t *testing.T) { } mockGameService := mock.NewMockGame(ctrl) - gameHandler := NewGame(session, mockGameService) + gameHandler := NewGame(mockAppConfig, session, mockGameService) type test struct { description string @@ -594,6 +597,7 @@ func TestGetGames(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -615,7 +619,7 @@ func TestGetGames(t *testing.T) { } mockGameService := mock.NewMockGame(ctrl) - gameHandler := NewGame(session, mockGameService) + gameHandler := NewGame(mockAppConfig, session, mockGameService) type test struct { description string @@ -1093,6 +1097,7 @@ func TestDeleteGames(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -1114,7 +1119,7 @@ func TestDeleteGames(t *testing.T) { } mockGameService := mock.NewMockGame(ctrl) - gameHandler := NewGame(session, mockGameService) + gameHandler := NewGame(mockAppConfig, session, mockGameService) type test struct { description string diff --git a/src/handler/v1/game_url.go b/src/handler/v1/game_url.go index f3f09794..1952fada 100644 --- a/src/handler/v1/game_url.go +++ b/src/handler/v1/game_url.go @@ -7,22 +7,29 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" "github.com/traPtitech/trap-collection-server/src/service" ) type GameURL struct { + featureWrite bool gameURLService service.GameURL } -func NewGameURL(gameURLService service.GameURL) *GameURL { +func NewGameURL(appConf config.App, gameURLService service.GameURL) *GameURL { return &GameURL{ + featureWrite: appConf.FeatureV1Write(), gameURLService: gameURLService, } } func (gu *GameURL) PostURL(c echo.Context, strGameID string, newGameURL *openapi.NewGameUrl) (*openapi.GameUrl, error) { + if !gu.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "v1 write is disabled") + } + ctx := c.Request().Context() uuidGameID, err := uuid.Parse(strGameID) diff --git a/src/handler/v1/game_url_test.go b/src/handler/v1/game_url_test.go index 5edd7bcc..7f0b64f2 100644 --- a/src/handler/v1/game_url_test.go +++ b/src/handler/v1/game_url_test.go @@ -13,6 +13,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" + mockConfig "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" @@ -26,9 +27,10 @@ func TestPostURL(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameURLService := mock.NewMockGameURL(ctrl) - gameURLHandler := NewGameURL(mockGameURLService) + gameURLHandler := NewGameURL(mockAppConfig, mockGameURLService) type test struct { description string @@ -175,9 +177,10 @@ func TestGetGameURL(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameURLService := mock.NewMockGameURL(ctrl) - gameURLHandler := NewGameURL(mockGameURLService) + gameURLHandler := NewGameURL(mockAppConfig, mockGameURLService) type test struct { description string diff --git a/src/handler/v1/game_version.go b/src/handler/v1/game_version.go index f82aed1e..4f6eba7f 100644 --- a/src/handler/v1/game_version.go +++ b/src/handler/v1/game_version.go @@ -8,22 +8,29 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" "github.com/traPtitech/trap-collection-server/src/service" ) type GameVersion struct { + featureWrite bool gameVersionService service.GameVersion } -func NewGameVersion(gameVersionService service.GameVersion) *GameVersion { +func NewGameVersion(appConf config.App, gameVersionService service.GameVersion) *GameVersion { return &GameVersion{ + featureWrite: appConf.FeatureV1Write(), gameVersionService: gameVersionService, } } func (gv *GameVersion) PostGameVersion(c echo.Context, strGameID string, newGameVersion *openapi.NewGameVersion) (*openapi.GameVersion, error) { + if !gv.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "v1 write is disabled") + } + ctx := c.Request().Context() uuidGameID, err := uuid.Parse(strGameID) diff --git a/src/handler/v1/game_version_test.go b/src/handler/v1/game_version_test.go index 0a997e48..0f7b5862 100644 --- a/src/handler/v1/game_version_test.go +++ b/src/handler/v1/game_version_test.go @@ -12,6 +12,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" + mockConfig "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" @@ -25,9 +26,10 @@ func TestPostGameVersion(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameVersionService := mock.NewMockGameVersion(ctrl) - gameVersionHandler := NewGameVersion(mockGameVersionService) + gameVersionHandler := NewGameVersion(mockAppConfig, mockGameVersionService) type test struct { description string @@ -224,9 +226,10 @@ func TestGetGameVersion(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockGameVersionService := mock.NewMockGameVersion(ctrl) - gameVersionHandler := NewGameVersion(mockGameVersionService) + gameVersionHandler := NewGameVersion(mockAppConfig, mockGameVersionService) type test struct { description string diff --git a/src/handler/v1/game_video.go b/src/handler/v1/game_video.go index 27f55ec3..ce5fa71c 100644 --- a/src/handler/v1/game_video.go +++ b/src/handler/v1/game_video.go @@ -10,21 +10,28 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/service" ) type GameVideo struct { + featureWrite bool gameVideoService service.GameVideo } -func NewGameVideo(gameVideoService service.GameVideo) *GameVideo { +func NewGameVideo(appConf config.App, gameVideoService service.GameVideo) *GameVideo { return &GameVideo{ + featureWrite: appConf.FeatureV1Write(), gameVideoService: gameVideoService, } } func (gv *GameVideo) PostVideo(c echo.Context, strGameID string, video multipart.File) error { + if !gv.featureWrite { + return echo.NewHTTPError(http.StatusForbidden, "v1 write is disabled") + } + ctx := c.Request().Context() uuidGameID, err := uuid.Parse(strGameID) diff --git a/src/handler/v1/game_video_test.go b/src/handler/v1/game_video_test.go index cf16b741..b056f5e0 100644 --- a/src/handler/v1/game_video_test.go +++ b/src/handler/v1/game_video_test.go @@ -13,6 +13,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" + mockConf "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/service" "github.com/traPtitech/trap-collection-server/src/service/mock" @@ -24,9 +25,10 @@ func TestPostVideo(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConf.NewMockApp(ctrl) mockGameVideoService := mock.NewMockGameVideo(ctrl) - gameVideoHandler := NewGameVideo(mockGameVideoService) + gameVideoHandler := NewGameVideo(mockAppConfig, mockGameVideoService) type test struct { description string @@ -136,9 +138,10 @@ func TestGetVideo(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConf.NewMockApp(ctrl) mockGameVideoService := mock.NewMockGameVideo(ctrl) - gameVideoHandler := NewGameVideo(mockGameVideoService) + gameVideoHandler := NewGameVideo(mockAppConfig, mockGameVideoService) type test struct { description string diff --git a/src/handler/v1/launcher_auth.go b/src/handler/v1/launcher_auth.go index edee7e14..66dd62ba 100644 --- a/src/handler/v1/launcher_auth.go +++ b/src/handler/v1/launcher_auth.go @@ -9,6 +9,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" @@ -16,16 +17,22 @@ import ( ) type LauncherAuth struct { + featureWrite bool launcherAuthService service.LauncherAuth } -func NewLauncherAuth(launcherAuthService service.LauncherAuth) *LauncherAuth { +func NewLauncherAuth(appConf config.App, launcherAuthService service.LauncherAuth) *LauncherAuth { return &LauncherAuth{ + featureWrite: appConf.FeatureV1Write(), launcherAuthService: launcherAuthService, } } func (la *LauncherAuth) PostKeyGenerate(c echo.Context, productKeyGen *openapi.ProductKeyGen) ([]*openapi.ProductKey, error) { + if !la.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "write feature is disabled") + } + ctx := c.Request().Context() keyNum := int(productKeyGen.Num) @@ -83,6 +90,10 @@ func (la *LauncherAuth) PostLauncherLogin(c echo.Context, productKey *openapi.Pr } func (la *LauncherAuth) DeleteProductKey(c echo.Context, productKeyID string) error { + if !la.featureWrite { + return echo.NewHTTPError(http.StatusForbidden, "write feature is disabled") + } + ctx := c.Request().Context() uuidLauncherUserID, err := uuid.Parse(productKeyID) diff --git a/src/handler/v1/launcher_auth_test.go b/src/handler/v1/launcher_auth_test.go index 1b03464a..98776dba 100644 --- a/src/handler/v1/launcher_auth_test.go +++ b/src/handler/v1/launcher_auth_test.go @@ -14,6 +14,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" + mockConfig "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" @@ -29,9 +30,10 @@ func TestPostKeyGenerate(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) - launcherAuthHandler := NewLauncherAuth(mockLauncherAuthService) + launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) type test struct { description string @@ -220,9 +222,10 @@ func TestPostLauncherLogin(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) - launcherAuthHandler := NewLauncherAuth(mockLauncherAuthService) + launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) type test struct { description string @@ -351,9 +354,10 @@ func TestDeleteProductKey(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) - launcherAuthHandler := NewLauncherAuth(mockLauncherAuthService) + launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) type test struct { description string @@ -451,9 +455,10 @@ func TestGetProductKeys(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) - launcherAuthHandler := NewLauncherAuth(mockLauncherAuthService) + launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) type test struct { description string @@ -615,9 +620,10 @@ func TestGetLauncherMe(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) - launcherAuthHandler := NewLauncherAuth(mockLauncherAuthService) + launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) type test struct { description string diff --git a/src/handler/v1/launcher_version.go b/src/handler/v1/launcher_version.go index 290d7fb3..76a00cc0 100644 --- a/src/handler/v1/launcher_version.go +++ b/src/handler/v1/launcher_version.go @@ -11,6 +11,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" + "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" @@ -18,11 +19,13 @@ import ( ) type LauncherVersion struct { + featureWrite bool launcherVersionService service.LauncherVersion } -func NewLauncherVersion(launcherVersionService service.LauncherVersion) *LauncherVersion { +func NewLauncherVersion(appConf config.App, launcherVersionService service.LauncherVersion) *LauncherVersion { return &LauncherVersion{ + featureWrite: appConf.FeatureV1Write(), launcherVersionService: launcherVersionService, } } @@ -61,6 +64,10 @@ func (lv *LauncherVersion) GetVersions(c echo.Context) ([]*openapi.Version, erro } func (lv *LauncherVersion) PostVersion(c echo.Context, newVersion *openapi.NewVersion) (*openapi.VersionMeta, error) { + if !lv.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "write feature is disabled") + } + ctx := c.Request().Context() name := values.NewLauncherVersionName(newVersion.Name) @@ -160,6 +167,10 @@ func (lv *LauncherVersion) GetVersion(c echo.Context, strLauncherVersionID strin } func (lv *LauncherVersion) PostGameToVersion(c echo.Context, strLauncherVersionID string, apiGameIDs *openapi.GameIDs) (*openapi.VersionDetails, error) { + if !lv.featureWrite { + return nil, echo.NewHTTPError(http.StatusForbidden, "write feature is disabled") + } + ctx := c.Request().Context() uuidLauncherVersionID, err := uuid.Parse(strLauncherVersionID) diff --git a/src/handler/v1/launcher_version_test.go b/src/handler/v1/launcher_version_test.go index 865d27de..2bc85851 100644 --- a/src/handler/v1/launcher_version_test.go +++ b/src/handler/v1/launcher_version_test.go @@ -13,6 +13,7 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" + mockConfig "github.com/traPtitech/trap-collection-server/src/config/mock" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" @@ -26,9 +27,10 @@ func TestGetVersions(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) - launcherVersionHandler := NewLauncherVersion(mockLauncherVersionService) + launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) type test struct { description string @@ -179,9 +181,10 @@ func TestPostVersion(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) - launcherVersionHandler := NewLauncherVersion(mockLauncherVersionService) + launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) type test struct { description string @@ -331,9 +334,10 @@ func TestGetVersion(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) - launcherVersionHandler := NewLauncherVersion(mockLauncherVersionService) + launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) type test struct { description string @@ -567,9 +571,10 @@ func TestPostGameToVersion(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) - launcherVersionHandler := NewLauncherVersion(mockLauncherVersionService) + launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) type test struct { description string @@ -836,9 +841,10 @@ func TestGetCheckList(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() + mockAppConfig := mockConfig.NewMockApp(ctrl) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) - launcherVersionHandler := NewLauncherVersion(mockLauncherVersionService) + launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) type test struct { description string From e027a80edfd76bd6f60d4e26232605709f4c2eee Mon Sep 17 00:00:00 2001 From: mazrean Date: Wed, 26 Oct 2022 03:56:50 +0900 Subject: [PATCH 3/4] =?UTF-8?q?wire=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wire/wire_gen.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/wire/wire_gen.go b/src/wire/wire_gen.go index 4853c723..b97de756 100644 --- a/src/wire/wire_gen.go +++ b/src/wire/wire_gen.go @@ -137,8 +137,8 @@ func InjectApp() (*App, error) { user2 := v1_2.NewUser(v1Session, v1User) gameVersion := gorm2.NewGameVersion(db) v1Game := v1_3.NewGame(db, game, gameVersion, gameManagementRole, userUtils) - game2 := v1_2.NewGame(v1Session, v1Game) - gameRole := v1_2.NewGameRole(v1Session, gameAuth) + game2 := v1_2.NewGame(app, v1Session, v1Game) + gameRole := v1_2.NewGameRole(app, v1Session, gameAuth) gameImage := gorm2.NewGameImage(db) storage := v1.NewStorage() storageSwift := v1.NewStorageSwift() @@ -150,23 +150,23 @@ func InjectApp() (*App, error) { } storageGameImage := wireStorage.GameImage v1GameImage := v1_3.NewGameImage(db, game, gameImage, storageGameImage) - gameImage2 := v1_2.NewGameImage(v1GameImage) + gameImage2 := v1_2.NewGameImage(app, v1GameImage) gameVideo := gorm2.NewGameVideo(db) storageGameVideo := wireStorage.GameVideo v1GameVideo := v1_3.NewGameVideo(db, game, gameVideo, storageGameVideo) - gameVideo2 := v1_2.NewGameVideo(v1GameVideo) + gameVideo2 := v1_2.NewGameVideo(app, v1GameVideo) v1GameVersion := v1_3.NewGameVersion(db, game, gameVersion) - gameVersion2 := v1_2.NewGameVersion(v1GameVersion) + gameVersion2 := v1_2.NewGameVersion(app, v1GameVersion) gameFile := gorm2.NewGameFile(db) storageGameFile := wireStorage.GameFile v1GameFile := v1_3.NewGameFile(db, game, gameVersion, gameFile, storageGameFile) - gameFile2 := v1_2.NewGameFile(v1GameFile) + gameFile2 := v1_2.NewGameFile(app, v1GameFile) gameURL := gorm2.NewGameURL(db) v1GameURL := v1_3.NewGameURL(db, game, gameVersion, gameURL) - gameURL2 := v1_2.NewGameURL(v1GameURL) - v1LauncherAuth := v1_2.NewLauncherAuth(launcherAuth) + gameURL2 := v1_2.NewGameURL(app, v1GameURL) + v1LauncherAuth := v1_2.NewLauncherAuth(app, launcherAuth) v1LauncherVersion := v1_3.NewLauncherVersion(db, launcherVersion, game) - launcherVersion2 := v1_2.NewLauncherVersion(v1LauncherVersion) + launcherVersion2 := v1_2.NewLauncherVersion(app, v1LauncherVersion) oAuth2, err := v1_2.NewOAuth2(v1Handler, v1Session, v1OIDC) if err != nil { return nil, err From c6330511ba97592c3d649d65a502e9ff29d002f2 Mon Sep 17 00:00:00 2001 From: mazrean Date: Wed, 26 Oct 2022 04:09:36 +0900 Subject: [PATCH 4/4] default on --- src/handler/v1/game_file_test.go | 8 ++++++++ src/handler/v1/game_image_test.go | 8 ++++++++ src/handler/v1/game_role_test.go | 8 ++++++++ src/handler/v1/game_test.go | 20 ++++++++++++++++++++ src/handler/v1/game_url_test.go | 8 ++++++++ src/handler/v1/game_version_test.go | 8 ++++++++ src/handler/v1/game_video_test.go | 8 ++++++++ src/handler/v1/launcher_auth_test.go | 20 ++++++++++++++++++++ src/handler/v1/launcher_version_test.go | 20 ++++++++++++++++++++ 9 files changed, 108 insertions(+) diff --git a/src/handler/v1/game_file_test.go b/src/handler/v1/game_file_test.go index 8a35a609..13208e81 100644 --- a/src/handler/v1/game_file_test.go +++ b/src/handler/v1/game_file_test.go @@ -29,6 +29,10 @@ func TestPostFile(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameFileService := mock.NewMockGameFile(ctrl) gameFileHandler := NewGameFile(mockAppConfig, mockGameFileService) @@ -259,6 +263,10 @@ func TestGetGameFile(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameFileService := mock.NewMockGameFile(ctrl) gameFileHandler := NewGameFile(mockAppConfig, mockGameFileService) diff --git a/src/handler/v1/game_image_test.go b/src/handler/v1/game_image_test.go index 49b824e8..679fe089 100644 --- a/src/handler/v1/game_image_test.go +++ b/src/handler/v1/game_image_test.go @@ -26,6 +26,10 @@ func TestPostImage(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConf.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameImageService := mock.NewMockGameImage(ctrl) gameImageHandler := NewGameImage(mockAppConfig, mockGameImageService) @@ -139,6 +143,10 @@ func TestGetImage(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConf.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameImageService := mock.NewMockGameImage(ctrl) gameImageHandler := NewGameImage(mockAppConfig, mockGameImageService) diff --git a/src/handler/v1/game_role_test.go b/src/handler/v1/game_role_test.go index e61fc9eb..1c1ace36 100644 --- a/src/handler/v1/game_role_test.go +++ b/src/handler/v1/game_role_test.go @@ -27,6 +27,10 @@ func TestPostMaintainer(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameAuthService := mock.NewMockGameAuth(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. @@ -272,6 +276,10 @@ func TestGetMaintainer(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameAuthService := mock.NewMockGameAuth(ctrl) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. diff --git a/src/handler/v1/game_test.go b/src/handler/v1/game_test.go index 0cb9c2ee..c0510a35 100644 --- a/src/handler/v1/game_test.go +++ b/src/handler/v1/game_test.go @@ -28,6 +28,10 @@ func TestPostGame(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -252,6 +256,10 @@ func TestGetGame(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -415,6 +423,10 @@ func TestPutGame(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -598,6 +610,10 @@ func TestGetGames(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). @@ -1098,6 +1114,10 @@ func TestDeleteGames(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockConf := mockConfig.NewMockHandler(ctrl) mockConf. EXPECT(). diff --git a/src/handler/v1/game_url_test.go b/src/handler/v1/game_url_test.go index 7f0b64f2..563ea94e 100644 --- a/src/handler/v1/game_url_test.go +++ b/src/handler/v1/game_url_test.go @@ -28,6 +28,10 @@ func TestPostURL(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameURLService := mock.NewMockGameURL(ctrl) gameURLHandler := NewGameURL(mockAppConfig, mockGameURLService) @@ -178,6 +182,10 @@ func TestGetGameURL(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameURLService := mock.NewMockGameURL(ctrl) gameURLHandler := NewGameURL(mockAppConfig, mockGameURLService) diff --git a/src/handler/v1/game_version_test.go b/src/handler/v1/game_version_test.go index 0f7b5862..596b8562 100644 --- a/src/handler/v1/game_version_test.go +++ b/src/handler/v1/game_version_test.go @@ -27,6 +27,10 @@ func TestPostGameVersion(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameVersionService := mock.NewMockGameVersion(ctrl) gameVersionHandler := NewGameVersion(mockAppConfig, mockGameVersionService) @@ -227,6 +231,10 @@ func TestGetGameVersion(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameVersionService := mock.NewMockGameVersion(ctrl) gameVersionHandler := NewGameVersion(mockAppConfig, mockGameVersionService) diff --git a/src/handler/v1/game_video_test.go b/src/handler/v1/game_video_test.go index b056f5e0..1d29346d 100644 --- a/src/handler/v1/game_video_test.go +++ b/src/handler/v1/game_video_test.go @@ -26,6 +26,10 @@ func TestPostVideo(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConf.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameVideoService := mock.NewMockGameVideo(ctrl) gameVideoHandler := NewGameVideo(mockAppConfig, mockGameVideoService) @@ -139,6 +143,10 @@ func TestGetVideo(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConf.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockGameVideoService := mock.NewMockGameVideo(ctrl) gameVideoHandler := NewGameVideo(mockAppConfig, mockGameVideoService) diff --git a/src/handler/v1/launcher_auth_test.go b/src/handler/v1/launcher_auth_test.go index 98776dba..b6e0db79 100644 --- a/src/handler/v1/launcher_auth_test.go +++ b/src/handler/v1/launcher_auth_test.go @@ -31,6 +31,10 @@ func TestPostKeyGenerate(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) @@ -223,6 +227,10 @@ func TestPostLauncherLogin(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) @@ -355,6 +363,10 @@ func TestDeleteProductKey(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) @@ -456,6 +468,10 @@ func TestGetProductKeys(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) @@ -621,6 +637,10 @@ func TestGetLauncherMe(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherAuthService := mock.NewMockLauncherAuth(ctrl) launcherAuthHandler := NewLauncherAuth(mockAppConfig, mockLauncherAuthService) diff --git a/src/handler/v1/launcher_version_test.go b/src/handler/v1/launcher_version_test.go index 2bc85851..375eb580 100644 --- a/src/handler/v1/launcher_version_test.go +++ b/src/handler/v1/launcher_version_test.go @@ -28,6 +28,10 @@ func TestGetVersions(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) @@ -182,6 +186,10 @@ func TestPostVersion(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) @@ -335,6 +343,10 @@ func TestGetVersion(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) @@ -572,6 +584,10 @@ func TestPostGameToVersion(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService) @@ -842,6 +858,10 @@ func TestGetCheckList(t *testing.T) { defer ctrl.Finish() mockAppConfig := mockConfig.NewMockApp(ctrl) + mockAppConfig. + EXPECT(). + FeatureV1Write(). + Return(true) mockLauncherVersionService := mock.NewMockLauncherVersion(ctrl) launcherVersionHandler := NewLauncherVersion(mockAppConfig, mockLauncherVersionService)