2022-12-19 17:37:44 +00:00
|
|
|
import pytest
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
from selfprivacy_api.models.tokens.recovery_key import RecoveryKey
|
2022-12-26 14:01:36 +00:00
|
|
|
from selfprivacy_api.models.tokens.new_device_key import NewDeviceKey
|
2022-12-19 17:37:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_recovery_key_expired():
|
|
|
|
expiration = datetime.now() - timedelta(minutes=5)
|
|
|
|
key = RecoveryKey.generate(expiration=expiration, uses_left=2)
|
|
|
|
assert not key.is_valid()
|
2022-12-26 14:01:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_new_device_key_expired():
|
|
|
|
expiration = datetime.now() - timedelta(minutes=5)
|
|
|
|
key = NewDeviceKey.generate()
|
|
|
|
key.expires_at = expiration
|
|
|
|
assert not key.is_valid()
|