Skip to content

Commit 6d3ed2e

Browse files
committed
fixup some tests
1 parent 4326e9d commit 6d3ed2e

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

coderd/idpsync/organizations_test.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"cdr.dev/slog/sloggers/slogtest"
1111
"github.com/coder/coder/v2/coderd/idpsync"
12+
"github.com/coder/coder/v2/coderd/runtimeconfig"
1213
"github.com/coder/coder/v2/testutil"
1314
)
1415

@@ -18,11 +19,13 @@ func TestParseOrganizationClaims(t *testing.T) {
1819
t.Run("SingleOrgDeployment", func(t *testing.T) {
1920
t.Parallel()
2021

21-
s := idpsync.NewAGPLSync(slogtest.Make(t, &slogtest.Options{}), idpsync.SyncSettings{
22-
OrganizationField: "",
23-
OrganizationMapping: nil,
24-
OrganizationAssignDefault: true,
25-
})
22+
s := idpsync.NewAGPLSync(slogtest.Make(t, &slogtest.Options{}),
23+
runtimeconfig.NewNoopManager(),
24+
idpsync.DeploymentSyncSettings{
25+
OrganizationField: "",
26+
OrganizationMapping: nil,
27+
OrganizationAssignDefault: true,
28+
})
2629

2730
ctx := testutil.Context(t, testutil.WaitMedium)
2831

@@ -38,13 +41,15 @@ func TestParseOrganizationClaims(t *testing.T) {
3841
t.Parallel()
3942

4043
// AGPL has limited behavior
41-
s := idpsync.NewAGPLSync(slogtest.Make(t, &slogtest.Options{}), idpsync.SyncSettings{
42-
OrganizationField: "orgs",
43-
OrganizationMapping: map[string][]uuid.UUID{
44-
"random": {uuid.New()},
45-
},
46-
OrganizationAssignDefault: false,
47-
})
44+
s := idpsync.NewAGPLSync(slogtest.Make(t, &slogtest.Options{}),
45+
runtimeconfig.NewNoopManager(),
46+
idpsync.DeploymentSyncSettings{
47+
OrganizationField: "orgs",
48+
OrganizationMapping: map[string][]uuid.UUID{
49+
"random": {uuid.New()},
50+
},
51+
OrganizationAssignDefault: false,
52+
})
4853

4954
ctx := testutil.Context(t, testutil.WaitMedium)
5055

enterprise/coderd/enidpsync/enidpsync.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"cdr.dev/slog"
55
"github.com/coder/coder/v2/coderd/entitlements"
66
"github.com/coder/coder/v2/coderd/idpsync"
7+
"github.com/coder/coder/v2/coderd/runtimeconfig"
78
)
89

910
// EnterpriseIDPSync enabled syncing user information from an external IDP.
@@ -16,9 +17,9 @@ type EnterpriseIDPSync struct {
1617
*idpsync.AGPLIDPSync
1718
}
1819

19-
func NewSync(logger slog.Logger, set *entitlements.Set, settings idpsync.DeploymentSyncSettings) *EnterpriseIDPSync {
20+
func NewSync(logger slog.Logger, manager runtimeconfig.Manager, set *entitlements.Set, settings idpsync.DeploymentSyncSettings) *EnterpriseIDPSync {
2021
return &EnterpriseIDPSync{
2122
entitlements: set,
22-
AGPLIDPSync: idpsync.NewAGPLSync(logger.With(slog.F("enterprise_capable", "true")), settings),
23+
AGPLIDPSync: idpsync.NewAGPLSync(logger.With(slog.F("enterprise_capable", "true")), manager, settings),
2324
}
2425
}

enterprise/coderd/enidpsync/organizations_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/coder/coder/v2/coderd/entitlements"
2020
"github.com/coder/coder/v2/coderd/idpsync"
2121
"github.com/coder/coder/v2/coderd/rbac"
22+
"github.com/coder/coder/v2/coderd/runtimeconfig"
2223
"github.com/coder/coder/v2/codersdk"
2324
"github.com/coder/coder/v2/enterprise/coderd/enidpsync"
2425
"github.com/coder/coder/v2/testutil"
@@ -41,7 +42,7 @@ type Expectations struct {
4142
}
4243

4344
type OrganizationSyncTestCase struct {
44-
Settings idpsync.SyncSettings
45+
Settings idpsync.DeploymentSyncSettings
4546
Entitlements *entitlements.Set
4647
Exps []Expectations
4748
}
@@ -89,7 +90,7 @@ func TestOrganizationSync(t *testing.T) {
8990
other := dbgen.Organization(t, db, database.Organization{})
9091
return OrganizationSyncTestCase{
9192
Entitlements: entitled,
92-
Settings: idpsync.SyncSettings{
93+
Settings: idpsync.DeploymentSyncSettings{
9394
OrganizationField: "",
9495
OrganizationMapping: nil,
9596
OrganizationAssignDefault: true,
@@ -142,7 +143,7 @@ func TestOrganizationSync(t *testing.T) {
142143
three := dbgen.Organization(t, db, database.Organization{})
143144
return OrganizationSyncTestCase{
144145
Entitlements: entitled,
145-
Settings: idpsync.SyncSettings{
146+
Settings: idpsync.DeploymentSyncSettings{
146147
OrganizationField: "organizations",
147148
OrganizationMapping: map[string][]uuid.UUID{
148149
"first": {one.ID},
@@ -236,7 +237,7 @@ func TestOrganizationSync(t *testing.T) {
236237
}
237238

238239
// Create a new sync object
239-
sync := enidpsync.NewSync(logger, caseData.Entitlements, caseData.Settings)
240+
sync := enidpsync.NewSync(logger, runtimeconfig.NewStoreManager(rdb), caseData.Entitlements, caseData.Settings)
240241
for _, exp := range caseData.Exps {
241242
t.Run(exp.Name, func(t *testing.T) {
242243
params, httpErr := sync.ParseOrganizationClaims(ctx, exp.Claims)

0 commit comments

Comments
 (0)