Move technical manifest exports out of panel workflows
This commit is contained in:
1 parent
7b486c491b
commit
b58d683f21
14 files changed
+265
-73
No files matched your search
+4
-4
@@ -1421,7 +1421,7 @@ confirm its domain using **Retire website**. The web node archives its data
|
||||
and disables its Apache and PHP configuration. Retiring a failed provisioning request also frees its place in the plan.
|
||||
Its domain remains reserved until released with the account's names.
|
||||
|
||||
Operators can download the website's version 2 manifest. Use the existing
|
||||
Export the website's version 2 manifest with `export_manifest website`. Use the existing
|
||||
[website SFTP setup](development.md#install-sftp-keys-on-a-web-node) on the web node
|
||||
with that manifest to authorize a key for the site's own user. The web
|
||||
node suspends new SFTP logins for a suspended independent website when
|
||||
@@ -1936,9 +1936,9 @@ managed database and restore it to an empty database with the same identity.
|
||||
|
||||
## Back up an account's website and databases
|
||||
|
||||
Download an account backup manifest from the panel. Use it to create one ZIP
|
||||
Export an account backup manifest from the CLI. Use it to create one ZIP
|
||||
on a single server or bundle native archives from separate nodes. The CLI can
|
||||
also include mailbox archives when the downloaded manifest lists mailboxes.
|
||||
also include mailbox archives when the manifest lists mailboxes.
|
||||
[Account backup and recovery](development.md#back-up-a-hosting-account)
|
||||
|
||||
### Start local account backups from the panel
|
||||
@@ -2787,7 +2787,7 @@ reported failure. Operators need permission to view hosting accounts and
|
||||
mailbox requests and the **Can add mailbox provisioning** permission.
|
||||
|
||||
The initial password is kept in the root-only credentials file on the mail node.
|
||||
To locate that file, download the manifest and use the node's `apply` command.
|
||||
To locate that file, export the mailbox manifest and use the node's `apply` command.
|
||||
Reapplying the manifest preserves the password and prints the file path.
|
||||
[Show mailbox connection details in the panel](#show-local-database-and-mailbox-connection-details)
|
||||
|
||||
|
||||
+50
-25
@@ -146,14 +146,35 @@ ID, operation, resource, and time. SSH key changes record fingerprints of
|
||||
the keys added or removed. Queued changes still report their execution
|
||||
status in the hosting account.
|
||||
|
||||
## Export manifests from the command line
|
||||
|
||||
Routine provisioning and backups in the panel do not require a separate
|
||||
manifest. For manual node operations or local testing, export the matching
|
||||
resource using the panel's Django management environment.
|
||||
|
||||
```sh
|
||||
panel_manage export_manifest database 1 > coulobre-database-1.json
|
||||
panel_manage export_manifest dns-zone 1 > coulobre-zone.json
|
||||
panel_manage export_manifest mailbox 1 > coulobre-mailbox-1.json
|
||||
panel_manage export_manifest website 1 > coulobre-website-1.json
|
||||
panel_manage export_manifest apache-preview 1 > coulobre-web-plan-1.json
|
||||
panel_manage export_manifest account-backup 1 --include-mail > account.json
|
||||
```
|
||||
|
||||
Replace `1` with the ID of the matching database, DNS zone, mailbox,
|
||||
independent website, Apache preview, or hosting account. Use the
|
||||
[`panel_manage` helper](deployment.md#prepare-the-panel) on an installed
|
||||
server, or `python manage.py` in a development checkout. The command only
|
||||
exports metadata and does not apply changes or create a backup.
|
||||
|
||||
## Request a MariaDB database
|
||||
|
||||
Open a hosting account and select **Request database**. Choose a short suffix
|
||||
such as `wordpress`. The panel derives the full database name from the account
|
||||
ID and suffix, so two accounts can each request a database named `wordpress`.
|
||||
|
||||
The account page shows the requested databases. Operators can download a
|
||||
versioned deployment manifest containing the account ID and suffix. Managers
|
||||
The account page shows the requested databases. The CLI manifest contains the
|
||||
account ID and suffix. Managers
|
||||
can view the requested database names on their own assigned accounts. The
|
||||
manifest describes the database to provision on a MariaDB node.
|
||||
|
||||
@@ -168,7 +189,7 @@ coulobre-database-node inspect coulobre-database-1.json
|
||||
|
||||
Use a local MariaDB server with Unix socket authentication for
|
||||
`root@localhost`. Install Coulobre with the `mariadb` extra in a root-owned
|
||||
virtual environment and apply the downloaded manifest on that server.
|
||||
virtual environment and apply the exported manifest on that server.
|
||||
|
||||
```sh
|
||||
sudo /opt/coulobre/bin/coulobre-database-node apply coulobre-database-1.json
|
||||
@@ -286,11 +307,11 @@ Use `@` for the zone domain in either field. Use fully qualified names
|
||||
for other records. The panel increments the SOA serial when the zone data
|
||||
changes. Changing the account's primary domain preserves its existing DNS zones.
|
||||
|
||||
Select **Download manifest** in the DNS table and copy the file to the
|
||||
hosting server or a separate DNS node. Managers can see the configured
|
||||
domains and serials for their assigned accounts. Operators with the
|
||||
appropriate permissions can add and edit zones and download manifests.
|
||||
The panel exports version 2 for zones containing MX or TXT records and
|
||||
Export the zone using the CLI and copy the file to the hosting server or a
|
||||
separate DNS node. Managers can see the configured domains and serials for
|
||||
their assigned accounts. Operators with the appropriate permissions can add
|
||||
and edit zones in the panel.
|
||||
Coulobre exports version 2 for zones containing MX or TXT records and
|
||||
version 1 for other zones.
|
||||
|
||||
A manifest can also be written directly for local testing. Save the
|
||||
@@ -391,7 +412,7 @@ sudo /opt/coulobre/bin/coulobre-dns-node apply coulobre-zone.json
|
||||
|
||||
Coulobre validates the zone with `named-checkzone` and installs it under
|
||||
`/etc/bind/coulobre/`. BIND9 persists the primary zone registration through
|
||||
`rndc addzone`. To publish an edit, download the updated manifest and apply
|
||||
`rndc addzone`. To publish an edit manually, export the updated manifest and apply
|
||||
it again. Coulobre checks the SOA serial, reloads the individual zone, and
|
||||
waits for BIND9 to report the requested serial. Reapply the same manifest to
|
||||
resume after an interrupted reload. See the [BIND9 command reference](https://bind9.readthedocs.io/en/v9.18.39/manpages.html#rndc) and [RFC 1982](https://www.rfc-editor.org/rfc/rfc1982.html).
|
||||
@@ -425,8 +446,8 @@ the `@`, such as `support`. The panel uses the account's primary domain,
|
||||
lowercases the local part, and converts the domain to its ASCII DNS form.
|
||||
Existing mailbox requests keep their addresses when the primary domain changes.
|
||||
|
||||
The **Mailbox requests** table shows the email addresses. Operators can
|
||||
download a versioned manifest that contains the domain and local part.
|
||||
The **Mailbox requests** table shows the email addresses. The CLI export
|
||||
contains the domain and local part.
|
||||
Managers can see mailbox requests on their assigned accounts.
|
||||
Version 2 adds `quota_mib` for mailboxes with a storage limit. Version 1
|
||||
manifests continue to apply with no Coulobre storage limit.
|
||||
@@ -571,7 +592,7 @@ mailbox already provisioned through the panel, saving queues an update on
|
||||
the local mail node. Use **Retry provisioning** to retry a failed update
|
||||
before setting another limit.
|
||||
|
||||
For a mailbox provisioned manually, download its updated manifest and run
|
||||
For a mailbox provisioned manually, export its updated manifest and run
|
||||
the following command on the mail node.
|
||||
|
||||
```sh
|
||||
@@ -609,7 +630,7 @@ running the check without root privileges.
|
||||
|
||||
### Back up and restore a mailbox
|
||||
|
||||
Download the mailbox manifest from the panel and run the backup on the node
|
||||
Export the mailbox manifest and run the backup on the node
|
||||
that hosts the mailbox. Use a new archive name in a root-controlled directory.
|
||||
|
||||
```sh
|
||||
@@ -734,8 +755,8 @@ python manage.py import_directadmin user.admin.customer.tar.zst
|
||||
The import checks domain ownership again and creates the new hosting account,
|
||||
supported database requests and selected domain's mailbox requests in one
|
||||
transaction. The JSON report includes the new account ID and the MariaDB
|
||||
names derived from the database requests. Use the account page to download
|
||||
deployment manifests for the nodes. The `manual_review` list records the
|
||||
names derived from the database requests. Use the CLI to export deployment
|
||||
manifests for the nodes. The `manual_review` list records the
|
||||
website, DNS, mail and SQL data to review before completing the separate
|
||||
restore steps below.
|
||||
|
||||
@@ -890,8 +911,8 @@ are eligible for delivery again.
|
||||
|
||||
## Render configuration on a web node
|
||||
|
||||
Open a completed preview for the account's current domain and select **Download
|
||||
deployment manifest**. The versioned JSON file contains the account ID and
|
||||
Export a completed preview for the account's current domain with
|
||||
`export_manifest apache-preview`. The versioned JSON file contains the account ID and
|
||||
primary domain. The web node command validates those values and derives the
|
||||
system user, document root, and PHP-FPM socket from the account ID.
|
||||
|
||||
@@ -1188,11 +1209,10 @@ backup. The website can be recovered while its web services are stopped.
|
||||
|
||||
## Back up a hosting account
|
||||
|
||||
Open the account as an operator and select **Download backup manifest**. The
|
||||
manifest lists the primary website and all database requests for the account.
|
||||
Select **Download backup manifest with mail** to also include mailbox requests
|
||||
from every mail domain assigned to the account. This option requires permission
|
||||
to view mailbox requests. Provision all listed resources before running the
|
||||
Export the backup manifest with `export_manifest account-backup`. It lists the
|
||||
website and database resources for the account. Pass `--include-mail` to also
|
||||
include mailbox requests from every mail domain assigned to the account.
|
||||
Provision all listed resources before running the
|
||||
backup. The ZIP contains the native website archive, a compressed SQL dump for
|
||||
each listed database, and the requested mailbox archives. Back up DNS and panel
|
||||
settings separately.
|
||||
@@ -1272,13 +1292,18 @@ continue to unpack with the same filenames.
|
||||
|
||||
## Run an isolated PHP test site
|
||||
|
||||
Open a completed preview for the account's current domain and select **Download
|
||||
test bundle**. The archive contains the exact Apache preview, a matching PHP-FPM
|
||||
Export a completed preview for the account's current domain to a new tar file.
|
||||
|
||||
```sh
|
||||
python manage.py export_manifest apache-preview 1 --smoke-bundle coulobre-web-plan-1.tar
|
||||
```
|
||||
|
||||
The archive contains the exact Apache preview, a matching PHP-FPM
|
||||
pool, site metadata, and a small PHP test page. It is intended for the isolated
|
||||
Ubuntu check below.
|
||||
|
||||
Run the test with Docker from the repository root. Set the bundle path to the
|
||||
downloaded tar archive.
|
||||
exported tar archive.
|
||||
|
||||
```sh
|
||||
docker build -t coulobre-web-smoke tests/web-node
|
||||
|
||||
@@ -32,6 +32,9 @@ only use shared components available in its supported Core versions.
|
||||
time-stamped events and snapshots. Label historical details explicitly
|
||||
and keep live actions on the current resource or in a dedicated workflow.
|
||||
Keep history scoped to the viewer’s role, especially internal config.
|
||||
- Keep low-level provisioning manifests and developer test bundles out of
|
||||
routine panel actions. Document their CLI export instead. Keep meaningful
|
||||
user downloads, such as backup archives, in the relevant workflow.
|
||||
- Use `.surface` for sections, `.section-heading` for ordinary section
|
||||
headers, and `.table-scroll` around tables. Keep horizontal overflow in
|
||||
the table wrapper and give empty or pending states an explicit label.
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from ...account_backups import account_backup_manifest
|
||||
from ...models import (
|
||||
HostingAccount,
|
||||
HostingDatabase,
|
||||
HostingDnsZone,
|
||||
HostingMailbox,
|
||||
IndependentWebsite,
|
||||
WebProvisioningPlan,
|
||||
)
|
||||
from ...web_node import build_web_smoke_bundle, serialize_deployment_manifest
|
||||
|
||||
RESOURCE_MODELS = {
|
||||
"account-backup": HostingAccount,
|
||||
"database": HostingDatabase,
|
||||
"dns-zone": HostingDnsZone,
|
||||
"mailbox": HostingMailbox,
|
||||
"website": IndependentWebsite,
|
||||
"apache-preview": WebProvisioningPlan,
|
||||
}
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Export a Coulobre provisioning or backup manifest as JSON."
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("resource", choices=RESOURCE_MODELS)
|
||||
parser.add_argument("id", type=int)
|
||||
parser.add_argument("--include-mail", action="store_true")
|
||||
parser.add_argument("--smoke-bundle", type=Path, metavar="TAR")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
resource = options["resource"]
|
||||
record_id = options["id"]
|
||||
include_mail = options["include_mail"]
|
||||
bundle = options["smoke_bundle"]
|
||||
if include_mail and resource != "account-backup":
|
||||
raise CommandError("--include-mail requires account-backup.")
|
||||
if bundle and resource != "apache-preview":
|
||||
raise CommandError("--smoke-bundle requires apache-preview.")
|
||||
if not 0 < record_id < 2**63:
|
||||
raise CommandError("Enter a positive 64-bit resource ID.")
|
||||
|
||||
model = RESOURCE_MODELS[resource]
|
||||
try:
|
||||
record = model.objects.get(pk=record_id)
|
||||
except model.DoesNotExist as error:
|
||||
raise CommandError(
|
||||
f"No {resource} with ID {record_id}."
|
||||
) from error
|
||||
|
||||
if resource == "apache-preview":
|
||||
if not record.can_export:
|
||||
raise CommandError(
|
||||
"Select a completed preview for the current domain."
|
||||
)
|
||||
if bundle:
|
||||
self.write_bundle(record, bundle)
|
||||
return
|
||||
return serialize_deployment_manifest(record)
|
||||
if resource == "account-backup":
|
||||
if record.retired_at:
|
||||
raise CommandError("Select an active hosting account.")
|
||||
manifest = account_backup_manifest(
|
||||
record, include_mailboxes=include_mail
|
||||
)
|
||||
else:
|
||||
manifest = record.spec.manifest()
|
||||
return json.dumps(manifest, indent=2)
|
||||
|
||||
def write_bundle(self, plan, path):
|
||||
data = build_web_smoke_bundle(plan)
|
||||
try:
|
||||
with path.open("xb") as output:
|
||||
output.write(data)
|
||||
except OSError as error:
|
||||
raise CommandError(
|
||||
f"Could not write the bundle: {error}"
|
||||
) from error
|
||||
@@ -18,7 +18,7 @@
|
||||
{% if is_tenant or perms.hosting.view_hostingdnszone %}<a href="#domains-dns">Domains and DNS</a>{% endif %}
|
||||
{% if is_tenant or perms.hosting.view_hostingmailbox %}<a href="#email">Email</a>{% endif %}
|
||||
{% if is_tenant or perms.hosting.view_hostingdatabase %}<a href="#databases">Databases</a>{% endif %}
|
||||
{% if show_account_backups or export_backup_manifest %}<a href="#backups">Backups</a>{% endif %}
|
||||
{% if show_account_backups %}<a href="#backups">Backups</a>{% endif %}
|
||||
{% if can_change_hosting_services or service_change or can_retire_account or is_operator and perms.hosting.change_hostingaccount %}<a href="#account-management">Account management</a>{% endif %}
|
||||
<a href="#history">History</a>
|
||||
</nav>
|
||||
@@ -174,9 +174,6 @@
|
||||
<button class="button secondary compact" type="submit">Open phpMyAdmin</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if is_operator %}
|
||||
<a class="button secondary compact" href="{% url 'panel:database_manifest' database.pk %}" aria-label="Download manifest for {{ database }}">Download manifest</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if is_operator and manage_database_provisioning and database.provisioning.problem %}
|
||||
<p class="heading-meta">{{ database.provisioning.problem }}</p>
|
||||
@@ -224,7 +221,6 @@
|
||||
{% if is_operator %}
|
||||
<td>
|
||||
<div class="form-actions">
|
||||
<a class="button secondary compact" href="{% url 'panel:dns_zone_manifest' zone.pk %}" aria-label="Download DNS manifest for {{ zone.domain }}">Download manifest</a>
|
||||
{% if show_dns_replication %}
|
||||
<a class="button secondary compact" href="{% url 'panel:dns_replication' zone.pk %}">Check replication</a>
|
||||
{% endif %}
|
||||
@@ -366,9 +362,6 @@
|
||||
{% if show_mailbox_credentials %}
|
||||
<a class="button secondary compact" href="{% url 'panel:mailbox_credentials' mailbox.pk %}" aria-label="Connection details for {{ mailbox }}">Connection details</a>
|
||||
{% endif %}
|
||||
{% if is_operator %}
|
||||
<a class="button secondary compact" href="{% url 'panel:mailbox_manifest' mailbox.pk %}" aria-label="Download mailbox manifest for {{ mailbox }}">Download manifest</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% include "hosting/mailbox_management_links.html" %}
|
||||
</div>
|
||||
@@ -402,19 +395,9 @@
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% if show_account_backups or export_backup_manifest %}
|
||||
{% if show_account_backups %}
|
||||
<section class="account-content" id="backups" data-account-section tabindex="-1" aria-label="Backups">
|
||||
{% if export_backup_manifest %}
|
||||
<div class="form-actions account-actions">
|
||||
{% if export_backup_manifest %}
|
||||
<a class="button secondary" href="{% url 'panel:account_backup_manifest' account.pk %}">Download backup manifest</a>
|
||||
{% endif %}
|
||||
{% if export_mail_backup_manifest %}
|
||||
<a class="button secondary" href="{% url 'panel:account_backup_manifest' account.pk %}?include_mail=1">Download backup manifest with mail</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if show_account_backups %}{% include "hosting/account_backups.html" %}{% endif %}
|
||||
{% include "hosting/account_backups.html" %}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -33,9 +33,6 @@
|
||||
{% if action.value == 'settings' %}<a class="button secondary compact" href="{% url 'panel:independent_php_settings' account.pk website.pk %}">{{ action.label }}</a>
|
||||
{% else %}<a class="button {% if action.value == 'retire' %}danger{% else %}secondary{% endif %} compact" href="{% url 'panel:independent_website_operation' account.pk website.pk action.value %}">{{ action.label }}</a>{% endif %}
|
||||
{% endfor %}
|
||||
{% if is_operator and perms.hosting.view_hostingaccount %}
|
||||
<a class="button secondary compact" href="{% url 'panel:independent_website_manifest' account.pk website.pk %}">Download manifest</a>
|
||||
{% endif %}
|
||||
</div></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -44,12 +44,8 @@
|
||||
<h2 id="configuration-heading">{% if plan_mode == "current" %}Primary HTTP virtual host{% else %}Virtual host configuration{% endif %}</h2>
|
||||
{% if plan_mode == "current" %}<p class="heading-meta">Coulobre’s recorded configuration. HTTPS and alias configuration are managed separately.</p>{% endif %}
|
||||
</div>
|
||||
{% if plan_mode != "history" and not is_reseller and plan.can_export %}
|
||||
<div class="form-actions">
|
||||
{% if may_manage_https %}<a class="button secondary" href="{% url 'panel:website_https' plan.account_id %}">Manage HTTPS</a>{% endif %}
|
||||
<a class="button secondary" href="{% url 'panel:download_deployment_manifest' plan.pk %}">Download deployment manifest</a>
|
||||
<a class="button secondary" href="{% url 'panel:download_smoke_bundle' plan.pk %}">Download test bundle</a>
|
||||
</div>
|
||||
{% if may_manage_https %}
|
||||
<a class="button secondary" href="{% url 'panel:website_https' plan.account_id %}">Manage HTTPS</a>
|
||||
{% endif %}
|
||||
</header>
|
||||
<pre class="configuration"><code>{{ plan.apache_config }}</code></pre>
|
||||
|
||||
@@ -83,7 +83,7 @@ class AccountBackupManifestTests(TestCase):
|
||||
(self.cms.spec, self.shop.spec),
|
||||
),
|
||||
)
|
||||
self.assertContains(
|
||||
self.assertNotContains(
|
||||
self.client.get(self.account.get_absolute_url()), self.url
|
||||
)
|
||||
|
||||
@@ -141,7 +141,7 @@ class AccountBackupManifestTests(TestCase):
|
||||
AccountBackup.from_manifest(response.json()).mailboxes,
|
||||
(old_mailbox.spec, current_mailbox.spec),
|
||||
)
|
||||
self.assertContains(
|
||||
self.assertNotContains(
|
||||
self.client.get(self.account.get_absolute_url()),
|
||||
"Download backup manifest with mail",
|
||||
)
|
||||
|
||||
@@ -121,7 +121,7 @@ class DatabaseProvisioningTests(TestCase):
|
||||
def test_disabled_provisioning_preserves_existing_manifest_download(self):
|
||||
detail = self.client.get(self.detail)
|
||||
self.assertNotContains(detail, "Provision database")
|
||||
self.assertContains(detail, "Download manifest")
|
||||
self.assertNotContains(detail, "Download manifest")
|
||||
self.assertEqual(self.client.post(self.url).status_code, 404)
|
||||
|
||||
def test_operator_can_retry_a_failed_request(self):
|
||||
|
||||
@@ -391,7 +391,7 @@ class DnsZonePanelTests(TestCase):
|
||||
zone = self.create_zone()
|
||||
self.client.force_login(self.reader)
|
||||
account = self.client.get(self.account.get_absolute_url())
|
||||
self.assertContains(account, "Download DNS manifest")
|
||||
self.assertNotContains(account, "Download DNS manifest")
|
||||
self.assertNotContains(account, "Edit DNS zone")
|
||||
self.assertContains(
|
||||
self.client.get(
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import json
|
||||
import tarfile
|
||||
from io import StringIO
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from django.core.management import CommandError, call_command
|
||||
from django.test import TestCase
|
||||
|
||||
from .models import (
|
||||
HostingAccount,
|
||||
HostingDatabase,
|
||||
HostingDnsZone,
|
||||
HostingMailbox,
|
||||
HostingMailDomain,
|
||||
IndependentWebsite,
|
||||
WebProvisioningPlan,
|
||||
WebsiteDomain,
|
||||
)
|
||||
from .tasks import render_web_plan
|
||||
|
||||
|
||||
class ExportManifestTests(TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.account = HostingAccount.objects.create(
|
||||
name="Example", primary_domain="example.net"
|
||||
)
|
||||
cls.database = HostingDatabase.objects.create(
|
||||
account=cls.account, suffix="cms"
|
||||
)
|
||||
domain = HostingMailDomain.objects.create(
|
||||
account=cls.account, domain=cls.account.primary_domain
|
||||
)
|
||||
cls.mailbox = HostingMailbox.objects.create(
|
||||
mail_domain=domain, local_part="contact"
|
||||
)
|
||||
cls.zone = HostingDnsZone.objects.create(
|
||||
account=cls.account,
|
||||
domain=cls.account.primary_domain,
|
||||
responsible_name="hostmaster.example.net",
|
||||
nameservers=["ns1.provider.example", "ns2.provider.example"],
|
||||
)
|
||||
cls.website = IndependentWebsite.objects.create(
|
||||
reservation=WebsiteDomain.objects.create(
|
||||
account=cls.account, domain="blog.example.net"
|
||||
)
|
||||
)
|
||||
cls.preview = WebProvisioningPlan.for_account(cls.account)
|
||||
cls.preview.save()
|
||||
|
||||
def export(self, resource, pk, *args):
|
||||
result = StringIO()
|
||||
call_command(
|
||||
"export_manifest", resource, str(pk), *args, stdout=result
|
||||
)
|
||||
return json.loads(result.getvalue())
|
||||
|
||||
def test_provisioning_exports_match_their_manifest_format(self):
|
||||
for resource, model in (
|
||||
("database", self.database),
|
||||
("dns-zone", self.zone),
|
||||
("mailbox", self.mailbox),
|
||||
("website", self.website),
|
||||
):
|
||||
with self.subTest(resource=resource):
|
||||
self.assertEqual(
|
||||
self.export(resource, model.pk), model.spec.manifest()
|
||||
)
|
||||
|
||||
def test_backup_manifest_can_include_requested_mailboxes(self):
|
||||
self.assertNotIn(
|
||||
"mailboxes", self.export("account-backup", self.account.pk)
|
||||
)
|
||||
self.assertEqual(
|
||||
self.export("account-backup", self.account.pk, "--include-mail")[
|
||||
"mailboxes"
|
||||
],
|
||||
[self.mailbox.spec.manifest()],
|
||||
)
|
||||
|
||||
def test_preview_must_be_ready_and_bundle_cannot_replace_a_file(self):
|
||||
with self.assertRaisesMessage(CommandError, "completed preview"):
|
||||
self.export("apache-preview", self.preview.pk)
|
||||
render_web_plan.run(self.preview.pk)
|
||||
self.assertEqual(
|
||||
self.export("apache-preview", self.preview.pk)["domain"],
|
||||
"example.net",
|
||||
)
|
||||
with TemporaryDirectory() as directory:
|
||||
path = Path(directory, "test.tar")
|
||||
args = (
|
||||
"apache-preview",
|
||||
str(self.preview.pk),
|
||||
"--smoke-bundle",
|
||||
str(path),
|
||||
)
|
||||
call_command("export_manifest", *args)
|
||||
with tarfile.open(path) as archive:
|
||||
self.assertIn("apache.conf", archive.getnames())
|
||||
with self.assertRaisesMessage(CommandError, "Could not write"):
|
||||
call_command("export_manifest", *args)
|
||||
@@ -82,6 +82,7 @@ class MailboxImportTests(TestCase):
|
||||
email = reverse("panel:domain_workspace", args=[account.pk, "email"])
|
||||
for path in (email, account.get_absolute_url()):
|
||||
response = self.client.get(path, secure=True)
|
||||
self.assertNotContains(response, "View import result")
|
||||
for name, label, variant in (
|
||||
("mailbox_import", "Import mail", "secondary"),
|
||||
(
|
||||
@@ -126,11 +127,19 @@ class MailboxImportTests(TestCase):
|
||||
job.finished_at = timezone.now()
|
||||
job.problem = "Check your source password."
|
||||
job.save(update_fields=["finished_at", "problem"])
|
||||
self.assertContains(self.client.get(email), "Import needs attention")
|
||||
for path in (email, account.get_absolute_url()):
|
||||
response = self.client.get(path)
|
||||
self.assertContains(response, "Import needs attention")
|
||||
self.assertContains(response, ">Review import</a>")
|
||||
self.assertNotContains(response, "View import result")
|
||||
job.problem = ""
|
||||
job.save(update_fields=["problem"])
|
||||
self.assertContains(self.client.get(email), "Import complete")
|
||||
self.assertNotContains(self.client.get(email), "Import in progress")
|
||||
for path in (email, account.get_absolute_url()):
|
||||
response = self.client.get(path)
|
||||
self.assertContains(response, "Import complete")
|
||||
self.assertContains(response, ">View import result</a>", count=1)
|
||||
self.assertContains(response, ">Import mail</a>", count=1)
|
||||
self.assertNotContains(response, "Import in progress")
|
||||
|
||||
def test_only_the_owner_and_authorized_operator_can_start_import(self):
|
||||
self.sign_in(self.stranger)
|
||||
|
||||
@@ -39,7 +39,7 @@ class WebSmokeBundleTests(TestCase):
|
||||
render_web_plan.run(self.plan.pk)
|
||||
|
||||
detail = self.client.get(reverse("panel:plan", args=[self.plan.pk]))
|
||||
self.assertContains(detail, "Download test bundle")
|
||||
self.assertNotContains(detail, "Download test bundle")
|
||||
response = self.client.get(self.download)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response["Content-Type"], "application/x-tar")
|
||||
@@ -96,7 +96,7 @@ class WebSmokeBundleTests(TestCase):
|
||||
render_web_plan.run(self.plan.pk)
|
||||
|
||||
detail = self.client.get(reverse("panel:plan", args=[self.plan.pk]))
|
||||
self.assertContains(detail, "Download deployment manifest")
|
||||
self.assertNotContains(detail, "Download deployment manifest")
|
||||
response = self.client.get(self.manifest)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn(".json", response["Content-Disposition"])
|
||||
|
||||
@@ -824,12 +824,6 @@ class AccountDetail(TenantScopeMixin, PermissionRequiredMixin, DetailView):
|
||||
context["can_enable_alias_https"] = panel_feature_allowed(
|
||||
"LOCAL_WEB_HTTPS"
|
||||
) and user.has_perms(ENABLE_WEB_HTTPS)
|
||||
context["export_backup_manifest"] = not tenant and user.has_perms(
|
||||
EXPORT_BACKUP_MANIFEST
|
||||
)
|
||||
context["export_mail_backup_manifest"] = context[
|
||||
"export_backup_manifest"
|
||||
] and user.has_perm(VIEW_MAILBOXES)
|
||||
if (
|
||||
settings.LOCAL_ACCOUNT_BACKUPS
|
||||
and not tenant
|
||||
|
||||
Reference in new issue
Block a user