mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-30 07:51:27 +00:00
19 lines
568 B
Python
19 lines
568 B
Python
import pytest
|
|
from datetime import datetime, timedelta
|
|
|
|
from selfprivacy_api.models.tokens.recovery_key import RecoveryKey
|
|
from selfprivacy_api.models.tokens.new_device_key import NewDeviceKey
|
|
|
|
|
|
def test_recovery_key_expired():
|
|
expiration = datetime.now() - timedelta(minutes=5)
|
|
key = RecoveryKey.generate(expiration=expiration, uses_left=2)
|
|
assert not key.is_valid()
|
|
|
|
|
|
def test_new_device_key_expired():
|
|
expiration = datetime.now() - timedelta(minutes=5)
|
|
key = NewDeviceKey.generate()
|
|
key.expires_at = expiration
|
|
assert not key.is_valid()
|