mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
A permission 'Can back up instances' lets a user back up the VMs they may change into targets open to VM owners, restore those backups over the VM or as a new VM, and delete the backups they took by hand. Each job checks the rights at admission and again when it runs. - A backup quota (GiB, in the user's quota) counts the owner's own backups: a backup being made holds its estimate, what its disks and the files below them hold. An owner's backups run one at a time, so each run's check sees the others. - An owner restores as a new VM on the VM's compute, into its first disk's pool, within the VM quota; the job counts in it until its VM is recorded, as a clone does. - An owner's restore over the VM removes the disks it ran from once the switch is done, unless another VM uses them: the owner cannot remove them. - Recovery never begins a deletion the job had not begun. Superusers keep everything they had.
27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
"""After saving a user, the edit page goes back to ?next= only on this site."""
|
|
|
|
from django.contrib.auth.models import User
|
|
from django.test import TestCase
|
|
from django.urls import reverse
|
|
from admin.tests.edits import user_seen
|
|
|
|
LIMITS = {"role": "user", "max_instances": 1, "max_cpus": 1, "max_memory": 1, "max_disk_size": 4, "max_backup_size": 0}
|
|
|
|
|
|
class UserUpdateNextTests(TestCase):
|
|
def setUp(self):
|
|
self.client.force_login(User.objects.create_superuser("un-admin", "un@example.com", "pw"))
|
|
self.user = User.objects.create_user("un-user", password="pw")
|
|
|
|
def save(self, next_url):
|
|
url = reverse("admin:user_update", args=[self.user.id]) + "?next=" + next_url
|
|
return self.client.post(url, {"username": "un-user", "is_active": "on", "seen": user_seen(self.user), **LIMITS})
|
|
|
|
def test_a_page_of_this_site(self):
|
|
account = reverse("accounts:account", args=[self.user.id])
|
|
self.assertRedirects(self.save(account), account, fetch_redirect_response=False)
|
|
|
|
def test_another_site_is_not_followed(self):
|
|
for next_url in ("https://evil.example/", "//evil.example/", "/\\evil.example/"):
|
|
with self.subTest(next_url=next_url):
|
|
self.assertRedirects(self.save(next_url), reverse("admin:user_list"), fetch_redirect_response=False)
|