2020-08-24 13:56:30 +00:00
|
|
|
from . import client_credentials
|
|
|
|
|
|
|
|
|
|
|
|
def test_token_revocation(testclient, user, client, token, slapd_connection):
|
2020-09-17 09:10:12 +00:00
|
|
|
assert not token.oauthRevokationDate
|
2020-08-24 13:56:30 +00:00
|
|
|
|
|
|
|
res = testclient.post(
|
|
|
|
"/oauth/revoke",
|
2021-10-29 12:20:06 +00:00
|
|
|
params=dict(
|
|
|
|
token=token.oauthAccessToken,
|
|
|
|
),
|
2020-08-24 13:56:30 +00:00
|
|
|
headers={"Authorization": f"Basic {client_credentials(client)}"},
|
2020-10-30 18:19:34 +00:00
|
|
|
status=200,
|
2020-08-24 13:56:30 +00:00
|
|
|
)
|
|
|
|
assert {} == res.json
|
|
|
|
|
|
|
|
token.reload(slapd_connection)
|
2020-09-17 09:10:12 +00:00
|
|
|
assert token.oauthRevokationDate
|
2020-08-24 13:56:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_token_invalid(testclient, client):
|
|
|
|
res = testclient.post(
|
|
|
|
"/oauth/revoke",
|
|
|
|
params=dict(token="invalid"),
|
|
|
|
headers={"Authorization": f"Basic {client_credentials(client)}"},
|
2020-10-30 18:19:34 +00:00
|
|
|
status=200,
|
2020-08-24 13:56:30 +00:00
|
|
|
)
|
|
|
|
assert {} == res.json
|