]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/smb: add unit tests for show command json and yaml outupt
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 25 Apr 2024 20:27:51 +0000 (16:27 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 1 May 2024 13:29:51 +0000 (09:29 -0400)
Assert that the show command output is consistent.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/pybind/mgr/smb/tests/test_smb.py

index 85bf98a85cf0aefa1f4cc50ccda254d354dda436..03648750360de50df7e49c70dfe1507010f1d0a0 100644 (file)
@@ -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()
+    )