Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/v0/iam_users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface IamUser {
invitationExpired?: boolean
connectedDashboards?: Record<string, string[]>
isFirstLoginDone?: string
mmsId?: string | null
}

export interface IamUsersQueryHandler {
Expand Down
110 changes: 110 additions & 0 deletions test/iam_users/get-one.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down