Keystone v3-ext/OS-ENDPOINT-POLICY endpoints implementation.
Existing policy client is missing policy association API calls
for the endpoints, services and regions. These are supported API,
as mentioned on the wiki given below:
https://developer.openstack.org/api-ref/identity/v3-ext/index.html#associate-policy-and-endpoint
Closes-Bug: #1682641
Change-Id: I4af1e4862a17216d65446e8c29bd1b886f5d8c24
diff --git a/releasenotes/notes/add-additional-methods-to-policy-client-library-b8279c18335588c9.yaml b/releasenotes/notes/add-additional-methods-to-policy-client-library-b8279c18335588c9.yaml
new file mode 100644
index 0000000..cd5284d
--- /dev/null
+++ b/releasenotes/notes/add-additional-methods-to-policy-client-library-b8279c18335588c9.yaml
@@ -0,0 +1,6 @@
+---
+features:
+ - |
+ Add ``v3-ext/OS-ENDPOINT-POLICY`` API calls to support creation, deletion and
+ retrieval of associations between service endpoints and policies. Such associations
+ enable an endpoint to request its policy.
diff --git a/tempest/lib/services/identity/v3/policies_client.py b/tempest/lib/services/identity/v3/policies_client.py
index d4560e2..ca8dbbd 100644
--- a/tempest/lib/services/identity/v3/policies_client.py
+++ b/tempest/lib/services/identity/v3/policies_client.py
@@ -73,3 +73,115 @@
resp, body = self.delete(url)
self.expected_success(204, resp.status)
return rest_client.ResponseBody(resp, body)
+
+ def update_policy_association_for_endpoint(self, policy_id, endpoint_id):
+ """Create policy association with endpoint.
+
+ For a full list of available parameters, please refer to the official
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#associate-policy-and-endpoint
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/endpoints/{1}"\
+ .format(policy_id, endpoint_id)
+ resp, body = self.put(url, '{}')
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def show_policy_association_for_endpoint(self, policy_id, endpoint_id):
+ """Get policy association of endpoint.
+
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#verify-a-policy-and-endpoint-association
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/endpoints/{1}"\
+ .format(policy_id, endpoint_id)
+ resp, body = self.get(url)
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def delete_policy_association_for_endpoint(self, policy_id, endpoint_id):
+ """Delete policy association with endpoint.
+
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#delete-a-policy-and-endpoint-association
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/endpoints/{1}"\
+ .format(policy_id, endpoint_id)
+ resp, body = self.delete(url)
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def update_policy_association_for_service(self, policy_id, service_id):
+ """Create policy association with service.
+
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#associate-policy-and-service-type-endpoint
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/services/{1}"\
+ .format(policy_id, service_id)
+ resp, body = self.put(url, '{}')
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def show_policy_association_for_service(self, policy_id, service_id):
+ """Get policy association of service.
+
+ API Reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#verify-a-policy-and-service-type-endpoint-association
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/services/{1}"\
+ .format(policy_id, service_id)
+ resp, body = self.get(url)
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def delete_policy_association_for_service(self, policy_id, service_id):
+ """Delete policy association with service.
+
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#delete-a-policy-and-service-type-endpoint-association
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/services/{1}"\
+ .format(policy_id, service_id)
+ resp, body = self.delete(url)
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def update_policy_association_for_region_and_service(
+ self, policy_id, service_id, region_id):
+ """Create policy association with service and region.
+
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#associate-policy-and-service-type-endpoint-in-a-region
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/services/{1}/regions/{2}"\
+ .format(policy_id, service_id, region_id)
+ resp, body = self.put(url, '{}')
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def show_policy_association_for_region_and_service(
+ self, policy_id, service_id, region_id):
+ """Get policy association of service and region.
+
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#verify-a-policy-and-service-type-endpoint-in-a-region-association
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/services/{1}/regions/{2}"\
+ .format(policy_id, service_id, region_id)
+ resp, body = self.get(url)
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
+ def delete_policy_association_for_region_and_service(
+ self, policy_id, service_id, region_id):
+ """Delete policy association with service and region.
+
+ API reference:
+ https://developer.openstack.org/api-ref/identity/v3-ext/index.html#delete-a-policy-and-service-type-endpoint-in-a-region-association
+ """
+ url = "policies/{0}/OS-ENDPOINT-POLICY/services/{1}/regions/{2}"\
+ .format(policy_id, service_id, region_id)
+ resp, body = self.delete(url)
+ self.expected_success(204, resp.status)
+ return rest_client.ResponseBody(resp, body)
diff --git a/tempest/tests/lib/services/identity/v3/test_policies_client.py b/tempest/tests/lib/services/identity/v3/test_policies_client.py
index 66c3d65..0237475 100644
--- a/tempest/tests/lib/services/identity/v3/test_policies_client.py
+++ b/tempest/tests/lib/services/identity/v3/test_policies_client.py
@@ -81,6 +81,10 @@
}
]
}
+ FAKE_ENDPOINT_ID = "234789"
+ FAKE_SERVICE_ID = "556782"
+ FAKE_POLICY_ID = "717273"
+ FAKE_REGION_ID = "73"
def setUp(self):
super(TestPoliciesClient, self).setUp()
@@ -150,3 +154,87 @@
{},
policy_id="717273",
status=204)
+
+ def test_update_policy_association_for_endpoint(self):
+ self.check_service_client_function(
+ self.client.update_policy_association_for_endpoint,
+ 'tempest.lib.common.rest_client.RestClient.put',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ endpoint_id=self.FAKE_ENDPOINT_ID,
+ status=204)
+
+ def test_show_policy_association_for_endpoint(self):
+ self.check_service_client_function(
+ self.client.show_policy_association_for_endpoint,
+ 'tempest.lib.common.rest_client.RestClient.get',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ endpoint_id=self.FAKE_ENDPOINT_ID,
+ status=204)
+
+ def test_delete_policy_association_for_endpoint(self):
+ self.check_service_client_function(
+ self.client.delete_policy_association_for_endpoint,
+ 'tempest.lib.common.rest_client.RestClient.delete',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ endpoint_id=self.FAKE_ENDPOINT_ID,
+ status=204)
+
+ def test_update_policy_association_for_service(self):
+ self.check_service_client_function(
+ self.client.update_policy_association_for_service,
+ 'tempest.lib.common.rest_client.RestClient.put',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ service_id=self.FAKE_SERVICE_ID,
+ status=204)
+
+ def test_show_policy_association_for_service(self):
+ self.check_service_client_function(
+ self.client.show_policy_association_for_service,
+ 'tempest.lib.common.rest_client.RestClient.get',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ service_id=self.FAKE_SERVICE_ID,
+ status=204)
+
+ def test_delete_policy_association_for_service(self):
+ self.check_service_client_function(
+ self.client.delete_policy_association_for_service,
+ 'tempest.lib.common.rest_client.RestClient.delete',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ service_id=self.FAKE_SERVICE_ID,
+ status=204)
+
+ def test_update_policy_association_for_region_and_service(self):
+ self.check_service_client_function(
+ self.client.update_policy_association_for_region_and_service,
+ 'tempest.lib.common.rest_client.RestClient.put',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ service_id=self.FAKE_SERVICE_ID,
+ region_id=self.FAKE_REGION_ID,
+ status=204)
+
+ def test_show_policy_association_for_region_and_service(self):
+ self.check_service_client_function(
+ self.client.show_policy_association_for_region_and_service,
+ 'tempest.lib.common.rest_client.RestClient.get',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ service_id=self.FAKE_SERVICE_ID,
+ region_id=self.FAKE_REGION_ID,
+ status=204)
+
+ def test_delete_policy_association_for_region_and_service(self):
+ self.check_service_client_function(
+ self.client.delete_policy_association_for_region_and_service,
+ 'tempest.lib.common.rest_client.RestClient.delete',
+ {},
+ policy_id=self.FAKE_POLICY_ID,
+ service_id=self.FAKE_SERVICE_ID,
+ region_id=self.FAKE_REGION_ID,
+ status=204)