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
2 changes: 1 addition & 1 deletion x-pack/plugins/security/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const NEXT_URL_QUERY_STRING_PARAMETER = 'next';
* - Must contain only letters, numbers, spaces, punctuation and printable symbols.
* - Must not contain leading or trailing spaces.
*/
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]+(?<! )$/;
export const NAME_REGEX = /^(?! )[a-zA-Z0-9 !"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]*[a-zA-Z0-9!"#$%&'()*+,\-./\\:;<=>?@\[\]^_`{|}~]$/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: hmm, it doesn't look like we have any tests that validate this "no trailing whitespace" requirement or I missed that? If true, would you mind adding some?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I've added that in


/**
* Maximum length of usernames and role names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ describe('CreateUserPage', () => {

await findAllByText(/Username must not contain leading or trailing spaces/i);

fireEvent.change(await findByLabelText('Username'), {
target: { value: 'username_with_trailing_space ' },
});

await findAllByText(/Username must not contain leading or trailing spaces/i);

fireEvent.change(await findByLabelText('Username'), {
target: { value: '€' },
});
Expand Down