(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestUpdateRoleSync(t *testing.T) { |
| 72 | t.Parallel() |
| 73 | |
| 74 | t.Run("OK", func(t *testing.T) { |
| 75 | t.Parallel() |
| 76 | |
| 77 | owner, _ := coderdenttest.New(t, &coderdenttest.Options{ |
| 78 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 79 | Features: license.Features{ |
| 80 | codersdk.FeatureMultipleOrganizations: 1, |
| 81 | }, |
| 82 | }, |
| 83 | }) |
| 84 | |
| 85 | ctx := testutil.Context(t, testutil.WaitLong) |
| 86 | inv, root := clitest.New(t, "organization", "settings", "set", "rolesync") |
| 87 | //nolint:gocritic // Using the owner, testing the cli not perms |
| 88 | clitest.SetupConfig(t, owner, root) |
| 89 | |
| 90 | expectedSettings := codersdk.RoleSyncSettings{ |
| 91 | Field: "roles", |
| 92 | Mapping: map[string][]string{ |
| 93 | "test": {rbac.RoleOrgAdmin()}, |
| 94 | }, |
| 95 | } |
| 96 | expectedData, err := json.Marshal(expectedSettings) |
| 97 | require.NoError(t, err) |
| 98 | |
| 99 | buf := new(bytes.Buffer) |
| 100 | inv.Stdout = buf |
| 101 | inv.Stdin = bytes.NewBuffer(expectedData) |
| 102 | err = inv.WithContext(ctx).Run() |
| 103 | require.NoError(t, err) |
| 104 | require.JSONEq(t, string(expectedData), buf.String()) |
| 105 | |
| 106 | // Now read it back |
| 107 | inv, root = clitest.New(t, "organization", "settings", "show", "rolesync") |
| 108 | //nolint:gocritic // Using the owner, testing the cli not perms |
| 109 | clitest.SetupConfig(t, owner, root) |
| 110 | |
| 111 | buf = new(bytes.Buffer) |
| 112 | inv.Stdout = buf |
| 113 | err = inv.WithContext(ctx).Run() |
| 114 | require.NoError(t, err) |
| 115 | require.JSONEq(t, string(expectedData), buf.String()) |
| 116 | }) |
| 117 | } |
| 118 | |
| 119 | func TestUpdateOrganizationSync(t *testing.T) { |
| 120 | t.Parallel() |
nothing calls this directly
no test coverage detected