test(backups): preliminary test of repo reset

This commit is contained in:
Houkime 2023-06-16 14:33:48 +00:00
parent 33c60f971d
commit 8e1e37c766
2 changed files with 46 additions and 1 deletions

View file

@ -64,7 +64,9 @@ class BackupMutations:
def remove_repository(self) -> GenericBackupConfigReturn: def remove_repository(self) -> GenericBackupConfigReturn:
"""Remove repository""" """Remove repository"""
Backups.reset() Backups.reset()
return Backup.configuration() return GenericBackupConfigReturn(
success=True, message="", code="200", configuration=Backup().configuration()
)
@strawberry.mutation(permission_classes=[IsAuthenticated]) @strawberry.mutation(permission_classes=[IsAuthenticated])
def set_autobackup_period( def set_autobackup_period(

View file

@ -6,6 +6,24 @@ from tests.common import generate_backup_query
from selfprivacy_api.graphql.common_types.service import service_to_graphql_service from selfprivacy_api.graphql.common_types.service import service_to_graphql_service
from selfprivacy_api.jobs import Jobs, JobStatus from selfprivacy_api.jobs import Jobs, JobStatus
API_REMOVE_REPOSITORY_MUTATION = """
mutation TestRemoveRepo {
removeRepository {
success
message
code
configuration {
provider
encryptionKey
isInitialized
autobackupPeriod
locationName
locationId
}
}
}
"""
API_INIT_MUTATION = """ API_INIT_MUTATION = """
mutation TestInitRepo($input: InitializeRepositoryInput!) { mutation TestInitRepo($input: InitializeRepositoryInput!) {
initializeRepository(repository: $input) { initializeRepository(repository: $input) {
@ -85,6 +103,17 @@ def api_backup(authorized_client, service):
return response return response
def api_remove(authorized_client):
response = authorized_client.post(
"/graphql",
json={
"query": API_REMOVE_REPOSITORY_MUTATION,
"variables": {},
},
)
return response
def api_init_without_key( def api_init_without_key(
authorized_client, kind, login, password, location_name, location_id authorized_client, kind, login, password, location_name, location_id
): ):
@ -193,3 +222,17 @@ def test_reinit(authorized_client, dummy_service, tmpdir):
job = data["job"] job = data["job"]
assert Jobs.get_job(job["uid"]).status == JobStatus.FINISHED assert Jobs.get_job(job["uid"]).status == JobStatus.FINISHED
def test_remove(authorized_client, generic_userdata):
response = api_remove(authorized_client)
data = get_data(response)["removeRepository"]
assert_ok(data)
configuration = data["configuration"]
assert configuration["provider"] == "BACKBLAZE"
assert configuration["locationId"] == ""
assert configuration["locationName"] == "selfprivacy"
# still generated every time it is missing
assert len(configuration["encryptionKey"]) > 1
assert configuration["isInitialized"] is False