[MM-60280] api4/license.go: add err check to JSON unmarshal (#28063)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2024-08-29 15:24:55 +02:00
коммит произвёл GitHub
родитель d5cc2eb2f6
Коммит 6235f6cb77
2 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@@ -386,6 +386,18 @@ func TestRequestTrialLicense(t *testing.T) {
CheckForbiddenStatus(t, resp)
})
t.Run("trial license invalid JSON", func(t *testing.T) {
// the JSON is invalid because it is missing a closing brace
licenseManagerMock := &mocks.LicenseInterface{}
licenseManagerMock.On("CanStartTrial").Return(true, nil).Once()
th.App.Srv().Platform().SetLicenseManager(licenseManagerMock)
resp, err := th.SystemAdminClient.DoAPIPost(context.Background(), "/trial-license", `{"users": 5`)
CheckErrorID(t, err, "api.license.request-trial.bad-request")
CheckBadRequestStatus(t, model.BuildResponse(resp))
})
t.Run("trial license user count less than current users", func(t *testing.T) {
nUsers := 1
license := model.NewTestLicense()