-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): reject assertions if fxa-tokenVerified is false
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,26 @@ def test_unauthorized_error_status(self): | |
with self.assertRaises(ValueError): | ||
res = self.app.get('/1.0/sync/1.1', headers=headers) | ||
|
||
def test_unverified_token(self): | ||
headers = {'Authorization': 'BrowserID %s' % self._getassertion()} | ||
# Assertion should not be rejected if fxa-tokenVerified is unset | ||
mock_response = { | ||
"status": "okay", | ||
"email": "[email protected]", | ||
"idpClaims": {} | ||
} | ||
with self.mock_verifier(response=mock_response): | ||
self.app.get("/1.0/sync/1.1", headers=headers, status=200) | ||
# Assertion should not be rejected if fxa-tokenVerified is True | ||
mock_response['idpClaims']['fxa-tokenVerified'] = True | ||
with self.mock_verifier(response=mock_response): | ||
self.app.get("/1.0/sync/1.1", headers=headers, status=200) | ||
# Assertion should be rejected if fxa-tokenVerified is False | ||
mock_response['idpClaims']['fxa-tokenVerified'] = False | ||
with self.mock_verifier(response=mock_response): | ||
res = self.app.get("/1.0/sync/1.1", headers=headers, status=401) | ||
self.assertEqual(res.json['status'], 'invalid-credentials') | ||
|
||
def test_generation_number_change(self): | ||
headers = {"Authorization": "BrowserID %s" % self._getassertion()} | ||
# Start with no generation number. | ||
|
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