]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add a test case for custom port validation func
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 12 Jun 2025 19:45:16 +0000 (15:45 -0400)
committerAdam King <adking@redhat.com>
Wed, 9 Jul 2025 15:52:24 +0000 (11:52 -0400)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit e7e13ad11017968f58780472a6c7ad6df47ab21a)

src/pybind/mgr/smb/tests/test_validation.py

index 248b68966cf4790499a0937b7112208e58a85199..bdf40a67448ee8e245dac2be3b7e68452b699998 100644 (file)
@@ -130,3 +130,27 @@ def test_check_access_name(value, ok, err_match):
     else:
         with pytest.raises(ValueError, match=err_match):
             smb.validation.check_access_name(value)
+
+
+@pytest.mark.parametrize(
+    'value,err_match',
+    [
+        (None, None),
+        ({}, None),
+        ({'smb': 4455}, None),
+        ({'smb': 4455, 'smbmetrics': 9009, 'ctdb': 9999}, None),
+        ({'smb': 0}, 'invalid port'),
+        ({'smb': 1 << 16}, 'invalid port'),
+        ({'smb': 4455, 'sbmetrics': 9009}, 'invalid service names'),
+        (
+            {'smb': 4455, 'smbmetrics': 9999, 'ctdb': 9999},
+            'must not be repeated',
+        ),
+    ],
+)
+def test_check_custom_ports(value, err_match):
+    if err_match is None:
+        smb.validation.check_custom_ports(value)
+    else:
+        with pytest.raises(ValueError, match=err_match):
+            smb.validation.check_custom_ports(value)