From f8d775d17c1c3749de6c8842a3c45795d85b034a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Sat, 9 Aug 2025 17:07:21 +0300 Subject: [PATCH] fix build error, remove test for backport --- .../integration_test/users_create_test.go | 75 ------------------- .../middleware/scim_context_middleware.go | 2 +- 2 files changed, 1 insertion(+), 76 deletions(-) diff --git a/internal/api/scim/integration_test/users_create_test.go b/internal/api/scim/integration_test/users_create_test.go index 040a3eb888..35d5297878 100644 --- a/internal/api/scim/integration_test/users_create_test.go +++ b/internal/api/scim/integration_test/users_create_test.go @@ -426,78 +426,3 @@ func TestCreateUser_scopedExternalID(t *testing.T) { assert.Equal(tt, "701984", string(md.Metadata.Value)) }, retryDuration, tick) } - -func TestCreateUser_ignorePasswordOnCreate(t *testing.T) { - t.Parallel() - tests := []struct { - name string - ignorePassword string - scimErrorType string - scimErrorDetail string - wantUser *resources.ScimUser - wantErr bool - }{ - { - name: "ignorePasswordOnCreate set to false", - ignorePassword: "false", - wantErr: true, - scimErrorType: "invalidValue", - scimErrorDetail: "Password is too short", - }, - { - name: "ignorePasswordOnCreate set to an invalid value", - ignorePassword: "random", - wantErr: true, - scimErrorType: "invalidValue", - scimErrorDetail: "Invalid value for metadata key urn:zitadel:scim:ignorePasswordOnCreate: random", - }, - { - name: "ignorePasswordOnCreate set to true", - ignorePassword: "true", - wantUser: &resources.ScimUser{ - UserName: "acmeUser1", - Name: &resources.ScimUserName{ - FamilyName: "Ross", - GivenName: "Bethany", - }, - Emails: []*resources.ScimEmail{ - { - Value: "user1@example.com", - Primary: true, - }, - }, - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - // create a machine user - callingUserId, callingUserPat, err := Instance.CreateMachineUserPATWithMembership(CTX, "ORG_OWNER") - require.NoError(t, err) - ctx := integration.WithAuthorizationToken(CTX, callingUserPat) - - // set urn:zitadel:scim:ignorePasswordOnCreate metadata for the machine user - setAndEnsureMetadata(t, callingUserId, "urn:zitadel:scim:ignorePasswordOnCreate", tt.ignorePassword) - - // create a user with an invalid password - createdUser, err := Instance.Client.SCIM.Users.Create(ctx, Instance.DefaultOrg.Id, withUsername(invalidPasswordUserJson, "acmeUser1")) - require.Equal(t, tt.wantErr, err != nil) - if err != nil { - scimErr := scim.RequireScimError(t, http.StatusBadRequest, err) - assert.Equal(t, tt.scimErrorType, scimErr.Error.ScimType) - assert.Equal(t, tt.scimErrorDetail, scimErr.Error.Detail) - return - } - - retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute) - require.EventuallyWithT(t, func(ttt *assert.CollectT) { - // ensure the user is really stored and not just returned to the caller - fetchedUser, err := Instance.Client.SCIM.Users.Get(CTX, Instance.DefaultOrg.Id, createdUser.ID) - require.NoError(ttt, err) - assert.True(ttt, test.PartiallyDeepEqual(tt.wantUser, fetchedUser)) - }, retryDuration, tick) - }) - } -} diff --git a/internal/api/scim/middleware/scim_context_middleware.go b/internal/api/scim/middleware/scim_context_middleware.go index e9b6f48aa2..d63e490c08 100644 --- a/internal/api/scim/middleware/scim_context_middleware.go +++ b/internal/api/scim/middleware/scim_context_middleware.go @@ -42,7 +42,7 @@ func initScimContext(ctx context.Context, q *query.Queries) (context.Context, er } queries := sresources.BuildMetadataQueries(ctx, metadataKeys) - metadataList, err := q.SearchUserMetadata(ctx, false, userID, queries, nil) + metadataList, err := q.SearchUserMetadata(ctx, false, userID, queries, false) if err != nil { if zerrors.IsNotFound(err) { return ctx, nil