From: John Mulligan Date: Thu, 12 Jun 2025 19:45:16 +0000 (-0400) Subject: mgr/smb: add a test case for custom port validation func X-Git-Tag: v20.1.0~42^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=83fe948b4c6c77d2fca3c1d0e77bca98ced58bf8;p=ceph.git mgr/smb: add a test case for custom port validation func Signed-off-by: John Mulligan (cherry picked from commit e7e13ad11017968f58780472a6c7ad6df47ab21a) --- diff --git a/src/pybind/mgr/smb/tests/test_validation.py b/src/pybind/mgr/smb/tests/test_validation.py index 248b68966cf4..bdf40a67448e 100644 --- a/src/pybind/mgr/smb/tests/test_validation.py +++ b/src/pybind/mgr/smb/tests/test_validation.py @@ -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)