Skip to content

Commit ef1044c

Browse files
authored
Merge pull request #1257 from traPtitech/bug/negative_product_keys_count
🐛 プロダクトキーの数が負のとき400を返すように修正
2 parents 95e5a1b + 6e42881 commit ef1044c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/handler/v2/edition_auth.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (editionAuth *EditionAuth) GetProductKeys(c echo.Context, editionID openapi
8585
// プロダクトキーの生成
8686
// (POST /editions/{editionID}/keys)
8787
func (editionAuth *EditionAuth) PostProductKey(c echo.Context, editionID openapi.EditionIDInPath, params openapi.PostProductKeyParams) error {
88+
if params.Num < 0 {
89+
return echo.NewHTTPError(http.StatusBadRequest, "invalid key num")
90+
}
91+
8892
productKey, err := editionAuth.editionAuthService.GenerateProductKey(
8993
c.Request().Context(),
9094
values.NewLauncherVersionIDFromUUID(editionID),

src/handler/v2/edition_auth_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ func TestPostProductKey(t *testing.T) {
281281
isErr: true,
282282
statusCode: http.StatusInternalServerError,
283283
},
284+
"Numが負なので400": {
285+
editionID: editionID,
286+
params: openapi.PostProductKeyParams{Num: -1},
287+
isErr: true,
288+
statusCode: http.StatusBadRequest,
289+
},
284290
}
285291

286292
for name, testCase := range testCases {

0 commit comments

Comments
 (0)