From 878e1f4d9b7d188c24604ed85707e5db7b850666 Mon Sep 17 00:00:00 2001 From: Barbara Date: Thu, 30 Jul 2026 15:23:13 +0200 Subject: [PATCH] feat(): get mmsid for special admin - UOD-3753 --- src/v0/iam_users.ts | 1 + test/iam_users/get-one.test.ts | 110 +++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) diff --git a/src/v0/iam_users.ts b/src/v0/iam_users.ts index f95ebd18ac8..40c4bbf1536 100644 --- a/src/v0/iam_users.ts +++ b/src/v0/iam_users.ts @@ -51,6 +51,7 @@ export interface IamUser { invitationExpired?: boolean connectedDashboards?: Record isFirstLoginDone?: string + mmsId?: string | null } export interface IamUsersQueryHandler { diff --git a/test/iam_users/get-one.test.ts b/test/iam_users/get-one.test.ts index f21af3d6e42..258c2c15430 100644 --- a/test/iam_users/get-one.test.ts +++ b/test/iam_users/get-one.test.ts @@ -201,6 +201,116 @@ describe('v0: IamUser: can get one user', () => { expect(data.hasBackupCodesConfigured).toBe(true) }) + it('can get user with mmsId field', async () => { + if (process.env.SYSTEM_TEST !== 'true') { + mock.onPost('https://api.tillhub.com/api/v0/users/login').reply(() => { + return [ + 200, + { + token: '', + user: { + id: '123', + legacy_id: legacyId + } + } + ] + }) + + mock.onGet(`https://api.tillhub.com/api/v0/iam/users/${legacyId}/${iamUserId}`).reply(() => { + return [ + 200, + { + count: 1, + results: [ + { + id: iamUserId, + email: 'test@example.com', + firstName: 'Test', + lastName: 'User', + mmsId: 'mms-contact-1' + } + ] + } + ] + }) + } + + const options = { + credentials: { + username: user.username, + password: user.password + }, + base: process.env.TILLHUB_BASE + } + + const th = new TillhubClient() + + th.init(options) + await th.auth.loginUsername({ + username: user.username, + password: user.password + }) + + const iamUsers = th.iamUsers() + + const { data } = await iamUsers.get(iamUserId) + + expect(data.mmsId).toBe('mms-contact-1') + }) + + it('can get user with a null mmsId when the user did not come from MMS', async () => { + if (process.env.SYSTEM_TEST !== 'true') { + mock.onPost('https://api.tillhub.com/api/v0/users/login').reply(() => { + return [ + 200, + { + token: '', + user: { + id: '123', + legacy_id: legacyId + } + } + ] + }) + + mock.onGet(`https://api.tillhub.com/api/v0/iam/users/${legacyId}/${iamUserId}`).reply(() => { + return [ + 200, + { + count: 1, + results: [ + { + id: iamUserId, + email: 'test@example.com', + mmsId: null + } + ] + } + ] + }) + } + + const options = { + credentials: { + username: user.username, + password: user.password + }, + base: process.env.TILLHUB_BASE + } + + const th = new TillhubClient() + + th.init(options) + await th.auth.loginUsername({ + username: user.username, + password: user.password + }) + + const { data } = await th.iamUsers().get(iamUserId) + + expect(data.mmsId).toBeNull() + }) + it('rejects on status codes that are not 200', async () => { if (process.env.SYSTEM_TEST !== 'true') { mock.onPost('https://api.tillhub.com/api/v0/users/login').reply(() => {