-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #674 from SUNET/lundberg_signup_fix
Better password handling in signup
- Loading branch information
Showing
6 changed files
with
23 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -544,6 +544,8 @@ def _create_user( | |
"use_suggested_password": True, | ||
"use_webauthn": False, | ||
} | ||
if custom_password is not None: | ||
_data["custom_password"] = custom_password | ||
if data is not None: | ||
_data.update(data) | ||
|
||
|
@@ -563,10 +565,8 @@ def _create_user( | |
assert self.get_response_payload(response)["state"]["email"]["completed"] is True | ||
assert self.get_response_payload(response)["state"]["credentials"]["completed"] is True | ||
if custom_password: | ||
assert ( | ||
self.get_response_payload(response)["state"]["credentials"]["custom_password"] | ||
== custom_password | ||
) | ||
assert self.get_response_payload(response)["state"]["credentials"]["custom_password"] is True | ||
assert self.get_response_payload(response)["state"]["credentials"]["generated_password"] is None | ||
else: | ||
assert ( | ||
self.get_response_payload(response)["state"]["credentials"]["generated_password"] | ||
|
@@ -848,7 +848,7 @@ def test_get_state_initial(self): | |
assert state == { | ||
"already_signed_up": False, | ||
"captcha": {"completed": False}, | ||
"credentials": {"completed": False, "generated_password": None}, | ||
"credentials": {"completed": False, "custom_password": False, "generated_password": None}, | ||
"email": {"address": None, "bad_attempts": 0, "bad_attempts_max": 3, "completed": False, "sent_at": None}, | ||
"invite": {"completed": False, "finish_url": None, "initiated_signup": False}, | ||
"name": {"given_name": None, "surname": None}, | ||
|
@@ -863,7 +863,7 @@ def test_get_state_initial_logged_in(self): | |
assert state == { | ||
"already_signed_up": True, | ||
"captcha": {"completed": False}, | ||
"credentials": {"completed": False, "generated_password": None}, | ||
"credentials": {"completed": False, "custom_password": False, "generated_password": None}, | ||
"email": {"address": None, "bad_attempts": 0, "bad_attempts_max": 3, "completed": False, "sent_at": None}, | ||
"invite": {"completed": False, "finish_url": None, "initiated_signup": False}, | ||
"name": {"given_name": None, "surname": None}, | ||
|
@@ -1249,10 +1249,9 @@ def test_create_user_with_custom_password(self): | |
self._prepare_for_create_user(given_name=given_name, surname=surname, email=email) | ||
data = { | ||
"use_suggested_password": False, | ||
"custom_password": "9MbKxTHhCDK3Y9hhn6", | ||
"use_webauthn": False, | ||
} | ||
response = self._create_user(data=data, expect_success=True) | ||
response = self._create_user(data=data, custom_password="9MbKxTHhCDK3Y9hhn6", expect_success=True) | ||
assert response.reached_state == SignupState.S6_CREATE_USER | ||
|
||
with self.session_cookie_anon(self.browser) as client: | ||
|
@@ -1272,10 +1271,11 @@ def test_create_user_with_weak_custom_password(self): | |
self._prepare_for_create_user(given_name=given_name, surname=surname, email=email) | ||
data = { | ||
"use_suggested_password": True, | ||
"custom_password": "abc123", | ||
"use_webauthn": False, | ||
} | ||
response = self._create_user(data=data, expect_success=False, expected_message=SignupMsg.weak_custom_password) | ||
response = self._create_user( | ||
data=data, custom_password="abc123", expect_success=False, expected_message=SignupMsg.weak_custom_password | ||
) | ||
assert response.reached_state == SignupState.S6_CREATE_USER | ||
|
||
def test_create_user_out_of_sync(self): | ||
|
@@ -1382,7 +1382,7 @@ def test_get_state_after_accept_invite(self): | |
assert normalised_data(state, exclude_keys=["expires_time_left", "throttle_time_left", "sent_at"]) == { | ||
"already_signed_up": False, | ||
"captcha": {"completed": False}, | ||
"credentials": {"completed": False, "generated_password": None}, | ||
"credentials": {"completed": False, "custom_password": False, "generated_password": None}, | ||
"email": { | ||
"address": "[email protected]", | ||
"bad_attempts": 0, | ||
|
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