From: John Mulligan Date: Mon, 6 May 2024 23:20:35 +0000 (-0400) Subject: mgr/smb: add validation unit tests for login names X-Git-Tag: testing/wip-rishabh-testing-20240628.135345-debug~50^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2a1a93ad499a05db5e55776296e1a02d6de5b5a9;p=ceph-ci.git mgr/smb: add validation unit tests for login names Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/tests/test_validation.py b/src/pybind/mgr/smb/tests/test_validation.py index f44c0309798..248b68966cf 100644 --- a/src/pybind/mgr/smb/tests/test_validation.py +++ b/src/pybind/mgr/smb/tests/test_validation.py @@ -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)