Skip to content

Commit 11784db

Browse files
munirsidddosaboy
authored andcommitted
Add manila policyd tests
(cherry picked from commit 217e261)
1 parent d477883 commit 11784db

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

  • zaza/openstack/charm_tests/policyd

zaza/openstack/charm_tests/policyd/tests.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import heatclient.exc
4646
import glanceclient.common.exceptions
4747
import keystoneauth1
48+
import manilaclient.common.apiclient.exceptions
4849

4950
import zaza.model as zaza_model
5051

@@ -744,3 +745,33 @@ def get_client_and_attempt_operation(self, ip):
744745
except (barbicanclient.exceptions.HTTPClientError,
745746
keystoneauth1.exceptions.http.Forbidden):
746747
raise PolicydOperationFailedException()
748+
749+
750+
class ManilaTests(BasePolicydSpecialization):
751+
"""Test the policyd override using the manila client."""
752+
753+
_rule = {'rule.yaml': "{'share:get_all': '!'}"}
754+
755+
@classmethod
756+
def setUpClass(cls, application_name=None):
757+
"""Run class setup for running ManilaTests charm operation tests."""
758+
super(ManilaTests, cls).setUpClass(application_name="manila")
759+
cls.application_name = "manila"
760+
761+
def get_client_and_attempt_operation(self, ip):
762+
"""Attempt to list shares as a policyd override.
763+
764+
This operation should pass normally, and fail when
765+
the rule has been overriden (see the `rule` class variable).
766+
767+
:param ip: the IP address to get the session against.
768+
:type ip: str
769+
:raises: PolicydOperationFailedException if operation fails.
770+
"""
771+
manila_client = openstack_utils.get_manila_session_client(
772+
self.get_keystone_session_admin_user(ip))
773+
try:
774+
manila_client.shares.list()
775+
except (manilaclient.common.apiclient.exceptions.Forbidden,
776+
keystoneauth1.exceptions.http.Forbidden):
777+
raise PolicydOperationFailedException()

0 commit comments

Comments
 (0)