-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix test errors with newer Flask releases. (#607)
- Loading branch information
Showing
14 changed files
with
47 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,4 @@ | |
verify_and_update_password, | ||
) | ||
|
||
__version__ = "4.1.3" | ||
__version__ = "4.1.4" |
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 |
---|---|---|
|
@@ -318,13 +318,13 @@ def test_unauthorized_access(client, get_message): | |
def test_unauthorized_access_with_referrer(client, get_message): | ||
authenticate(client, "[email protected]") | ||
response = client.get("/admin", headers={"referer": "/admin"}) | ||
assert response.headers["Location"] != "/admin" | ||
client.get(response.headers["Location"]) | ||
assert response.location != "/admin" | ||
client.get(response.location) | ||
|
||
response = client.get( | ||
"/admin?a=b", headers={"referer": "http://localhost/admin?x=y"} | ||
) | ||
assert response.headers["Location"] == "http://localhost/" | ||
assert "/" in response.location | ||
client.get(response.headers["Location"]) | ||
|
||
response = client.get( | ||
|
@@ -336,7 +336,7 @@ def test_unauthorized_access_with_referrer(client, get_message): | |
# we expect a temp redirect (302) to the referer | ||
response = client.get("/admin?w=s", headers={"referer": "/profile"}) | ||
assert response.status_code == 302 | ||
assert response.headers["Location"] == "http://localhost/profile" | ||
assert "/profile" in response.location | ||
|
||
|
||
@pytest.mark.settings(unauthorized_view="/unauthz") | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
Lots of tests | ||
:copyright: (c) 2012 by Matt Wright. | ||
:copyright: (c) 2019-2021 by J. Christopher Wagner (jwag). | ||
:copyright: (c) 2019-2022 by J. Christopher Wagner (jwag). | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
|
@@ -814,8 +814,7 @@ def myspecialview(): | |
response = client.get("/myspecialview", follow_redirects=False) | ||
assert response.status_code == 302 | ||
assert ( | ||
response.location | ||
== "http://localhost/verify?next=http%3A%2F%2Flocalhost%2Fmyspecialview" | ||
"/verify?next=http%3A%2F%2Flocalhost%2Fmyspecialview" in response.location | ||
) | ||
assert flashes[0]["category"] == "error" | ||
assert flashes[0]["message"].encode("utf-8") == get_message( | ||
|
@@ -896,10 +895,7 @@ def myview(): | |
time.sleep(0.1) | ||
response = client.get("/myview", follow_redirects=False) | ||
assert response.status_code == 302 | ||
assert ( | ||
response.location | ||
== "http://localhost/myprefix/verify?next=http%3A%2F%2Flocalhost%2Fmyview" | ||
) | ||
assert "/myprefix/verify?next=http%3A%2F%2Flocalhost%2Fmyview" in response.location | ||
|
||
|
||
def test_authn_freshness_grace(app, client, get_message): | ||
|
@@ -941,10 +937,7 @@ def myview(): | |
# This should fail - should be a redirect | ||
response = client_nc.get("/myview", headers=h, follow_redirects=False) | ||
assert response.status_code == 302 | ||
assert ( | ||
response.location | ||
== "http://localhost/verify?next=http%3A%2F%2Flocalhost%2Fmyview" | ||
) | ||
assert "/verify?next=http%3A%2F%2Flocalhost%2Fmyview" in response.location | ||
|
||
|
||
def test_verify_fresh(app, client, get_message): | ||
|
@@ -1106,11 +1099,11 @@ def test_post_security_with_application_root(app, sqlalchemy_datastore): | |
"/login", data=dict(email="[email protected]", password="password") | ||
) | ||
assert response.status_code == 302 | ||
assert response.headers["Location"] == "http://localhost/root" | ||
assert "/root" in response.location | ||
|
||
response = client.get("/logout") | ||
assert response.status_code == 302 | ||
assert response.headers["Location"] == "http://localhost/root" | ||
assert "/root" in response.location | ||
|
||
|
||
def test_post_security_with_application_root_and_views(app, sqlalchemy_datastore): | ||
|
@@ -1129,11 +1122,11 @@ def test_post_security_with_application_root_and_views(app, sqlalchemy_datastore | |
"/login", data=dict(email="[email protected]", password="password") | ||
) | ||
assert response.status_code == 302 | ||
assert response.headers["Location"] == "http://localhost/post_login" | ||
assert "/post_login" in response.location | ||
|
||
response = client.get("/logout") | ||
assert response.status_code == 302 | ||
assert response.headers["Location"] == "http://localhost/post_logout" | ||
assert "/post_logout" in response.location | ||
|
||
|
||
@pytest.mark.settings(redirect_validate_mode="regex") | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
two_factor tests | ||
:copyright: (c) 2019-2021 by J. Christopher Wagner (jwag). | ||
:copyright: (c) 2019-2022 by J. Christopher Wagner (jwag). | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
|
@@ -319,8 +319,8 @@ def test_two_factor_flag(app, client): | |
"/tf-setup", data=dict(setup="not_a_method"), follow_redirects=True | ||
) | ||
assert b"Marked method is not valid" in response.data | ||
session = get_session(response) | ||
assert session["tf_state"] == "setup_from_login" | ||
with client.session_transaction() as session: | ||
assert session["tf_state"] == "setup_from_login" | ||
|
||
# try non-existing setup on setup page (using json) | ||
data = dict(setup="not_a_method") | ||
|
@@ -851,7 +851,7 @@ def test_admin_setup_reset(app, client, get_message): | |
# we shouldn't be logged in | ||
response = client.get("/profile", follow_redirects=False) | ||
assert response.status_code == 302 | ||
assert response.location == "http://localhost/login?next=%2Fprofile" | ||
assert "/login?next=%2Fprofile" in response.location | ||
|
||
# Use admin to setup gene's SMS/phone. | ||
with app.app_context(): | ||
|
@@ -1105,7 +1105,7 @@ def test_bad_sender(app, client, get_message): | |
data = {"email": "[email protected]", "password": "password"} | ||
response = client.post("login", data=data, follow_redirects=False) | ||
assert response.status_code == 302 | ||
assert response.location == "http://localhost/login" | ||
assert "/login" in response.location | ||
assert get_message("FAILED_TO_SEND_CODE") in flashes[0]["message"].encode("utf-8") | ||
|
||
# test w/ JSON | ||
|
@@ -1186,10 +1186,7 @@ def test_verify(app, client, get_message): | |
# Test setup when re-authenticate required | ||
authenticate(client) | ||
response = client.get("tf-setup", follow_redirects=False) | ||
verify_url = response.location | ||
assert ( | ||
verify_url == "http://localhost/verify?next=http%3A%2F%2Flocalhost%2Ftf-setup" | ||
) | ||
assert "/verify?next=http%3A%2F%2Flocalhost%2Ftf-setup" in response.location | ||
logout(client) | ||
|
||
# Now try again - follow redirects to get to verify form | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
Unified signin tests | ||
:copyright: (c) 2019-2021 by J. Christopher Wagner (jwag). | ||
:copyright: (c) 2019-2022 by J. Christopher Wagner (jwag). | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
@@ -513,7 +513,7 @@ def authned(myapp, user, **extra_args): | |
|
||
# Try with no code | ||
response = client.get("[email protected]", follow_redirects=False) | ||
assert response.location == "http://localhost/us-signin" | ||
assert "/us-signin" in response.location | ||
response = client.get("[email protected]", follow_redirects=True) | ||
assert get_message("API_ERROR") in response.data | ||
|
||
|
@@ -837,10 +837,7 @@ def test_verify(app, client, get_message): | |
us_authenticate(client) | ||
response = client.get("us-setup", follow_redirects=False) | ||
verify_url = response.location | ||
assert ( | ||
verify_url | ||
== "http://localhost/us-verify?next=http%3A%2F%2Flocalhost%2Fus-setup" | ||
) | ||
assert "/us-verify?next=http%3A%2F%2Flocalhost%2Fus-setup" in verify_url | ||
logout(client) | ||
us_authenticate(client) | ||
|
||
|
@@ -1099,7 +1096,7 @@ def test_next(app, client, get_message): | |
data=dict(identity="[email protected]", passcode=requests[0]["token"]), | ||
follow_redirects=False, | ||
) | ||
assert response.location == "http://localhost/post_login" | ||
assert "/post_login" in response.location | ||
|
||
logout(client) | ||
response = client.post( | ||
|
@@ -1109,7 +1106,8 @@ def test_next(app, client, get_message): | |
), | ||
follow_redirects=False, | ||
) | ||
assert response.location == "http://localhost/post_login" | ||
|
||
assert "/post_login" in response.location | ||
|
||
|
||
@pytest.mark.registerable() | ||
|
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