[MM-54024] Handle JSON nulls when unmarshalling in api4 (#24656)

* handle JSON nulls when unmarshalling in api4

* catch more cases of unhandled JSON null

* fix lint issues

* remove unnecessary checks

* add bot tests for null values

* fix bot_test lint

* add channel null tests

* add group null tests

* add notify_admin null tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Delaney Sylvans
2023-10-05 14:55:59 +01:00
коммит произвёл GitHub
родитель 5b25519890
Коммит d61364a24a
14 изменённых файлов: 130 добавлений и 29 удалений

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

@@ -80,6 +80,10 @@ func TestCreateGroup(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional, "ldap"))
_, resp, err := th.SystemAdminClient.CreateGroup(context.Background(), nil)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
group, _, err := th.SystemAdminClient.CreateGroup(context.Background(), g)
require.NoError(t, err)
@@ -1582,6 +1586,11 @@ func TestAddMembersToGroup(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
//Empty group members returns bad request
_, resp, nullErr := th.SystemAdminClient.UpsertGroupMembers(context.Background(), group.Id, nil)
require.Error(t, nullErr)
CheckBadRequestStatus(t, resp)
groupMembers, response, upsertErr := th.SystemAdminClient.UpsertGroupMembers(context.Background(), group.Id, members)
require.NoError(t, upsertErr)
CheckOKStatus(t, response)
@@ -1654,6 +1663,10 @@ func TestDeleteMembersFromGroup(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
_, resp, nullErr := th.SystemAdminClient.DeleteGroupMembers(context.Background(), group.Id, nil)
require.Error(t, nullErr)
CheckBadRequestStatus(t, resp)
groupMembers, response, deleteErr := th.SystemAdminClient.DeleteGroupMembers(context.Background(), group.Id, members)
require.NoError(t, deleteErr)
CheckOKStatus(t, response)