-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
106 additions
and
15 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_mail_address = 'mailto:[email protected]' | ||
|
||
|
||
def test_should_return_error_for_non_existing_accounts(signed_request, directory): | ||
response = signed_request(directory['newAccount'], signed_request.nonce, {'onlyReturnExisting': True}) | ||
|
||
assert response.status_code == 400 | ||
assert response.headers['Content-Type'] == 'application/problem+json' | ||
assert response.json()['type'] == 'urn:ietf:params:acme:error:accountDoesNotExist' | ||
|
||
|
||
def test_should_not_reflect_unknown_fields(signed_request, directory): | ||
response = signed_request(directory['newAccount'], signed_request.nonce, {'contact': [_mail_address], 'unknown': 'dummy'}) | ||
assert response.status_code == 201 | ||
assert 'unknown' not in response.json() |
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 |
---|---|---|
@@ -1,10 +1,25 @@ | ||
from .conftest import TestClient | ||
|
||
def test_generate_nonce(testclient: TestClient): | ||
response = testclient.get('/acme/new-nonce') | ||
import re | ||
import jwcrypto | ||
|
||
|
||
def test_generate_nonce(testclient: TestClient, directory): | ||
response = testclient.get(directory['newNonce']) | ||
assert response.status_code == 204 | ||
nonce = response.headers['Replay-Nonce'] | ||
assert len(nonce) == 43 | ||
response2 = testclient.head('/acme/new-nonce') | ||
assert re.match('^[A-Za-z0-9_-]+$', nonce) | ||
assert len(jwcrypto.common.base64url_decode(nonce)) >= 128 // 8, 'minimum 128bit entropy' | ||
response2 = testclient.head(directory['newNonce']) | ||
nonce2 = response2.headers['Replay-Nonce'] | ||
assert nonce != nonce2 | ||
|
||
|
||
def test_should_fail_on_bad_nonce(signed_request, directory): | ||
response = signed_request(directory['newAccount'], 'not-a-correct-nonce', {'contact': ['mailto:[email protected]']}) | ||
|
||
assert response.status_code == 400 | ||
assert response.headers['Content-Type'] == 'application/problem+json' | ||
assert response.json()['type'] == 'urn:ietf:params:acme:error:badNonce' | ||
assert response.json()['detail'] == 'old nonce is wrong' |