mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-13 04:44:32 +00:00
Merge branch 'master' into def/add_users_repositories
This commit is contained in:
commit
e74717d56b
selfprivacy_api
tests/test_graphql
|
@ -258,6 +258,7 @@ class Backups:
|
|||
Backups._on_new_snapshot_created(service_name, snapshot)
|
||||
if reason == BackupReason.AUTO:
|
||||
Backups._prune_auto_snaps(service)
|
||||
service.post_backup()
|
||||
except Exception as error:
|
||||
Jobs.update(job, status=JobStatus.ERROR, error=str(error))
|
||||
raise error
|
||||
|
|
|
@ -76,18 +76,20 @@ class ServiceManager(Service):
|
|||
),
|
||||
]
|
||||
|
||||
try:
|
||||
dns_records.append(
|
||||
ServiceDnsRecord(
|
||||
type="CAA",
|
||||
name=get_domain(),
|
||||
content=f'128 issue "letsencrypt.org;accounturi={read_account_uri()}"',
|
||||
ttl=3600,
|
||||
display_name="CAA record",
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(f"Error creating CAA: {e}")
|
||||
# TODO: Reenable with 3.5.0 release when clients are ready.
|
||||
# Do not forget about tests!
|
||||
# try:
|
||||
# dns_records.append(
|
||||
# ServiceDnsRecord(
|
||||
# type="CAA",
|
||||
# name=get_domain(),
|
||||
# content=f'128 issue "letsencrypt.org;accounturi={read_account_uri()}"',
|
||||
# ttl=3600,
|
||||
# display_name="CAA record",
|
||||
# )
|
||||
# )
|
||||
# except Exception as e:
|
||||
# logging.error(f"Error creating CAA: {e}")
|
||||
|
||||
for service in ServiceManager.get_enabled_services():
|
||||
dns_records += service.get_dns_records(ip4, ip6)
|
||||
|
@ -117,9 +119,7 @@ class ServiceManager(Service):
|
|||
@staticmethod
|
||||
def get_url() -> typing.Optional[str]:
|
||||
"""Return service url."""
|
||||
domain = get_domain()
|
||||
subdomain = ServiceManager.get_subdomain()
|
||||
return f"https://{subdomain}.{domain}" if subdomain else None
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_subdomain() -> typing.Optional[str]:
|
||||
|
@ -160,7 +160,8 @@ class ServiceManager(Service):
|
|||
# Stash locations as they are set by user right now
|
||||
locations = {}
|
||||
for service in services:
|
||||
locations[service.get_id()] = service.get_drive()
|
||||
if service.is_movable():
|
||||
locations[service.get_id()] = service.get_drive()
|
||||
|
||||
# Copy files
|
||||
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
|
||||
|
@ -168,9 +169,10 @@ class ServiceManager(Service):
|
|||
|
||||
# Pop locations
|
||||
for service in services:
|
||||
device = BlockDevices().get_block_device(locations[service.get_id()])
|
||||
if device is not None:
|
||||
service.set_location(device)
|
||||
if service.is_movable():
|
||||
device = BlockDevices().get_block_device(locations[service.get_id()])
|
||||
if device is not None:
|
||||
service.set_location(device)
|
||||
|
||||
@classmethod
|
||||
def stop(cls):
|
||||
|
@ -240,6 +242,10 @@ class ServiceManager(Service):
|
|||
for p in [USERDATA_FILE, SECRETS_FILE, DKIM_DIR]:
|
||||
cls.stash_a_path(p)
|
||||
|
||||
@classmethod
|
||||
def post_backup(cls):
|
||||
rmtree(cls.dump_dir(), ignore_errors=True)
|
||||
|
||||
@classmethod
|
||||
def dump_dir(cls) -> str:
|
||||
"""
|
||||
|
|
|
@ -480,6 +480,9 @@ class Service(ABC):
|
|||
def pre_backup(self):
|
||||
pass
|
||||
|
||||
def post_backup(self):
|
||||
pass
|
||||
|
||||
def post_restore(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ from selfprivacy_api.utils.default_subdomains import (
|
|||
|
||||
USERDATA_FILE = "/etc/nixos/userdata.json"
|
||||
SECRETS_FILE = "/etc/selfprivacy/secrets.json"
|
||||
DKIM_DIR = "/var/dkim/"
|
||||
DKIM_DIR = "/var/dkim"
|
||||
|
||||
ACCOUNT_PATH_PATTERN = (
|
||||
"/var/lib/acme/.lego/accounts/*/acme-v02.api.letsencrypt.org/*/account.json"
|
||||
|
|
|
@ -394,15 +394,16 @@ def test_graphql_get_domain(
|
|||
ttl=18000,
|
||||
),
|
||||
)
|
||||
assert is_dns_record_in_array(
|
||||
dns_records,
|
||||
dns_record(
|
||||
name="test-domain.tld",
|
||||
record_type="CAA",
|
||||
content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
ttl=3600,
|
||||
),
|
||||
)
|
||||
# TODO: Reenable with 3.5.0 release when clients are ready.
|
||||
# assert is_dns_record_in_array(
|
||||
# dns_records,
|
||||
# dns_record(
|
||||
# name="test-domain.tld",
|
||||
# record_type="CAA",
|
||||
# content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
# ttl=3600,
|
||||
# ),
|
||||
# )
|
||||
|
||||
|
||||
def test_dns_records_no_duplicates(
|
||||
|
@ -546,15 +547,16 @@ def test_graphql_get_domain_no_uri_account_file(
|
|||
ttl=18000,
|
||||
),
|
||||
)
|
||||
assert not is_dns_record_in_array(
|
||||
dns_records,
|
||||
dns_record(
|
||||
name="test-domain.tld",
|
||||
record_type="CAA",
|
||||
content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
ttl=3600,
|
||||
),
|
||||
)
|
||||
# TODO: Reenable with 3.5.0 release when clients are ready.
|
||||
# assert not is_dns_record_in_array(
|
||||
# dns_records,
|
||||
# dns_record(
|
||||
# name="test-domain.tld",
|
||||
# record_type="CAA",
|
||||
# content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
# ttl=3600,
|
||||
# ),
|
||||
# )
|
||||
|
||||
|
||||
def test_graphql_get_domain_not_found_account_file(
|
||||
|
@ -645,15 +647,16 @@ def test_graphql_get_domain_not_found_account_file(
|
|||
ttl=18000,
|
||||
),
|
||||
)
|
||||
assert not is_dns_record_in_array(
|
||||
dns_records,
|
||||
dns_record(
|
||||
name="test-domain.tld",
|
||||
record_type="CAA",
|
||||
content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
ttl=3600,
|
||||
),
|
||||
)
|
||||
# TODO: Reenable with 3.5.0 release when clients are ready.
|
||||
# assert not is_dns_record_in_array(
|
||||
# dns_records,
|
||||
# dns_record(
|
||||
# name="test-domain.tld",
|
||||
# record_type="CAA",
|
||||
# content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
# ttl=3600,
|
||||
# ),
|
||||
# )
|
||||
|
||||
|
||||
def test_graphql_get_domain_black_account_file(
|
||||
|
@ -744,15 +747,16 @@ def test_graphql_get_domain_black_account_file(
|
|||
ttl=18000,
|
||||
),
|
||||
)
|
||||
assert not is_dns_record_in_array(
|
||||
dns_records,
|
||||
dns_record(
|
||||
name="test-domain.tld",
|
||||
record_type="CAA",
|
||||
content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
ttl=3600,
|
||||
),
|
||||
)
|
||||
# TODO: Reenable with 3.5.0 release when clients are ready.
|
||||
# assert not is_dns_record_in_array(
|
||||
# dns_records,
|
||||
# dns_record(
|
||||
# name="test-domain.tld",
|
||||
# record_type="CAA",
|
||||
# content='128 issue "letsencrypt.org;accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/234340396"',
|
||||
# ttl=3600,
|
||||
# ),
|
||||
# )
|
||||
|
||||
|
||||
API_GET_TIMEZONE = """
|
||||
|
|
Loading…
Reference in a new issue