MCPcopy Index your code
hub / github.com/coder/coder / TestPatchRoleSyncConfig

Function TestPatchRoleSyncConfig

enterprise/coderd/idpsync_test.go:400–468  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

398}
399
400func TestPatchRoleSyncConfig(t *testing.T) {
401 t.Parallel()
402
403 t.Run("OK", func(t *testing.T) {
404 t.Parallel()
405
406 owner, user := coderdenttest.New(t, &coderdenttest.Options{
407 LicenseOptions: &coderdenttest.LicenseOptions{
408 Features: license.Features{
409 codersdk.FeatureCustomRoles: 1,
410 codersdk.FeatureMultipleOrganizations: 1,
411 },
412 },
413 })
414
415 orgID := user.OrganizationID
416 orgAdmin, _ := coderdtest.CreateAnotherUser(t, owner, orgID, rbac.ScopedRoleOrgAdmin(user.OrganizationID))
417
418 mapping := map[string][]string{"wibble": {"group-01"}}
419
420 ctx := testutil.Context(t, testutil.WaitShort)
421 _, err := orgAdmin.PatchRoleIDPSyncSettings(ctx, orgID.String(), codersdk.RoleSyncSettings{
422 Field: "wibble",
423 Mapping: mapping,
424 })
425
426 require.NoError(t, err)
427
428 fetchedSettings, err := orgAdmin.RoleIDPSyncSettings(ctx, orgID.String())
429 require.NoError(t, err)
430 require.Equal(t, "wibble", fetchedSettings.Field)
431 require.Equal(t, mapping, fetchedSettings.Mapping)
432
433 ctx = testutil.Context(t, testutil.WaitShort)
434 settings, err := orgAdmin.PatchRoleIDPSyncConfig(ctx, orgID.String(), codersdk.PatchRoleIDPSyncConfigRequest{
435 Field: "wobble",
436 })
437
438 require.NoError(t, err)
439 require.Equal(t, "wobble", settings.Field)
440 require.Equal(t, mapping, settings.Mapping)
441
442 fetchedSettings, err = orgAdmin.RoleIDPSyncSettings(ctx, orgID.String())
443 require.NoError(t, err)
444 require.Equal(t, "wobble", fetchedSettings.Field)
445 require.Equal(t, mapping, fetchedSettings.Mapping)
446 })
447
448 t.Run("NotAuthorized", func(t *testing.T) {
449 t.Parallel()
450
451 owner, user := coderdenttest.New(t, &coderdenttest.Options{
452 LicenseOptions: &coderdenttest.LicenseOptions{
453 Features: license.Features{
454 codersdk.FeatureCustomRoles: 1,
455 codersdk.FeatureMultipleOrganizations: 1,
456 },
457 },

Callers

nothing calls this directly

Calls 12

StatusCodeMethod · 0.95
NewFunction · 0.92
CreateAnotherUserFunction · 0.92
ScopedRoleOrgAdminFunction · 0.92
ContextFunction · 0.92
RoleIDPSyncSettingsMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected