github.com/mad-app/mattermost-server@v5.11.1+incompatible/api4/group_test.go (about) 1 // Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package api4 5 6 import ( 7 "fmt" 8 "net/http" 9 "testing" 10 11 "github.com/stretchr/testify/assert" 12 13 "github.com/mattermost/mattermost-server/model" 14 ) 15 16 func TestGetGroup(t *testing.T) { 17 th := Setup().InitBasic() 18 defer th.TearDown() 19 20 id := model.NewId() 21 g, err := th.App.CreateGroup(&model.Group{ 22 DisplayName: "dn_" + id, 23 Name: "name" + id, 24 Source: model.GroupSourceLdap, 25 Description: "description_" + id, 26 RemoteId: model.NewId(), 27 }) 28 assert.Nil(t, err) 29 30 _, response := th.Client.GetGroup(g.Id, "") 31 CheckNotImplementedStatus(t, response) 32 33 _, response = th.SystemAdminClient.GetGroup(g.Id, "") 34 CheckNotImplementedStatus(t, response) 35 36 th.App.SetLicense(model.NewTestLicense("ldap")) 37 38 group, response := th.SystemAdminClient.GetGroup(g.Id, "") 39 CheckNoError(t, response) 40 41 assert.Equal(t, g.DisplayName, group.DisplayName) 42 assert.Equal(t, g.Name, group.Name) 43 assert.Equal(t, g.Source, group.Source) 44 assert.Equal(t, g.Description, group.Description) 45 assert.Equal(t, g.RemoteId, group.RemoteId) 46 assert.Equal(t, g.CreateAt, group.CreateAt) 47 assert.Equal(t, g.UpdateAt, group.UpdateAt) 48 assert.Equal(t, g.DeleteAt, group.DeleteAt) 49 50 _, response = th.SystemAdminClient.GetGroup(model.NewId(), "") 51 CheckNotFoundStatus(t, response) 52 53 _, response = th.SystemAdminClient.GetGroup("12345", "") 54 CheckBadRequestStatus(t, response) 55 56 th.SystemAdminClient.Logout() 57 _, response = th.SystemAdminClient.GetGroup(group.Id, "") 58 CheckUnauthorizedStatus(t, response) 59 } 60 61 func TestPatchGroup(t *testing.T) { 62 th := Setup().InitBasic() 63 defer th.TearDown() 64 65 id := model.NewId() 66 g, err := th.App.CreateGroup(&model.Group{ 67 DisplayName: "dn_" + id, 68 Name: "name" + id, 69 Source: model.GroupSourceLdap, 70 Description: "description_" + id, 71 RemoteId: model.NewId(), 72 }) 73 assert.Nil(t, err) 74 75 updateFmt := "%s_updated" 76 77 newName := fmt.Sprintf(updateFmt, g.Name) 78 newDisplayName := fmt.Sprintf(updateFmt, g.DisplayName) 79 newDescription := fmt.Sprintf(updateFmt, g.Description) 80 81 gp := &model.GroupPatch{ 82 Name: &newName, 83 DisplayName: &newDisplayName, 84 Description: &newDescription, 85 } 86 87 _, response := th.Client.PatchGroup(g.Id, gp) 88 CheckNotImplementedStatus(t, response) 89 90 _, response = th.SystemAdminClient.PatchGroup(g.Id, gp) 91 CheckNotImplementedStatus(t, response) 92 93 th.App.SetLicense(model.NewTestLicense("ldap")) 94 95 group2, response := th.SystemAdminClient.PatchGroup(g.Id, gp) 96 CheckOKStatus(t, response) 97 98 group, response := th.SystemAdminClient.GetGroup(g.Id, "") 99 CheckNoError(t, response) 100 101 assert.Equal(t, *gp.DisplayName, group.DisplayName) 102 assert.Equal(t, *gp.DisplayName, group2.DisplayName) 103 assert.Equal(t, *gp.Name, group.Name) 104 assert.Equal(t, *gp.Name, group2.Name) 105 assert.Equal(t, *gp.Description, group.Description) 106 assert.Equal(t, *gp.Description, group2.Description) 107 108 assert.Equal(t, group2.UpdateAt, group.UpdateAt) 109 110 assert.Equal(t, g.Source, group.Source) 111 assert.Equal(t, g.Source, group2.Source) 112 assert.Equal(t, g.RemoteId, group.RemoteId) 113 assert.Equal(t, g.RemoteId, group2.RemoteId) 114 assert.Equal(t, g.CreateAt, group.CreateAt) 115 assert.Equal(t, g.CreateAt, group2.CreateAt) 116 assert.Equal(t, g.DeleteAt, group.DeleteAt) 117 assert.Equal(t, g.DeleteAt, group2.DeleteAt) 118 119 _, response = th.SystemAdminClient.PatchGroup(model.NewId(), gp) 120 CheckNotFoundStatus(t, response) 121 122 th.SystemAdminClient.Logout() 123 _, response = th.SystemAdminClient.PatchGroup(group.Id, gp) 124 CheckUnauthorizedStatus(t, response) 125 } 126 127 func TestLinkGroupTeam(t *testing.T) { 128 th := Setup().InitBasic() 129 defer th.TearDown() 130 131 id := model.NewId() 132 g, err := th.App.CreateGroup(&model.Group{ 133 DisplayName: "dn_" + id, 134 Name: "name" + id, 135 Source: model.GroupSourceLdap, 136 Description: "description_" + id, 137 RemoteId: model.NewId(), 138 }) 139 assert.Nil(t, err) 140 141 patch := &model.GroupSyncablePatch{ 142 AutoAdd: model.NewBool(true), 143 } 144 145 _, response := th.Client.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 146 CheckNotImplementedStatus(t, response) 147 148 _, response = th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 149 CheckNotImplementedStatus(t, response) 150 151 th.App.SetLicense(model.NewTestLicense("ldap")) 152 153 groupTeam, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 154 assert.Equal(t, http.StatusCreated, response.StatusCode) 155 assert.NotNil(t, groupTeam) 156 } 157 158 func TestLinkGroupChannel(t *testing.T) { 159 th := Setup().InitBasic() 160 defer th.TearDown() 161 162 id := model.NewId() 163 g, err := th.App.CreateGroup(&model.Group{ 164 DisplayName: "dn_" + id, 165 Name: "name" + id, 166 Source: model.GroupSourceLdap, 167 Description: "description_" + id, 168 RemoteId: model.NewId(), 169 }) 170 assert.Nil(t, err) 171 172 patch := &model.GroupSyncablePatch{ 173 AutoAdd: model.NewBool(true), 174 } 175 176 _, response := th.Client.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 177 CheckNotImplementedStatus(t, response) 178 179 _, response = th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 180 CheckNotImplementedStatus(t, response) 181 182 th.App.SetLicense(model.NewTestLicense("ldap")) 183 184 _, response = th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 185 assert.Equal(t, http.StatusCreated, response.StatusCode) 186 } 187 188 func TestUnlinkGroupTeam(t *testing.T) { 189 th := Setup().InitBasic() 190 defer th.TearDown() 191 192 id := model.NewId() 193 g, err := th.App.CreateGroup(&model.Group{ 194 DisplayName: "dn_" + id, 195 Name: "name" + id, 196 Source: model.GroupSourceLdap, 197 Description: "description_" + id, 198 RemoteId: model.NewId(), 199 }) 200 assert.Nil(t, err) 201 202 patch := &model.GroupSyncablePatch{ 203 AutoAdd: model.NewBool(true), 204 } 205 206 th.App.SetLicense(model.NewTestLicense("ldap")) 207 208 _, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 209 assert.Equal(t, http.StatusCreated, response.StatusCode) 210 211 th.App.SetLicense(nil) 212 213 response = th.Client.UnlinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam) 214 CheckNotImplementedStatus(t, response) 215 216 response = th.SystemAdminClient.UnlinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam) 217 CheckNotImplementedStatus(t, response) 218 219 th.App.SetLicense(model.NewTestLicense("ldap")) 220 221 response = th.SystemAdminClient.UnlinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam) 222 CheckOKStatus(t, response) 223 } 224 225 func TestUnlinkGroupChannel(t *testing.T) { 226 th := Setup().InitBasic() 227 defer th.TearDown() 228 229 id := model.NewId() 230 g, err := th.App.CreateGroup(&model.Group{ 231 DisplayName: "dn_" + id, 232 Name: "name" + id, 233 Source: model.GroupSourceLdap, 234 Description: "description_" + id, 235 RemoteId: model.NewId(), 236 }) 237 assert.Nil(t, err) 238 239 patch := &model.GroupSyncablePatch{ 240 AutoAdd: model.NewBool(true), 241 } 242 243 th.App.SetLicense(model.NewTestLicense("ldap")) 244 245 _, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 246 assert.Equal(t, http.StatusCreated, response.StatusCode) 247 248 th.App.SetLicense(nil) 249 250 response = th.Client.UnlinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel) 251 CheckNotImplementedStatus(t, response) 252 253 response = th.SystemAdminClient.UnlinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel) 254 CheckNotImplementedStatus(t, response) 255 256 th.App.SetLicense(model.NewTestLicense("ldap")) 257 258 response = th.SystemAdminClient.UnlinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel) 259 CheckOKStatus(t, response) 260 } 261 262 func TestGetGroupTeam(t *testing.T) { 263 th := Setup().InitBasic() 264 defer th.TearDown() 265 266 id := model.NewId() 267 g, err := th.App.CreateGroup(&model.Group{ 268 DisplayName: "dn_" + id, 269 Name: "name" + id, 270 Source: model.GroupSourceLdap, 271 Description: "description_" + id, 272 RemoteId: model.NewId(), 273 }) 274 assert.Nil(t, err) 275 276 _, response := th.Client.GetGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, "") 277 CheckNotImplementedStatus(t, response) 278 279 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, "") 280 CheckNotImplementedStatus(t, response) 281 282 th.App.SetLicense(model.NewTestLicense("ldap")) 283 284 patch := &model.GroupSyncablePatch{ 285 AutoAdd: model.NewBool(true), 286 } 287 288 _, response = th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 289 assert.Equal(t, http.StatusCreated, response.StatusCode) 290 291 groupSyncable, response := th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, "") 292 CheckOKStatus(t, response) 293 assert.NotNil(t, groupSyncable) 294 295 assert.Equal(t, g.Id, groupSyncable.GroupId) 296 assert.Equal(t, th.BasicTeam.Id, groupSyncable.SyncableId) 297 assert.Equal(t, *patch.AutoAdd, groupSyncable.AutoAdd) 298 299 _, response = th.SystemAdminClient.GetGroupSyncable(model.NewId(), th.BasicTeam.Id, model.GroupSyncableTypeTeam, "") 300 CheckNotFoundStatus(t, response) 301 302 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, model.NewId(), model.GroupSyncableTypeTeam, "") 303 CheckNotFoundStatus(t, response) 304 305 _, response = th.SystemAdminClient.GetGroupSyncable("asdfasdfe3", th.BasicTeam.Id, model.GroupSyncableTypeTeam, "") 306 CheckBadRequestStatus(t, response) 307 308 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, "asdfasdfe3", model.GroupSyncableTypeTeam, "") 309 CheckBadRequestStatus(t, response) 310 311 th.SystemAdminClient.Logout() 312 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, "") 313 CheckUnauthorizedStatus(t, response) 314 } 315 316 func TestGetGroupChannel(t *testing.T) { 317 th := Setup().InitBasic() 318 defer th.TearDown() 319 320 id := model.NewId() 321 g, err := th.App.CreateGroup(&model.Group{ 322 DisplayName: "dn_" + id, 323 Name: "name" + id, 324 Source: model.GroupSourceLdap, 325 Description: "description_" + id, 326 RemoteId: model.NewId(), 327 }) 328 assert.Nil(t, err) 329 330 _, response := th.Client.GetGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, "") 331 CheckNotImplementedStatus(t, response) 332 333 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, "") 334 CheckNotImplementedStatus(t, response) 335 336 th.App.SetLicense(model.NewTestLicense("ldap")) 337 338 patch := &model.GroupSyncablePatch{ 339 AutoAdd: model.NewBool(true), 340 } 341 342 _, response = th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 343 assert.Equal(t, http.StatusCreated, response.StatusCode) 344 345 groupSyncable, response := th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, "") 346 CheckOKStatus(t, response) 347 assert.NotNil(t, groupSyncable) 348 349 assert.Equal(t, g.Id, groupSyncable.GroupId) 350 assert.Equal(t, th.BasicChannel.Id, groupSyncable.SyncableId) 351 assert.Equal(t, *patch.AutoAdd, groupSyncable.AutoAdd) 352 353 _, response = th.SystemAdminClient.GetGroupSyncable(model.NewId(), th.BasicChannel.Id, model.GroupSyncableTypeChannel, "") 354 CheckNotFoundStatus(t, response) 355 356 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, model.NewId(), model.GroupSyncableTypeChannel, "") 357 CheckNotFoundStatus(t, response) 358 359 _, response = th.SystemAdminClient.GetGroupSyncable("asdfasdfe3", th.BasicChannel.Id, model.GroupSyncableTypeChannel, "") 360 CheckBadRequestStatus(t, response) 361 362 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, "asdfasdfe3", model.GroupSyncableTypeChannel, "") 363 CheckBadRequestStatus(t, response) 364 365 th.SystemAdminClient.Logout() 366 _, response = th.SystemAdminClient.GetGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, "") 367 CheckUnauthorizedStatus(t, response) 368 } 369 370 func TestGetGroupTeams(t *testing.T) { 371 th := Setup().InitBasic() 372 defer th.TearDown() 373 374 id := model.NewId() 375 g, err := th.App.CreateGroup(&model.Group{ 376 DisplayName: "dn_" + id, 377 Name: "name" + id, 378 Source: model.GroupSourceLdap, 379 Description: "description_" + id, 380 RemoteId: model.NewId(), 381 }) 382 assert.Nil(t, err) 383 384 th.App.SetLicense(model.NewTestLicense("ldap")) 385 386 patch := &model.GroupSyncablePatch{ 387 AutoAdd: model.NewBool(true), 388 } 389 390 for i := 0; i < 10; i++ { 391 team := th.CreateTeam() 392 _, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, team.Id, model.GroupSyncableTypeTeam, patch) 393 assert.Equal(t, http.StatusCreated, response.StatusCode) 394 } 395 396 th.App.SetLicense(nil) 397 398 _, response := th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "") 399 CheckNotImplementedStatus(t, response) 400 401 _, response = th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "") 402 CheckNotImplementedStatus(t, response) 403 404 th.App.SetLicense(model.NewTestLicense("ldap")) 405 406 _, response = th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "") 407 assert.Equal(t, http.StatusForbidden, response.StatusCode) 408 409 groupSyncables, response := th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "") 410 CheckOKStatus(t, response) 411 412 assert.Len(t, groupSyncables, 10) 413 414 th.SystemAdminClient.Logout() 415 _, response = th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeTeam, "") 416 CheckUnauthorizedStatus(t, response) 417 } 418 419 func TestGetGroupChannels(t *testing.T) { 420 th := Setup().InitBasic() 421 defer th.TearDown() 422 423 id := model.NewId() 424 g, err := th.App.CreateGroup(&model.Group{ 425 DisplayName: "dn_" + id, 426 Name: "name" + id, 427 Source: model.GroupSourceLdap, 428 Description: "description_" + id, 429 RemoteId: model.NewId(), 430 }) 431 assert.Nil(t, err) 432 433 th.App.SetLicense(model.NewTestLicense("ldap")) 434 435 patch := &model.GroupSyncablePatch{ 436 AutoAdd: model.NewBool(true), 437 } 438 439 for i := 0; i < 10; i++ { 440 channel := th.CreatePublicChannel() 441 _, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, channel.Id, model.GroupSyncableTypeChannel, patch) 442 assert.Equal(t, http.StatusCreated, response.StatusCode) 443 } 444 445 th.App.SetLicense(nil) 446 447 _, response := th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "") 448 CheckNotImplementedStatus(t, response) 449 450 _, response = th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "") 451 CheckNotImplementedStatus(t, response) 452 453 th.App.SetLicense(model.NewTestLicense("ldap")) 454 455 _, response = th.Client.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "") 456 assert.Equal(t, http.StatusForbidden, response.StatusCode) 457 458 groupSyncables, response := th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "") 459 CheckOKStatus(t, response) 460 461 assert.Len(t, groupSyncables, 10) 462 463 th.SystemAdminClient.Logout() 464 _, response = th.SystemAdminClient.GetGroupSyncables(g.Id, model.GroupSyncableTypeChannel, "") 465 CheckUnauthorizedStatus(t, response) 466 } 467 468 func TestPatchGroupTeam(t *testing.T) { 469 th := Setup().InitBasic() 470 defer th.TearDown() 471 472 id := model.NewId() 473 g, err := th.App.CreateGroup(&model.Group{ 474 DisplayName: "dn_" + id, 475 Name: "name" + id, 476 Source: model.GroupSourceLdap, 477 Description: "description_" + id, 478 RemoteId: model.NewId(), 479 }) 480 assert.Nil(t, err) 481 482 patch := &model.GroupSyncablePatch{ 483 AutoAdd: model.NewBool(true), 484 } 485 486 th.App.SetLicense(model.NewTestLicense("ldap")) 487 488 groupSyncable, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 489 assert.Equal(t, http.StatusCreated, response.StatusCode) 490 assert.NotNil(t, groupSyncable) 491 assert.True(t, groupSyncable.AutoAdd) 492 493 _, response = th.Client.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 494 assert.Equal(t, http.StatusForbidden, response.StatusCode) 495 496 th.App.SetLicense(nil) 497 498 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 499 CheckNotImplementedStatus(t, response) 500 501 th.App.SetLicense(model.NewTestLicense("ldap")) 502 503 patch.AutoAdd = model.NewBool(false) 504 groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 505 CheckOKStatus(t, response) 506 assert.False(t, groupSyncable.AutoAdd) 507 508 assert.Equal(t, g.Id, groupSyncable.GroupId) 509 assert.Equal(t, th.BasicTeam.Id, groupSyncable.SyncableId) 510 assert.Equal(t, model.GroupSyncableTypeTeam, groupSyncable.Type) 511 512 patch.AutoAdd = model.NewBool(true) 513 groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 514 CheckOKStatus(t, response) 515 516 _, response = th.SystemAdminClient.PatchGroupSyncable(model.NewId(), th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 517 CheckNotFoundStatus(t, response) 518 519 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, model.NewId(), model.GroupSyncableTypeTeam, patch) 520 CheckNotFoundStatus(t, response) 521 522 _, response = th.SystemAdminClient.PatchGroupSyncable("abc", th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 523 CheckBadRequestStatus(t, response) 524 525 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, "abc", model.GroupSyncableTypeTeam, patch) 526 CheckBadRequestStatus(t, response) 527 528 th.SystemAdminClient.Logout() 529 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam, patch) 530 CheckUnauthorizedStatus(t, response) 531 } 532 533 func TestPatchGroupChannel(t *testing.T) { 534 th := Setup().InitBasic() 535 defer th.TearDown() 536 537 id := model.NewId() 538 g, err := th.App.CreateGroup(&model.Group{ 539 DisplayName: "dn_" + id, 540 Name: "name" + id, 541 Source: model.GroupSourceLdap, 542 Description: "description_" + id, 543 RemoteId: model.NewId(), 544 }) 545 assert.Nil(t, err) 546 547 patch := &model.GroupSyncablePatch{ 548 AutoAdd: model.NewBool(true), 549 } 550 551 th.App.SetLicense(model.NewTestLicense("ldap")) 552 553 groupSyncable, response := th.SystemAdminClient.LinkGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 554 assert.Equal(t, http.StatusCreated, response.StatusCode) 555 assert.NotNil(t, groupSyncable) 556 assert.True(t, groupSyncable.AutoAdd) 557 558 _, response = th.Client.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 559 assert.Equal(t, http.StatusForbidden, response.StatusCode) 560 561 th.App.SetLicense(nil) 562 563 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 564 CheckNotImplementedStatus(t, response) 565 566 th.App.SetLicense(model.NewTestLicense("ldap")) 567 568 patch.AutoAdd = model.NewBool(false) 569 groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 570 CheckOKStatus(t, response) 571 assert.False(t, groupSyncable.AutoAdd) 572 573 assert.Equal(t, g.Id, groupSyncable.GroupId) 574 assert.Equal(t, th.BasicChannel.Id, groupSyncable.SyncableId) 575 assert.Equal(t, model.GroupSyncableTypeChannel, groupSyncable.Type) 576 577 patch.AutoAdd = model.NewBool(true) 578 groupSyncable, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 579 CheckOKStatus(t, response) 580 581 _, response = th.SystemAdminClient.PatchGroupSyncable(model.NewId(), th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 582 CheckNotFoundStatus(t, response) 583 584 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, model.NewId(), model.GroupSyncableTypeChannel, patch) 585 CheckNotFoundStatus(t, response) 586 587 _, response = th.SystemAdminClient.PatchGroupSyncable("abc", th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 588 CheckBadRequestStatus(t, response) 589 590 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, "abc", model.GroupSyncableTypeChannel, patch) 591 CheckBadRequestStatus(t, response) 592 593 th.SystemAdminClient.Logout() 594 _, response = th.SystemAdminClient.PatchGroupSyncable(g.Id, th.BasicChannel.Id, model.GroupSyncableTypeChannel, patch) 595 CheckUnauthorizedStatus(t, response) 596 }