Compare commits

..

5 Commits

Author SHA1 Message Date
Inex Code a742e66cc3 feat: Add "OTHER" as a server provider
continuous-integration/drone/push Build is passing Details
We should allow manual SelfPrivacy installations on unsupported server providers. The ServerProvider enum is one of the gatekeepers that prevent this and we can change it easily as not much server-side logic rely on this.

The next step would be manual DNS management, but it would be much more involved than just adding the enum value.
2024-05-25 14:12:51 +03:00
Inex Code 4f1d44ce74 chore: Bump version to 3.2.1
continuous-integration/drone/push Build is passing Details
2024-05-24 22:53:58 +03:00
Houkime 8e8e76a954 fix(backups): fix orphaned snapshots erroring out
continuous-integration/drone/push Build is passing Details
2024-05-24 12:30:27 +00:00
Inex Code 5a100ec33a chore: Bump version to 3.2.0
continuous-integration/drone/push Build is passing Details
2024-05-22 10:57:59 +03:00
Inex Code 524adaa8bc add nix-collect-garbage endpoint (#112)
continuous-integration/drone/push Build is passing Details
Continuation of the broken #21

Co-authored-by: dettlaff <dettlaff@riseup.net>
Co-authored-by: def <dettlaff@riseup.net>
Co-authored-by: Houkime <>
Reviewed-on: #112
Reviewed-by: houkime <houkime@protonmail.com>
2024-05-01 16:10:39 +03:00
6 changed files with 52 additions and 20 deletions

View File

@ -27,4 +27,4 @@ async def get_token_header(
def get_api_version() -> str:
"""Get API version"""
return "3.1.0"
return "3.2.1"

View File

@ -34,6 +34,24 @@ class BackupConfiguration:
location_id: typing.Optional[str]
# TODO: Ideally this should not be done in API but making an internal Service requires more work
# than to make an API record about a service
def tombstone_service(service_id: str) -> Service:
return Service(
id=service_id,
display_name=f"{service_id} (Orphaned)",
description="",
svg_icon="",
is_movable=False,
is_required=False,
is_enabled=False,
status=ServiceStatusEnum.OFF,
url=None,
can_be_backed_up=False,
backup_description="",
)
@strawberry.type
class Backup:
@strawberry.field
@ -55,27 +73,21 @@ class Backup:
result = []
snapshots = Backups.get_all_snapshots()
for snap in snapshots:
api_service = None
service = get_service_by_id(snap.service_name)
if service is None:
service = Service(
id=snap.service_name,
display_name=f"{snap.service_name} (Orphaned)",
description="",
svg_icon="",
is_movable=False,
is_required=False,
is_enabled=False,
status=ServiceStatusEnum.OFF,
url=None,
dns_records=None,
can_be_backed_up=False,
backup_description="",
)
api_service = tombstone_service(snap.service_name)
else:
service = service_to_graphql_service(service)
api_service = service_to_graphql_service(service)
if api_service is None:
raise NotImplementedError(
f"Could not construct API Service record for:{snap.service_name}. This should be unreachable and is a bug if you see it."
)
graphql_snap = SnapshotInfo(
id=snap.id,
service=service,
service=api_service,
created_at=snap.created_at,
reason=snap.reason,
)

View File

@ -14,6 +14,7 @@ class DnsProvider(Enum):
class ServerProvider(Enum):
HETZNER = "HETZNER"
DIGITALOCEAN = "DIGITALOCEAN"
OTHER = "OTHER"
@strawberry.enum

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name="selfprivacy_api",
version="3.1.0",
version="3.2.1",
packages=find_packages(),
scripts=[
"selfprivacy_api/app.py",

View File

@ -208,5 +208,7 @@ def dummy_service(
service.enable()
yield service
# cleanup because apparently it matters wrt tasks
services.services.remove(service)
# Cleanup because apparently it matters wrt tasks
# Some tests may remove it from the list intentionally, this is fine
if service in services.services:
services.services.remove(service)

View File

@ -3,6 +3,8 @@ from tests.test_backup import backups
from tests.common import generate_backup_query
import selfprivacy_api.services as all_services
from selfprivacy_api.services import get_service_by_id
from selfprivacy_api.graphql.common_types.service import service_to_graphql_service
from selfprivacy_api.graphql.common_types.backup import (
_AutobackupQuotas,
@ -143,6 +145,7 @@ allSnapshots {
id
service {
id
displayName
}
createdAt
reason
@ -306,6 +309,20 @@ def test_snapshots_empty(authorized_client, dummy_service, backups):
assert snaps == []
def test_snapshots_orphaned_service(authorized_client, dummy_service, backups):
api_backup(authorized_client, dummy_service)
snaps = api_snapshots(authorized_client)
assert len(snaps) == 1
all_services.services.remove(dummy_service)
assert get_service_by_id(dummy_service.get_id()) is None
snaps = api_snapshots(authorized_client)
assert len(snaps) == 1
assert "Orphaned" in snaps[0]["service"]["displayName"]
assert dummy_service.get_id() in snaps[0]["service"]["displayName"]
def test_start_backup(authorized_client, dummy_service, backups):
response = api_backup(authorized_client, dummy_service)
data = get_data(response)["backup"]["startBackup"]