-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Includes a number of fixes for Starlette API and test client changes.
- Loading branch information
Showing
9 changed files
with
400 additions
and
358 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 |
---|---|---|
|
@@ -27,15 +27,15 @@ def test_rate_limit(self, test_client, irrd_db_session_with_user, config_overrid | |
response = test_client.post( | ||
self.url, | ||
data={"email": user.email, "password": "incorrect"}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
# This might already hit the limit from previous tests | ||
assert response.status_code in [200, 403] | ||
|
||
response = test_client.post( | ||
self.url, | ||
data={"email": user.email, "password": "incorrect"}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 403 | ||
|
||
|
@@ -44,14 +44,14 @@ def test_login_valid_mfa_pending(self, test_client, irrd_db_session_with_user): | |
response = test_client.post( | ||
self.url, | ||
data={"email": user.email, "password": SAMPLE_USER_PASSWORD}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
assert response.headers["Location"].endswith("/ui/auth/mfa-authenticate/") | ||
|
||
# Check that MFA is still pending | ||
response = test_client.get("/ui/user/") | ||
assert response.url.startswith("http://testserver/ui/auth/mfa-authenticate/") | ||
assert response.url.path == "/ui/auth/mfa-authenticate/" | ||
|
||
def test_login_valid_no_mfa(self, test_client, irrd_db_session_with_user): | ||
session_provider, user = irrd_db_session_with_user | ||
|
@@ -61,21 +61,21 @@ def test_login_valid_no_mfa(self, test_client, irrd_db_session_with_user): | |
response = test_client.post( | ||
self.url, | ||
data={"email": user.email, "password": SAMPLE_USER_PASSWORD}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
assert response.headers["Location"].endswith("/ui/") | ||
|
||
# Check that MFA is not pending | ||
response = test_client.get("/ui/user/") | ||
assert response.url.startswith("http://testserver/ui/user/") | ||
assert response.url.path == "/ui/user/" | ||
|
||
def test_login_invalid(self, test_client, irrd_db_session_with_user): | ||
session_provider, user = irrd_db_session_with_user | ||
response = test_client.post( | ||
self.url, | ||
data={"email": user.email, "password": "incorrect"}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "Invalid account" in response.text | ||
|
@@ -110,7 +110,7 @@ def test_create_valid(self, test_client_with_smtp, irrd_db_session_with_user): | |
response = test_client.post( | ||
self.url, | ||
data={"email": new_user_email, "name": "name"}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
|
||
|
@@ -132,7 +132,7 @@ def test_create_invalid_email_exists(self, test_client_with_smtp, irrd_db_sessio | |
response = test_client.post( | ||
self.url, | ||
data={"email": user.email, "name": "name"}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "account with this email" in response.text | ||
|
@@ -150,7 +150,7 @@ def test_create_invalid_missing_required(self, test_client_with_smtp, irrd_db_se | |
response = test_client.post( | ||
self.url, | ||
data={}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "This field is required" in response.text | ||
|
@@ -177,7 +177,7 @@ def test_request_valid(self, test_client_with_smtp, irrd_db_session_with_user): | |
response = test_client.post( | ||
self.url, | ||
data={"email": user.email}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
|
||
|
@@ -192,7 +192,7 @@ def test_request_unknown_user(self, test_client_with_smtp, irrd_db_session_with_ | |
response = test_client.post( | ||
self.url, | ||
data={"email": "[email protected]"}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
assert not smtpd.messages | ||
|
@@ -220,7 +220,7 @@ def test_valid(self, test_client_with_smtp, irrd_db_session_with_user): | |
"new_password_confirmation": new_password, | ||
"current_password": SAMPLE_USER_PASSWORD, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
self._login(test_client, user, new_password) | ||
|
@@ -241,7 +241,7 @@ def test_invalid_too_long(self, test_client_with_smtp, irrd_db_session_with_user | |
"new_password_confirmation": new_password, | ||
"current_password": SAMPLE_USER_PASSWORD, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "too long" in response.text | ||
|
@@ -262,7 +262,7 @@ def test_invalid_current_password(self, test_client_with_smtp, irrd_db_session_w | |
"new_password_confirmation": new_password, | ||
"current_password": "invalid", | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "Incorrect password." in response.text | ||
|
@@ -284,7 +284,7 @@ def test_invalid_password_mismatch(self, test_client_with_smtp, irrd_db_session_ | |
"new_password_confirmation": new_password2, | ||
"current_password": SAMPLE_USER_PASSWORD, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "do not match" in response.text | ||
|
@@ -303,7 +303,7 @@ def test_invalid_weak_password(self, test_client_with_smtp, irrd_db_session_with | |
"new_password_confirmation": "a", | ||
"current_password": SAMPLE_USER_PASSWORD, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "not strong enough" in response.text | ||
|
@@ -323,7 +323,7 @@ def test_invalid_missing_field(self, test_client_with_smtp, irrd_db_session_with | |
"new_password": new_password, | ||
"new_password_confirmation": new_password, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "This field is required." in response.text | ||
|
@@ -355,7 +355,7 @@ def test_valid(self, test_client_with_smtp, irrd_db_session_with_user): | |
"name": new_name, | ||
"current_password": SAMPLE_USER_PASSWORD, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
|
||
|
@@ -383,7 +383,7 @@ def test_invalid_current_password(self, test_client_with_smtp, irrd_db_session_w | |
"name": new_name, | ||
"current_password": "invalid", | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "Incorrect password." in response.text | ||
|
@@ -406,7 +406,7 @@ def test_invalid_email(self, test_client_with_smtp, irrd_db_session_with_user): | |
"name": "new name", | ||
"current_password": SAMPLE_USER_PASSWORD, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "Invalid email address" in response.text | ||
|
@@ -449,7 +449,7 @@ def test_valid_reset(self, test_client_with_smtp, irrd_db_session_with_user): | |
response = test_client.post( | ||
url, | ||
data={"new_password": new_password, "new_password_confirmation": new_password}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
self._login(test_client, user, new_password) | ||
|
@@ -465,7 +465,7 @@ def test_valid_reset_initial(self, test_client_with_smtp, irrd_db_session_with_u | |
response = test_client.post( | ||
url, | ||
data={"new_password": new_password, "new_password_confirmation": new_password}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 302 | ||
self._login(test_client, user, new_password) | ||
|
@@ -481,7 +481,7 @@ def test_invalid_password_mismatch(self, test_client_with_smtp, irrd_db_session_ | |
response = test_client.post( | ||
url, | ||
data={"new_password": new_password, "new_password_confirmation": new_password2}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "do not match" in response.text | ||
|
@@ -496,7 +496,7 @@ def test_invalid_password_weak(self, test_client_with_smtp, irrd_db_session_with | |
response = test_client.post( | ||
url, | ||
data={"new_password": "a", "new_password_confirmation": "a"}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "not strong enough" in response.text | ||
|
@@ -514,7 +514,7 @@ def test_invalid_missing_required(self, test_client_with_smtp, irrd_db_session_w | |
data={ | ||
"new_password": new_password, | ||
}, | ||
allow_redirects=False, | ||
follow_redirects=False, | ||
) | ||
assert response.status_code == 200 | ||
assert "This field is required." in response.text | ||
|
Oops, something went wrong.