(t *testing.T)
| 704 | } |
| 705 | |
| 706 | func TestPatchOrganizationSyncMapping(t *testing.T) { |
| 707 | t.Parallel() |
| 708 | |
| 709 | t.Run("OK", func(t *testing.T) { |
| 710 | t.Parallel() |
| 711 | |
| 712 | owner, _ := coderdenttest.New(t, &coderdenttest.Options{ |
| 713 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 714 | Features: license.Features{ |
| 715 | codersdk.FeatureCustomRoles: 1, |
| 716 | codersdk.FeatureMultipleOrganizations: 1, |
| 717 | }, |
| 718 | }, |
| 719 | }) |
| 720 | |
| 721 | // These IDs are easier to visually diff if the test fails than truly random |
| 722 | // ones. |
| 723 | orgs := []uuid.UUID{ |
| 724 | uuid.MustParse("00000000-b8bd-46bb-bb6c-6c2b2c0dd2ea"), |
| 725 | uuid.MustParse("01000000-fbe8-464c-9429-fe01a03f3644"), |
| 726 | uuid.MustParse("02000000-0926-407b-9998-39af62e3d0c5"), |
| 727 | } |
| 728 | |
| 729 | ctx := testutil.Context(t, testutil.WaitShort) |
| 730 | //nolint:gocritic // Only owners can change Organization IdP sync settings |
| 731 | settings, err := owner.PatchOrganizationIDPSyncMapping(ctx, codersdk.PatchOrganizationIDPSyncMappingRequest{ |
| 732 | Add: []codersdk.IDPSyncMapping[uuid.UUID]{ |
| 733 | {Given: "wibble", Gets: orgs[0]}, |
| 734 | {Given: "wobble", Gets: orgs[0]}, |
| 735 | {Given: "wobble", Gets: orgs[1]}, |
| 736 | {Given: "wobble", Gets: orgs[2]}, |
| 737 | }, |
| 738 | Remove: []codersdk.IDPSyncMapping[uuid.UUID]{ |
| 739 | {Given: "wobble", Gets: orgs[1]}, |
| 740 | }, |
| 741 | }) |
| 742 | |
| 743 | expected := map[string][]uuid.UUID{ |
| 744 | "wibble": {orgs[0]}, |
| 745 | "wobble": {orgs[0], orgs[2]}, |
| 746 | } |
| 747 | |
| 748 | require.NoError(t, err) |
| 749 | require.Equal(t, expected, settings.Mapping) |
| 750 | |
| 751 | fetchedSettings, err := owner.OrganizationIDPSyncSettings(ctx) |
| 752 | require.NoError(t, err) |
| 753 | require.Equal(t, expected, fetchedSettings.Mapping) |
| 754 | }) |
| 755 | |
| 756 | t.Run("NotAuthorized", func(t *testing.T) { |
| 757 | t.Parallel() |
| 758 | |
| 759 | owner, user := coderdenttest.New(t, &coderdenttest.Options{ |
| 760 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 761 | Features: license.Features{ |
| 762 | codersdk.FeatureCustomRoles: 1, |
| 763 | codersdk.FeatureMultipleOrganizations: 1, |
nothing calls this directly
no test coverage detected