mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 20:11:30 +00:00
test(tokens-repo): allow ading uses in a helper recovery function
This commit is contained in:
parent
3aa3d197e2
commit
42fa5fe524
|
@ -251,15 +251,23 @@ def test_get_recovery_token_when_none_exists(authorized_client, tokens_file):
|
||||||
assert_original(tokens_file)
|
assert_original(tokens_file)
|
||||||
|
|
||||||
|
|
||||||
def rest_make_recovery_token(client, expires_at=None, timeformat=None):
|
def rest_make_recovery_token(client, expires_at=None, timeformat=None, uses=None):
|
||||||
if expires_at is None:
|
json = {}
|
||||||
response = client.post("/auth/recovery_token")
|
|
||||||
else:
|
if expires_at is not None:
|
||||||
assert timeformat is not None
|
assert timeformat is not None
|
||||||
expires_at_str = expires_at.strftime(timeformat)
|
expires_at_str = expires_at.strftime(timeformat)
|
||||||
|
json["expiration"] = expires_at_str
|
||||||
|
|
||||||
|
if uses is not None:
|
||||||
|
json["uses"] = uses
|
||||||
|
|
||||||
|
if json == {}:
|
||||||
|
response = client.post("/auth/recovery_token")
|
||||||
|
else:
|
||||||
response = client.post(
|
response = client.post(
|
||||||
"/auth/recovery_token",
|
"/auth/recovery_token",
|
||||||
json={"expiration": expires_at_str},
|
json=json,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
Loading…
Reference in a new issue