From: John Mulligan Date: Thu, 9 May 2024 18:29:28 +0000 (-0400) Subject: mgr/smb: add test coverage for show command X-Git-Tag: v20.0.0~1619^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F57394%2Fhead;p=ceph.git mgr/smb: add test coverage for show command Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/tests/test_smb.py b/src/pybind/mgr/smb/tests/test_smb.py index cf788e1562175..4ee55e0aa90d1 100644 --- a/src/pybind/mgr/smb/tests/test_smb.py +++ b/src/pybind/mgr/smb/tests/test_smb.py @@ -667,3 +667,73 @@ domain_settings: ref: foo """.strip() ) + + +def test_apply_invalid_res(tmodule): + result = tmodule.apply_resources( + """ +resource_type: ceph.smb.cluster +cluster_id: "" +auth_mode: doop +""" + ) + assert not result.success + assert 'doop' in result.to_simplified()['results'][0]['msg'] + + +def test_show_all(tmodule): + _example_cfg_1(tmodule) + out = tmodule.show() + assert 'resources' in out + res = out['resources'] + assert len(res) == 4 + assert {r['resource_type'] for r in res} == { + 'ceph.smb.cluster', + 'ceph.smb.share', + 'ceph.smb.join.auth', + } + + +def test_show_shares(tmodule): + _example_cfg_1(tmodule) + out = tmodule.show(['ceph.smb.share']) + assert 'resources' in out + res = out['resources'] + assert len(res) == 2 + assert {r['resource_type'] for r in res} == { + 'ceph.smb.share', + } + + +def test_show_shares_in_cluster(tmodule): + _example_cfg_1(tmodule) + out = tmodule.show(['ceph.smb.share.foo']) + assert 'resources' in out + res = out['resources'] + assert len(res) == 2 + assert {r['resource_type'] for r in res} == { + 'ceph.smb.share', + } + assert {r['cluster_id'] for r in res} == {'foo'} + + +def test_show_specific_share(tmodule): + _example_cfg_1(tmodule) + out = tmodule.show(['ceph.smb.share.foo.s1']) + assert 'resources' not in out + assert out['resource_type'] == 'ceph.smb.share' + assert out['cluster_id'] == 'foo' + assert out['share_id'] == 's1' + + +def test_show_nomatches(tmodule): + _example_cfg_1(tmodule) + out = tmodule.show(['ceph.smb.share.foo.whoops']) + assert 'resources' in out + assert out['resources'] == [] + + +def test_show_invalid_input(tmodule): + _example_cfg_1(tmodule) + with pytest.raises(smb.cli.InvalidInputValue): + tmodule.show(['ceph.smb.export'])