-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d20577
commit 733d359
Showing
7 changed files
with
108 additions
and
23 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
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
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 |
---|---|---|
|
@@ -451,6 +451,82 @@ def test_PostUserGroupWithTerms_Fail(self): | |
utils.check_val_type(body["user_names"], list) | ||
utils.check_val_not_in(self.test_user_name, body["user_names"]) | ||
|
||
@runner.MAGPIE_TEST_USERS | ||
def test_PostUsers_NoExtraRegex_ValidRegex(self): | ||
""" | ||
Check that the user_name_extra_regex setting is not used to validate a new user name when user_name_extra_regex | ||
is falsy. | ||
.. versionadded:: 3.37 | ||
""" | ||
utils.warn_version(self, "extra username regex added", "3.37", skip=True) | ||
with utils.mocked_get_settings(settings={"magpie.user_name_extra_regex": None}): | ||
data = { | ||
"user_name": self.test_user_name, | ||
"password": self.test_user_name, | ||
"email": "[email protected]", | ||
} | ||
resp = utils.test_request(self, "POST", "/users", data=data, | ||
headers=self.json_headers, cookies=self.cookies, expect_errors=True) | ||
utils.check_response_basic_info(resp, 201, expected_method="POST") | ||
|
||
@runner.MAGPIE_TEST_USERS | ||
def test_PostUsers_WithExtraRegex_InvalidExtraRegex(self): | ||
""" | ||
Check that the user_name_extra_regex setting is used to validate a new user name when the user name is | ||
invalid according to that regex but is valid according to the ax.PARAM_REGEX. | ||
.. versionadded:: 3.37 | ||
""" | ||
utils.warn_version(self, "extra username regex added", "3.37", skip=True) | ||
with utils.mocked_get_settings(settings={"magpie.user_name_extra_regex": "^$"}): | ||
data = { | ||
"user_name": self.test_user_name, | ||
"password": self.test_user_name, | ||
"email": "[email protected]", | ||
} | ||
resp = utils.test_request(self, "POST", "/users", data=data, | ||
headers=self.json_headers, cookies=self.cookies, expect_errors=True) | ||
utils.check_response_basic_info(resp, 400, expected_method="POST") | ||
|
||
@runner.MAGPIE_TEST_USERS | ||
def test_PostUsers_WithExtraRegex_InvalidRegex(self): | ||
""" | ||
Check that the user_name_extra_regex setting is used to validate a new user name when the user name is | ||
valid according to that regex but is invalid according to the ax.PARAM_REGEX. | ||
.. versionadded:: 3.37 | ||
""" | ||
utils.warn_version(self, "extra username regex added", "3.37", skip=True) | ||
with utils.mocked_get_settings(settings={"magpie.user_name_extra_regex": "^.*$"}): | ||
data = { | ||
"user_name": "[email protected]", | ||
"password": self.test_user_name, | ||
"email": "[email protected]", | ||
} | ||
resp = utils.test_request(self, "POST", "/users", data=data, | ||
headers=self.json_headers, cookies=self.cookies, expect_errors=True) | ||
utils.check_response_basic_info(resp, 400, expected_method="POST") | ||
|
||
|
||
@runner.MAGPIE_TEST_USERS | ||
def test_PostUsers_WithExtraRegex_ValidBoth(self): | ||
""" | ||
Check that the user_name_extra_regex setting is used to validate a new user name when the user name is | ||
valid according to that regex and the ax.PARAM_REGEX. | ||
.. versionadded:: 3.37 | ||
""" | ||
utils.warn_version(self, "extra username regex added", "3.37", skip=True) | ||
with utils.mocked_get_settings(settings={"magpie.user_name_extra_regex": "^.*$"}): | ||
data = { | ||
"user_name": self.test_user_name, | ||
"password": self.test_user_name, | ||
"email": "[email protected]", | ||
} | ||
resp = utils.test_request(self, "POST", "/users", data=data, | ||
headers=self.json_headers, cookies=self.cookies, expect_errors=True) | ||
utils.check_response_basic_info(resp, 201, expected_method="POST") | ||
|
||
@runner.MAGPIE_TEST_API | ||
@runner.MAGPIE_TEST_LOCAL | ||
|