forked from Github-Mirrors/canaille
unit tests: improved token revokation coverage
This commit is contained in:
parent
b34e862e4b
commit
b230e40e23
1 changed files with 18 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
from . import client_credentials
|
from . import client_credentials
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +20,22 @@ def test_token_revocation(testclient, user, client, token):
|
||||||
assert token.revokation_date
|
assert token.revokation_date
|
||||||
|
|
||||||
|
|
||||||
|
def test_cannot_refresh_after_revocation(testclient, user, client, token):
|
||||||
|
token.revokation_date = datetime.datetime.utcnow() - datetime.timedelta(days=7)
|
||||||
|
token.save()
|
||||||
|
|
||||||
|
res = testclient.post(
|
||||||
|
"/oauth/token",
|
||||||
|
params=dict(
|
||||||
|
grant_type="refresh_token",
|
||||||
|
refresh_token=token.refresh_token,
|
||||||
|
),
|
||||||
|
headers={"Authorization": f"Basic {client_credentials(client)}"},
|
||||||
|
status=400,
|
||||||
|
)
|
||||||
|
assert res.json == {"error": "invalid_grant"}
|
||||||
|
|
||||||
|
|
||||||
def test_token_invalid(testclient, client):
|
def test_token_invalid(testclient, client):
|
||||||
res = testclient.post(
|
res = testclient.post(
|
||||||
"/oauth/revoke",
|
"/oauth/revoke",
|
||||||
|
|
Loading…
Reference in a new issue