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

Function TestPatchOrganizationSyncSettings

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

Source from the content-addressed store, hash-verified

576}
577
578func TestPatchOrganizationSyncSettings(t *testing.T) {
579 t.Parallel()
580
581 t.Run("OK", func(t *testing.T) {
582 t.Parallel()
583
584 owner, _ := coderdenttest.New(t, &coderdenttest.Options{
585 LicenseOptions: &coderdenttest.LicenseOptions{
586 Features: license.Features{
587 codersdk.FeatureCustomRoles: 1,
588 codersdk.FeatureMultipleOrganizations: 1,
589 },
590 },
591 })
592
593 ctx := testutil.Context(t, testutil.WaitShort)
594 //nolint:gocritic // Only owners can change Organization IdP sync settings
595 settings, err := owner.PatchOrganizationIDPSyncSettings(ctx, codersdk.OrganizationSyncSettings{
596 Field: "august",
597 })
598 require.NoError(t, err)
599 require.Equal(t, "august", settings.Field)
600
601 fetchedSettings, err := owner.OrganizationIDPSyncSettings(ctx)
602 require.NoError(t, err)
603 require.Equal(t, "august", fetchedSettings.Field)
604 })
605
606 t.Run("NotAuthorized", func(t *testing.T) {
607 t.Parallel()
608
609 owner, user := coderdenttest.New(t, &coderdenttest.Options{
610 LicenseOptions: &coderdenttest.LicenseOptions{
611 Features: license.Features{
612 codersdk.FeatureCustomRoles: 1,
613 codersdk.FeatureMultipleOrganizations: 1,
614 },
615 },
616 })
617
618 member, _ := coderdtest.CreateAnotherUser(t, owner, user.OrganizationID)
619
620 ctx := testutil.Context(t, testutil.WaitShort)
621 _, err := member.PatchRoleIDPSyncSettings(ctx, user.OrganizationID.String(), codersdk.RoleSyncSettings{
622 Field: "august",
623 })
624 var apiError *codersdk.Error
625 require.ErrorAs(t, err, &apiError)
626 require.Equal(t, http.StatusForbidden, apiError.StatusCode())
627
628 _, err = member.RoleIDPSyncSettings(ctx, user.OrganizationID.String())
629 require.ErrorAs(t, err, &apiError)
630 require.Equal(t, http.StatusForbidden, apiError.StatusCode())
631 })
632}
633
634func TestPatchOrganizationSyncConfig(t *testing.T) {
635 t.Parallel()

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected