-
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 tf-validate returning authorization_token.
Lots of fixes to openapi.yaml. closes #861
- Loading branch information
Showing
4 changed files
with
156 additions
and
114 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 |
---|---|---|
|
@@ -689,6 +689,32 @@ def test_rescue_json(app, client): | |
assert "[email protected]" in outbox[1].body | ||
|
||
|
||
@pytest.mark.settings(two_factor_required=True) | ||
def test_json_auth_token(app, client): | ||
""" | ||
Test getting auth_token with two-factor | ||
""" | ||
headers = {"Accept": "application/json", "Content-Type": "application/json"} | ||
|
||
# Login with someone already setup. | ||
sms_sender = SmsSenderFactory.createSender("test") | ||
data = dict(email="[email protected]", password="password") | ||
response = client.post("/login", json=data, headers=headers) | ||
assert response.status_code == 200 | ||
assert response.json["response"]["tf_required"] | ||
|
||
# Verify SMS sent | ||
assert sms_sender.get_count() == 1 | ||
code = sms_sender.messages[0].split()[-1] | ||
response = client.post("/tf-validate?include_auth_token", json=dict(code=code)) | ||
assert response.status_code == 200 | ||
token = response.json["response"]["user"]["authentication_token"] | ||
headers = {"Authentication-Token": token} | ||
# make sure can access restricted page | ||
response = client.get("/token", headers=headers) | ||
assert b"Token Authentication" in response.data | ||
|
||
|
||
@pytest.mark.settings(two_factor_required=True) | ||
def test_no_opt_out(app, client, get_message): | ||
# Test if 2FA required, can't opt-out. | ||
|