-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly encode links to edit user page (#81562)
- Loading branch information
Showing
4 changed files
with
63 additions
and
6 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
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 |
---|---|---|
|
@@ -71,6 +71,38 @@ describe('UsersGridPage', () => { | |
expect(findTestSubject(wrapper, 'userDisabled')).toHaveLength(0); | ||
}); | ||
|
||
it('generates valid links when usernames contain special characters', async () => { | ||
const apiClientMock = userAPIClientMock.create(); | ||
apiClientMock.getUsers.mockImplementation(() => { | ||
return Promise.resolve<User[]>([ | ||
{ | ||
username: 'username with some fun characters!@#$%^&*()', | ||
email: '[email protected]', | ||
full_name: 'foo bar', | ||
roles: ['kibana_user'], | ||
enabled: true, | ||
}, | ||
]); | ||
}); | ||
|
||
const wrapper = mountWithIntl( | ||
<UsersGridPage | ||
userAPIClient={apiClientMock} | ||
rolesAPIClient={rolesAPIClientMock.create()} | ||
notifications={coreStart.notifications} | ||
history={history} | ||
navigateToApp={coreStart.application.navigateToApp} | ||
/> | ||
); | ||
|
||
await waitForRender(wrapper); | ||
|
||
const link = findTestSubject(wrapper, 'userRowUserName'); | ||
expect(link.props().href).toMatchInlineSnapshot( | ||
`"/edit/username%20with%20some%20fun%20characters!%40%23%24%25%5E%26*()"` | ||
); | ||
}); | ||
|
||
it('renders a forbidden message if user is not authorized', async () => { | ||
const apiClient = userAPIClientMock.create(); | ||
apiClient.getUsers.mockRejectedValue({ body: { statusCode: 403 } }); | ||
|
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