From 67b9201fbe02841e25d73e48ebeda742ca7caad3 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Feb 2024 16:47:55 +0100 Subject: [PATCH 01/54] Add tests --- packages/pro | 2 +- .../src/api/routes/global/tests/scim.spec.ts | 52 ++++++++++++++++--- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/packages/pro b/packages/pro index 183b35d3ac..f78c338070 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 183b35d3acd42433dcb2d32bcd89a36abe13afec +Subproject commit f78c3380700ad71b40d64fc6de6097b39143dbd9 diff --git a/packages/worker/src/api/routes/global/tests/scim.spec.ts b/packages/worker/src/api/routes/global/tests/scim.spec.ts index ae0abadc5d..3ab2ccffa4 100644 --- a/packages/worker/src/api/routes/global/tests/scim.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim.spec.ts @@ -10,8 +10,6 @@ import { import { TestConfiguration } from "../../../../tests" import { events } from "@budibase/backend-core" -// this test can 409 - retries reduce issues with this -jest.retryTimes(2, { logErrorsBeforeRetry: true }) jest.setTimeout(30000) describe("scim", () => { @@ -367,13 +365,53 @@ describe("scim", () => { }) }) - it("creating an existing user name returns a conflict", async () => { - const body = structures.scim.createUserRequest() + it("creating an external user that conflicts an internal one syncs the existing user", async () => { + const { body: internalUser } = await config.api.users.saveUser( + structures.users.user() + ) - await postScimUser({ body }) + const scimUserData = { + externalId: structures.uuid(), + email: internalUser.email, + firstName: structures.generator.first(), + lastName: structures.generator.last(), + username: structures.generator.name(), + } + const scimUserRequest = structures.scim.createUserRequest(scimUserData) - const res = await postScimUser({ body }, { expect: 409 }) - expect((res as any).message).toBe("Email already in use") + const res = await postScimUser( + { body: scimUserRequest }, + { expect: 200 } + ) + + const expectedScimUser: ScimUserResponse = { + schemas: ["urn:ietf:params:scim:schemas:core:2.0:User"], + id: internalUser._id!, + externalId: scimUserRequest.externalId, + meta: { + resourceType: "User", + // @ts-ignore + created: mocks.date.MOCK_DATE.toISOString(), + // @ts-ignore + lastModified: mocks.date.MOCK_DATE.toISOString(), + }, + userName: scimUserData.username, + name: { + formatted: `${scimUserData.firstName} ${scimUserData.lastName}`, + familyName: scimUserData.lastName, + givenName: scimUserData.firstName, + }, + active: true, + emails: [ + { + value: internalUser.email, + type: "work", + primary: true, + }, + ], + } + + expect(res).toEqual(expectedScimUser) }) }) From 3aba6e70aa2624bbe9e32f260bf9af7366cd8461 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 26 Feb 2024 16:53:25 +0100 Subject: [PATCH 02/54] Add test validating not overriding scim users --- packages/pro | 2 +- .../src/api/routes/global/tests/scim.spec.ts | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index f78c338070..ec9dd27aee 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit f78c3380700ad71b40d64fc6de6097b39143dbd9 +Subproject commit ec9dd27aee79f206e595d36a438ca17efdcfde40 diff --git a/packages/worker/src/api/routes/global/tests/scim.spec.ts b/packages/worker/src/api/routes/global/tests/scim.spec.ts index 3ab2ccffa4..0c4a34be66 100644 --- a/packages/worker/src/api/routes/global/tests/scim.spec.ts +++ b/packages/worker/src/api/routes/global/tests/scim.spec.ts @@ -413,6 +413,30 @@ describe("scim", () => { expect(res).toEqual(expectedScimUser) }) + + it("a user cannot be SCIM synchronised with another SCIM user", async () => { + const { body: internalUser } = await config.api.users.saveUser( + structures.users.user() + ) + + await postScimUser( + { + body: structures.scim.createUserRequest({ + email: internalUser.email, + }), + }, + { expect: 200 } + ) + + await postScimUser( + { + body: structures.scim.createUserRequest({ + email: internalUser.email, + }), + }, + { expect: 409 } + ) + }) }) describe("GET /api/global/scim/v2/users/:id", () => { From 2bbb40fd3518de88a78b588720bb197293bba4f9 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 27 Feb 2024 13:11:15 +0100 Subject: [PATCH 03/54] Update pro ref --- packages/pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pro b/packages/pro index ec9dd27aee..b4b25a0ac1 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit ec9dd27aee79f206e595d36a438ca17efdcfde40 +Subproject commit b4b25a0ac1a395ae6c62f13fd2411cc9b134fa12 From 511cb5cee4e7d0891bc5d63e694ccfae45f125e7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 23 Feb 2024 16:42:41 +0100 Subject: [PATCH 04/54] Add sync icon to group icon --- .../portal/users/_components/SCIMInfo.svelte | 22 ++++++++++++++++++ .../users/groups/_components/GroupIcon.svelte | 23 ++++++++++++++++++- .../_components/GroupNameTableRenderer.svelte | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte diff --git a/packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte b/packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte new file mode 100644 index 0000000000..c530f08ef9 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte @@ -0,0 +1,22 @@ + + +
+ + {text} +
+ + diff --git a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte index c207501b55..25d33a0259 100644 --- a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte +++ b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte @@ -1,8 +1,29 @@ - +
+ + + {#if group.scimInfo?.isSync} +
+ +
+ {/if} +
+ + diff --git a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupNameTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupNameTableRenderer.svelte index 831ac6e20b..86816b50c9 100644 --- a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupNameTableRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupNameTableRenderer.svelte @@ -20,7 +20,7 @@ .align { display: flex; align-items: center; - overflow: hidden; + overflow: visible; gap: var(--spacing-m); max-width: var(--max-cell-width); flex: 1 1 auto; From c4e81c6e3873c67b3645c4786d62c4a3d5387679 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 23 Feb 2024 16:44:47 +0100 Subject: [PATCH 05/54] Change icon --- .../pages/builder/portal/users/_components/SCIMInfo.svelte | 6 +++--- .../portal/users/groups/_components/GroupIcon.svelte | 2 +- .../src/pages/builder/portal/users/groups/index.svelte | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte b/packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte index c530f08ef9..1fafc17e24 100644 --- a/packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte +++ b/packages/builder/src/pages/builder/portal/users/_components/SCIMInfo.svelte @@ -2,13 +2,13 @@ import { IconAvatar } from "@budibase/bbui" export let text = "" - export let size = "S" + export let iconSize = "S"
{text} diff --git a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte index 25d33a0259..9c8b50bf1a 100644 --- a/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte +++ b/packages/builder/src/pages/builder/portal/users/groups/_components/GroupIcon.svelte @@ -11,7 +11,7 @@ {#if group.scimInfo?.isSync}
- +
{/if}
diff --git a/packages/builder/src/pages/builder/portal/users/groups/index.svelte b/packages/builder/src/pages/builder/portal/users/groups/index.svelte index ab0a0eb938..0875e00f25 100644 --- a/packages/builder/src/pages/builder/portal/users/groups/index.svelte +++ b/packages/builder/src/pages/builder/portal/users/groups/index.svelte @@ -21,7 +21,7 @@ import UsersTableRenderer from "./_components/UsersTableRenderer.svelte" import GroupNameTableRenderer from "./_components/GroupNameTableRenderer.svelte" import { goto } from "@roxi/routify" - import ScimBanner from "../_components/SCIMBanner.svelte" + import ScimInfo from "../_components/SCIMInfo.svelte" import { sdk } from "@budibase/shared-core" const DefaultGroup = { @@ -116,7 +116,7 @@ Add group {:else} - + {/if} {:else} - {:else} - - {/if} + + {:else} - {:else} - {/if}
@@ -346,14 +344,19 @@ {customRenderers} loading={!$fetch.loaded || !groupsLoaded} /> -