diff --git a/virtsecrets/templates/create_secret_block.html b/virtsecrets/templates/create_secret_block.html
index 8ff145bb..9ab34929 100644
--- a/virtsecrets/templates/create_secret_block.html
+++ b/virtsecrets/templates/create_secret_block.html
@@ -37,8 +37,8 @@
diff --git a/virtsecrets/tests/test_create_secret.py b/virtsecrets/tests/test_create_secret.py
index cd177082..14139034 100644
--- a/virtsecrets/tests/test_create_secret.py
+++ b/virtsecrets/tests/test_create_secret.py
@@ -3,8 +3,12 @@ volume path, an iSCSI IQN or a Ceph name, and characters XML gives a meaning."""
from unittest.mock import patch
-from django.test import SimpleTestCase
-from lxml import etree
+from computes.models import Compute
+from django.contrib.auth import get_user_model
+from django.test import SimpleTestCase, TestCase
+from django.urls import reverse
+from lxml import etree, html
+from virtsecrets.forms import AddSecret
from vrtManager.virtsecrets import wvmSecrets
@@ -46,3 +50,14 @@ class SecretValueTests(SimpleTestCase):
with self.subTest(value=value), self.assertRaises(ValueError):
conn.set_secret_value("uuid", value)
secret.setValue.assert_not_called()
+
+
+class CreateSecretDialogTests(TestCase):
+ def test_the_dialog_offers_the_usage_types_the_form_takes(self):
+ compute = Compute.objects.create(name="secret-usage", hostname="localhost", login="", password="", type=4)
+ self.client.force_login(get_user_model().objects.create_superuser("usage", "usage@example.com", "pw"))
+ with patch("virtsecrets.views.wvmSecrets") as conn:
+ conn.return_value.get_secrets.return_value = []
+ response = self.client.get(reverse("virtsecrets", args=[compute.id]))
+ offered = html.fromstring(response.content).xpath("//select[@id='secret_usage_type']/option/@value")
+ self.assertEqual(offered, [value for value, _ in AddSecret.base_fields["usage_type"].choices])
diff --git a/virtsecrets/views.py b/virtsecrets/views.py
index f9f276d6..bfe62776 100644
--- a/virtsecrets/views.py
+++ b/virtsecrets/views.py
@@ -33,6 +33,8 @@ def secrets(request, compute_id):
VIR_SECRET_USAGE_TYPE_ISCSI: "iscsi",
VIR_SECRET_USAGE_TYPE_TLS: "tls",
}
+ # the create dialog offers the usage types the form takes
+ usage_choices = AddSecret.base_fields["usage_type"].choices
try:
conn = wvmSecrets(