|
45 | 45 | import heatclient.exc |
46 | 46 | import glanceclient.common.exceptions |
47 | 47 | import keystoneauth1 |
| 48 | +import manilaclient.common.apiclient.exceptions |
48 | 49 |
|
49 | 50 | import zaza.model as zaza_model |
50 | 51 |
|
@@ -744,3 +745,33 @@ def get_client_and_attempt_operation(self, ip): |
744 | 745 | except (barbicanclient.exceptions.HTTPClientError, |
745 | 746 | keystoneauth1.exceptions.http.Forbidden): |
746 | 747 | 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