]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add validation unit tests for login names
authorJohn Mulligan <jmulligan@redhat.com>
Mon, 6 May 2024 23:20:35 +0000 (19:20 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 19 Jun 2024 13:29:42 +0000 (09:29 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/tests/test_validation.py

index f44c03097986da0b51858480ac42f685a06e6ea2..248b68966cf4790499a0937b7112208e58a85199 100644 (file)
@@ -110,3 +110,23 @@ def test_clean_custom_options():
     smb.validation.check_custom_options(updated)
     assert smb.validation.clean_custom_options(updated) == orig
     assert smb.validation.clean_custom_options(None) is None
+
+
+@pytest.mark.parametrize(
+    "value,ok,err_match",
+    [
+        ("tim", True, ""),
+        ("britons\\arthur", True, ""),
+        ("lance a lot", False, "spaces, tabs, or newlines"),
+        ("tabs\ta\tlot", False, "spaces, tabs, or newlines"),
+        ("bed\nivere", False, "spaces, tabs, or newlines"),
+        ("runawa" + ("y" * 122), True, ""),
+        ("runawa" + ("y" * 123), False, "128"),
+    ],
+)
+def test_check_access_name(value, ok, err_match):
+    if ok:
+        smb.validation.check_access_name(value)
+    else:
+        with pytest.raises(ValueError, match=err_match):
+            smb.validation.check_access_name(value)