Exemplo n.º 1
0
 def test_validation_nonauto_ef(self):
     rreq = RunRequest(
         auto_generated_id=None,
         owner=self.get_user(self.USER_1),
         type=RunRequest.TYPE_EFI,
         efi_application="/somewhere.efi",
     )
     rreq.full_clean()
     self.assertEqual(str(rreq), "Unnamed runrequest")
Exemplo n.º 2
0
 def test_validation_nonauto_ok(self):
     RunRequest(
         auto_generated_id=None,
         owner=self.get_user(self.USER_1),
         type=RunRequest.TYPE_ONLINE_KERNEL,
         kernel_url="http://nowhere.world/",
         initrd_url="http://nowhere.world/",
     ).full_clean()
Exemplo n.º 3
0
 def test_validation_nonauto_ef_require_app(self):
     with self.assertRaises(ValidationError) as ex:
         RunRequest(
             auto_generated_id=None,
             owner=self.get_user(self.USER_1),
             type=RunRequest.TYPE_EFI,
             efi_application=None,
         ).full_clean()
     self.assertEqual(len(ex.exception.messages), 1)
Exemplo n.º 4
0
 def test_validation_nonauto_require_owner(self):
     with self.assertRaises(ValidationError) as ex:
         RunRequest(
             auto_generated_id=None,
             owner=None,
             type=RunRequest.TYPE_EFI,
             efi_application="/somewhere.efi",
         ).full_clean()
     self.assertEqual(len(ex.exception.messages), 1)
Exemplo n.º 5
0
 def test_validation_nonauto_invalid_type(self):
     with self.assertRaises(ValidationError) as ex:
         RunRequest(
             auto_generated_id=None,
             owner=self.get_user(self.USER_1),
             type="--",
             efi_application="/somewhere.efi",
         ).full_clean()
     self.assertEqual(len(ex.exception.messages), 2)
     self.assertIn("Invalid runreq type", ex.exception.messages)
Exemplo n.º 6
0
 def test_validation_nonauto_ok_require_initrd_url(self):
     with self.assertRaises(ValidationError) as ex:
         RunRequest(
             auto_generated_id=None,
             owner=self.get_user(self.USER_1),
             type=RunRequest.TYPE_ONLINE_KERNEL,
             kernel_url="http://nowhere.world/",
             initrd_url=None,
         ).full_clean()
     self.assertEqual(len(ex.exception.messages), 1)
Exemplo n.º 7
0
 def test_settings(self):
     rreq = RunRequest(
         auto_generated_id=None,
         owner=self.get_user(self.USER_1),
         type=RunRequest.TYPE_EFI,
         efi_application="/somewhere.efi",
         raw_settings=json.dumps({
             "foo": "bar",
             "baz": {
                 "bar": "foo"
             }
         }),
     )
     self.assertEqual(rreq.settings.foo, "bar")
     self.assertEqual(rreq.settings.baz.bar, "foo")
Exemplo n.º 8
0
def new_runreq(request, mac_addr):
    device = get_object_or_404(Device, mac_address=mac_addr.upper())

    if request.method == "POST":
        rrid = request.POST["runrequest"]
        runreq = get_object_or_404(RunRequest, id=rrid)
        if not request.user.has_perm(RunRequest.get_perm("use"), runreq):
            raise Http404()
        device.run_request = runreq
        device.full_clean()
        device.save()
        return redirect("portal_devices")

    runreqs = RunRequest.objects.filter(auto_generated_id__isnull=False)

    return render(request, "portal/runreq.html", {
        "device": device,
        "runreqs": runreqs
    })