This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added usernameInIdp property to update user schema (#292)
This change fixes authentication of users who are added by admin from ServiceWorkbench UI directly
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,56 @@ describe('UserService', () => { | |
service.assertAuthorized = jest.fn(); | ||
}); | ||
|
||
describe('updateUser', () => { | ||
it('should not fail validation when usernameInIdp in schema', async () => { | ||
const user = { | ||
email: '[email protected]', | ||
usernameInIdp: 'example', | ||
uid: 'user1', | ||
rev: 0, | ||
}; | ||
|
||
// mocked functions | ||
service.toUserType = jest.fn(() => { | ||
return { userType: 'root' }; | ||
}); | ||
service.getUserByPrincipal = jest.fn(() => { | ||
return null; | ||
}); | ||
service.findUser = jest.fn(() => { | ||
return user; | ||
}); | ||
await service.updateUser({}, user); | ||
}); | ||
|
||
it('should fail validation when unknown property in schema', async () => { | ||
const user = { | ||
email: '[email protected]', | ||
usernameInIdp: 'example', | ||
uid: 'user1', | ||
rev: 0, | ||
unknown: 'unknownProperty', | ||
}; | ||
|
||
// mocked functions | ||
service.toUserType = jest.fn(() => { | ||
return { userType: 'root' }; | ||
}); | ||
service.getUserByPrincipal = jest.fn(() => { | ||
return null; | ||
}); | ||
service.findUser = jest.fn(() => { | ||
return user; | ||
}); | ||
try { | ||
await service.updateUser({}, user); | ||
expect.fail('Expected to throw error validation errors'); | ||
} catch (err) { | ||
expect(err.message).toEqual('Input has validation errors'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('createUsers', () => { | ||
it('should try to create a user', async () => { | ||
const user = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters