From a8f71c8e0567db158d51edd83cf0df5cab221409 Mon Sep 17 00:00:00 2001 From: Juan Pablo Norena Date: Sun, 15 May 2022 20:13:26 +0000 Subject: [PATCH 1/4] Add test for ceph auth actions get-or-create-user and delete-user --- zaza/openstack/charm_tests/ceph/tests.py | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/zaza/openstack/charm_tests/ceph/tests.py b/zaza/openstack/charm_tests/ceph/tests.py index 039ce27..c8fe1b3 100644 --- a/zaza/openstack/charm_tests/ceph/tests.py +++ b/zaza/openstack/charm_tests/ceph/tests.py @@ -611,6 +611,40 @@ class CephTest(test_utils.OpenStackBaseTest): zaza_model.wait_for_application_states() self.assertEqual(len(osds) * 2, self.get_num_osds(mon)) + def test_ceph_auth(self): + """Test creating and deleting user.""" + logging.info('Creating user and exported keyring...') + action_obj = zaza_model.run_action_on_leader( + 'ceph-mon', + 'get-or-create-user', + action_params={'username': 'sandbox', + 'mon-caps': 'allow r', + 'osd-caps': 'allow r'} + ) + logging.debug('Result of action: {}'.format(action_obj)) + create_results = json.loads(action_obj.data['results']['message']) + + logging.info('Getting existing user and exported keyring...') + action_obj = zaza_model.run_action_on_leader( + 'ceph-mon', + 'get-or-create-user', + action_params={'username': 'sandbox'} + ) + logging.debug('Result of action: {}'.format(action_obj)) + get_results = json.loads(action_obj.data['results']['message']) + + self.assertEqual(get_results, create_results) + + logging.info('Deleting user...') + action_obj = zaza_model.run_action_on_leader( + 'ceph-mon', + 'delete-user', + action_params={'username': 'sandbox'} + ) + logging.debug('Result of action: {}'.format(action_obj)) + delete_results = action_obj.data['results']['message'] + self.assertEqual(delete_results, "updated\n") + class CephRGWTest(test_utils.OpenStackBaseTest): """Ceph RADOS Gateway Daemons Test Class.""" From 8cba107f3a70f819abcdf348ada51d16ce543b1a Mon Sep 17 00:00:00 2001 From: Juan Pablo Norena Date: Wed, 18 May 2022 11:57:29 +0000 Subject: [PATCH 2/4] add test for deleting non-existing user --- zaza/openstack/charm_tests/ceph/tests.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/ceph/tests.py b/zaza/openstack/charm_tests/ceph/tests.py index c8fe1b3..ed2eb4e 100644 --- a/zaza/openstack/charm_tests/ceph/tests.py +++ b/zaza/openstack/charm_tests/ceph/tests.py @@ -635,7 +635,7 @@ class CephTest(test_utils.OpenStackBaseTest): self.assertEqual(get_results, create_results) - logging.info('Deleting user...') + logging.info('Deleting existing user...') action_obj = zaza_model.run_action_on_leader( 'ceph-mon', 'delete-user', @@ -645,6 +645,16 @@ class CephTest(test_utils.OpenStackBaseTest): delete_results = action_obj.data['results']['message'] self.assertEqual(delete_results, "updated\n") + logging.info('Deleting non-existing user...') + action_obj = zaza_model.run_action_on_leader( + 'ceph-mon', + 'delete-user', + action_params={'username': 'sandbox'} + ) + logging.debug('Result of action: {}'.format(action_obj)) + delete_results = action_obj.data['results']['message'] + self.assertEqual(delete_results, "entity client.sandbox does not exist\n") + class CephRGWTest(test_utils.OpenStackBaseTest): """Ceph RADOS Gateway Daemons Test Class.""" From 72e2979901791719f82ac1ad2d60851ac05900b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Nore=C3=B1a-Monsalve?= <34222866+jpnorenam@users.noreply.github.com> Date: Thu, 9 Jun 2022 06:47:47 -0500 Subject: [PATCH 3/4] update test.py --- zaza/openstack/charm_tests/ceph/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/ceph/tests.py b/zaza/openstack/charm_tests/ceph/tests.py index ed2eb4e..a0359dd 100644 --- a/zaza/openstack/charm_tests/ceph/tests.py +++ b/zaza/openstack/charm_tests/ceph/tests.py @@ -653,7 +653,8 @@ class CephTest(test_utils.OpenStackBaseTest): ) logging.debug('Result of action: {}'.format(action_obj)) delete_results = action_obj.data['results']['message'] - self.assertEqual(delete_results, "entity client.sandbox does not exist\n") + self.assertEqual(delete_results, + "entity client.sandbox does not exist\n") class CephRGWTest(test_utils.OpenStackBaseTest): From 0f867b476d268c1842aed54bed93325de2bccda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Nore=C3=B1a-Monsalve?= <34222866+jpnorenam@users.noreply.github.com> Date: Thu, 9 Jun 2022 06:53:13 -0500 Subject: [PATCH 4/4] update test.py --- zaza/openstack/charm_tests/ceph/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zaza/openstack/charm_tests/ceph/tests.py b/zaza/openstack/charm_tests/ceph/tests.py index a0359dd..8a72245 100644 --- a/zaza/openstack/charm_tests/ceph/tests.py +++ b/zaza/openstack/charm_tests/ceph/tests.py @@ -653,7 +653,7 @@ class CephTest(test_utils.OpenStackBaseTest): ) logging.debug('Result of action: {}'.format(action_obj)) delete_results = action_obj.data['results']['message'] - self.assertEqual(delete_results, + self.assertEqual(delete_results, "entity client.sandbox does not exist\n")