From: John Mulligan Date: Thu, 25 Apr 2024 20:27:51 +0000 (-0400) Subject: mgr/smb: add unit tests for show command json and yaml outupt X-Git-Tag: v20.0.0~1971^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=61e92f5b284491792dde1412e7ebf42a63450b44;p=ceph.git mgr/smb: add unit tests for show command json and yaml outupt Assert that the show command output is consistent. 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 85bf98a85cf..03648750360 100644 --- a/src/pybind/mgr/smb/tests/test_smb.py +++ b/src/pybind/mgr/smb/tests/test_smb.py @@ -600,3 +600,58 @@ def test_dump_service_spec(tmodule): assert cfg['spec']['features'] == ['domain'] assert cfg['spec']['config_uri'] == 'mem:foo/config.smb' assert len(cfg['spec']['join_sources']) == 2 + + +def test_cmd_show_resource_json(tmodule): + _example_cfg_1(tmodule) + + res, body, status = tmodule.show.command(['ceph.smb.cluster.foo']) + assert res == 0 + assert ( + body.strip() + == """ +{ + "resource_type": "ceph.smb.cluster", + "cluster_id": "foo", + "auth_mode": "active-directory", + "intent": "present", + "domain_settings": { + "realm": "dom1.example.com", + "join_sources": [ + { + "source_type": "password", + "auth": { + "username": "testadmin", + "password": "Passw0rd" + } + } + ] + } +} + """.strip() + ) + + +def test_cmd_show_resource_yaml(tmodule): + _example_cfg_1(tmodule) + + res, body, status = tmodule.show.command( + ['ceph.smb.cluster.foo'], format='yaml' + ) + assert res == 0 + assert ( + body.strip() + == """ +resource_type: ceph.smb.cluster +cluster_id: foo +auth_mode: active-directory +intent: present +domain_settings: + realm: dom1.example.com + join_sources: + - source_type: password + auth: + username: testadmin + password: Passw0rd +""".strip() + )