mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 23:41:28 +00:00
c6919293b6
I've learned that there is no problem in grouping mutations like we do with queries. This is a big mistake from my side, now we have legacy not so conveniently placed endpoints. I've grouped all mutations, left the copies of old ones flattened in the root for backwards compatibility. We will migrate to mutation groups on client side, and backups now only use grouped mutations. Tests are updated.
39 lines
994 B
Python
39 lines
994 B
Python
from selfprivacy_api.backup.local_secret import LocalBackupSecret
|
|
from pytest import fixture
|
|
|
|
|
|
@fixture()
|
|
def localsecret():
|
|
LocalBackupSecret._full_reset()
|
|
return LocalBackupSecret
|
|
|
|
|
|
def test_local_secret_firstget(localsecret):
|
|
assert not LocalBackupSecret.exists()
|
|
secret = LocalBackupSecret.get()
|
|
assert LocalBackupSecret.exists()
|
|
assert secret is not None
|
|
|
|
# making sure it does not reset again
|
|
secret2 = LocalBackupSecret.get()
|
|
assert LocalBackupSecret.exists()
|
|
assert secret2 == secret
|
|
|
|
|
|
def test_local_secret_reset(localsecret):
|
|
secret1 = LocalBackupSecret.get()
|
|
|
|
LocalBackupSecret.reset()
|
|
secret2 = LocalBackupSecret.get()
|
|
assert secret2 is not None
|
|
assert secret2 != secret1
|
|
|
|
|
|
def test_local_secret_set(localsecret):
|
|
newsecret = "great and totally safe secret"
|
|
oldsecret = LocalBackupSecret.get()
|
|
assert oldsecret != newsecret
|
|
|
|
LocalBackupSecret.set(newsecret)
|
|
assert LocalBackupSecret.get() == newsecret
|