summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Bartra <rb560u@att.com>2018-08-23 12:06:07 -0400
committerRick Bartra <rb560u@att.com>2018-08-24 17:33:47 -0400
commit9ede7e52377c7c6b0b2f37790c0c960a199a8ff1 (patch)
tree297664d005823f5c9582576ca91e8bd4b5f068c9
parent9f473f288a6f8d42c32e54da7d9c4679c0cd40cc (diff)
Cleanup clients, add documenation, and fix 2 tests
This commit does the following: - Cleanup the service clients to not hard code resource values used in API endpoints - Add documentation to the README - Fix the following tests that were not previously working: - `test_get_action_validation` - `test_invoke_action_control` Change-Id: I8636f3b704871ad98c346b4a19c7f7f41c705e13
-rw-r--r--README.rst45
-rw-r--r--airship_tempest_plugin/services/shipyard/json/actions_client.py22
-rw-r--r--airship_tempest_plugin/services/shipyard/json/airflow_monitoring_client.py4
-rw-r--r--airship_tempest_plugin/services/shipyard/json/document_staging_client.py17
-rw-r--r--airship_tempest_plugin/services/shipyard/json/log_retrieval_client.py5
-rw-r--r--airship_tempest_plugin/tests/api/common/rbac_roles.yaml1
-rw-r--r--airship_tempest_plugin/tests/api/shipyard/rbac/test_actions_rbac.py23
7 files changed, 86 insertions, 31 deletions
diff --git a/README.rst b/README.rst
index f27f368..fb6ecb6 100644
--- a/README.rst
+++ b/README.rst
@@ -2,13 +2,58 @@
2Tempest Integration of airship-tempest-plugin 2Tempest Integration of airship-tempest-plugin
3=============================================== 3===============================================
4 4
5Purpose:
6--------
5The purpose of this plugin is to provide automated tests 7The purpose of this plugin is to provide automated tests
6for all OpenStack Airship components. 8for all OpenStack Airship components.
7 9
8DISCALIMER: 10DISCALIMER:
11-----------
9This initial implementation is just to meet the first use case which is RBAC 12This initial implementation is just to meet the first use case which is RBAC
10testing. For RBAC testing, we only need to hit the API endpoint and check 13testing. For RBAC testing, we only need to hit the API endpoint and check
11role permission to the API being tested. Some of the REST clients will need to be 14role permission to the API being tested. Some of the REST clients will need to be
12rewritten if functional testing is desired. Those that need to be rewritten 15rewritten if functional testing is desired. Those that need to be rewritten
13are documented in each service client code. 16are documented in each service client code.
14 17
18Environment Information:
19------------------------
20Testing can be done in a airship-in-a-bottle environment. Please refer to [0] and [1].
21Tempest and Tempest plugin installation can be done in a Python virtual environment.
22
23FAQ:
24----
25- Where do the REST clients exist?
26 https://github.com/att-comdev/airship-tempest-plugin/tree/master/airship_tempest_plugin/services
27- Where do the tests exists? [3]
28 https://github.com/att-comdev/airship-tempest-plugin/tree/master/airship_tempest_plugin/tests/api
29- Example of where/how the REST clients are instantiated.
30 https://github.com/att-comdev/airship-tempest-plugin/blob/master/airship_tempest_plugin/tests/api/shipyard/base.py
31- Where do we define expected results (requirements)?
32 https://github.com/att-comdev/airship-tempest-plugin/blob/master/airship_tempest_plugin/tests/api/common/rbac_roles.yaml
33- Where do we add configuration to support another Airship component?
34 https://github.com/att-comdev/airship-tempest-plugin/blob/master/airship_tempest_plugin/config.py
35- Where do we run the test from?
36 After the plugin is installed, run it from the tempest directory
37- Example of how to run all the RBAC tests for Shipyard:
38 'tempest run --regex airship_tempest_plugin.tests.api.shipyard.rbac'
39- What is Patrole?
40 https://github.com/openstack/patrole/blob/master/README.rst
41- What is a Tempest plugin? [8]
42 https://docs.openstack.org/tempest/latest/plugin.html
43
44Patrole Supporting Documentation:
45---------------------------------
46Patrole documentation for requirements driven approach that is used: https://github.com/openstack/patrole/blob/master/doc/source/framework/requirements_authority.rst
47Patrole role-overriding: https://github.com/openstack/patrole/blob/master/doc/source/framework/rbac_utils.rst#role-overriding
48Patrole under-permission exception: https://github.com/openstack/patrole/blob/master/patrole_tempest_plugin/rbac_exceptions.py#L51
49Patrole over-permission exception: https://github.com/openstack/patrole/blob/master/patrole_tempest_plugin/rbac_exceptions.py#L44
50
51Future Considerations:
52---------------------
53Will the airship-tempest-plugin continue to live here: https://github.com/att-comdev/airship-tempest-plugin or will it be moved under OpenStack?
54Will there exist a RBAC gate for all Airship projects?
55
56Referenced Links:
57-----------------
58[0] https://github.com/openstack/airship-in-a-bottle
59[1] https://www.airshipit.org/
diff --git a/airship_tempest_plugin/services/shipyard/json/actions_client.py b/airship_tempest_plugin/services/shipyard/json/actions_client.py
index 08f74a3..5b1001c 100644
--- a/airship_tempest_plugin/services/shipyard/json/actions_client.py
+++ b/airship_tempest_plugin/services/shipyard/json/actions_client.py
@@ -24,7 +24,7 @@ from tempest.lib.common import rest_client
24 24
25# NOTE(rb560u): The following will need to be rewritten in the future if 25# NOTE(rb560u): The following will need to be rewritten in the future if
26# functional testing is desired: 26# functional testing is desired:
27# - 'def post_actions` 27# - 'def create_action`
28# This initial implementation is just to meet the first use case which is RBAC 28# This initial implementation is just to meet the first use case which is RBAC
29# testing. For RBAC testing, we only need to hit the API endpoint and check 29# testing. For RBAC testing, we only need to hit the API endpoint and check
30# role permission to that API. 30# role permission to that API.
@@ -40,33 +40,35 @@ class ActionsClient(rest_client.RestClient):
40 return rest_client.ResponseBody(resp, body) 40 return rest_client.ResponseBody(resp, body)
41 41
42 def create_action(self): 42 def create_action(self):
43 url = "actions" 43 url = 'actions'
44 # Update post_body if functional testing is desired
44 post_body = json.dumps({}) 45 post_body = json.dumps({})
45 resp, body = self.post(url, post_body) 46 resp, body = self.post(url, post_body)
46 self.expected_success(201, resp.status) 47 self.expected_success(201, resp.status)
47 body = json.loads(body) 48 body = json.loads(body)
48 return rest_client.ResponseBody(resp, body) 49 return rest_client.ResponseBody(resp, body)
49 50
50 def get_action(self): 51 def get_action(self, action_id=None):
51 resp, body = self.get('actions/1') 52 resp, body = self.get('actions/%s' % action_id)
52 self.expected_success(200, resp.status) 53 self.expected_success(200, resp.status)
53 body = json.loads(body) 54 body = json.loads(body)
54 return rest_client.ResponseBody(resp, body) 55 return rest_client.ResponseBody(resp, body)
55 56
56 def get_action_validation(self): 57 def get_action_validation(self, action_id=None, validation_id=None):
57 resp, body = self.get('actions/1/validationdetails/1') 58 resp, body = \
59 self.get('actions/%s/validations/%s' % (action_id, validation_id))
58 self.expected_success(200, resp.status) 60 self.expected_success(200, resp.status)
59 body = json.loads(body) 61 body = json.loads(body)
60 return rest_client.ResponseBody(resp, body) 62 return rest_client.ResponseBody(resp, body)
61 63
62 def get_action_step(self): 64 def get_action_step(self, action_id=None, step_id=None):
63 resp, body = self.get('actions/1/steps/1') 65 resp, body = self.get('actions/%s/steps/%s' % (action_id, step_id))
64 self.expected_success(200, resp.status) 66 self.expected_success(200, resp.status)
65 body = json.loads(body) 67 body = json.loads(body)
66 return rest_client.ResponseBody(resp, body) 68 return rest_client.ResponseBody(resp, body)
67 69
68 def invoke_action_control(self): 70 def invoke_action_control(self, action_id=None, control_verb=None):
69 url = "actions/1/pause" 71 url = 'actions/%s/control/%s' % (action_id, control_verb)
70 post_body = json.dumps({}) 72 post_body = json.dumps({})
71 resp, body = self.post(url, post_body) 73 resp, body = self.post(url, post_body)
72 self.expected_success(202, resp.status) 74 self.expected_success(202, resp.status)
diff --git a/airship_tempest_plugin/services/shipyard/json/airflow_monitoring_client.py b/airship_tempest_plugin/services/shipyard/json/airflow_monitoring_client.py
index 2646ca0..e419fdb 100644
--- a/airship_tempest_plugin/services/shipyard/json/airflow_monitoring_client.py
+++ b/airship_tempest_plugin/services/shipyard/json/airflow_monitoring_client.py
@@ -32,8 +32,8 @@ class AirflowMonitoringClient(rest_client.RestClient):
32 body = json.loads(body) 32 body = json.loads(body)
33 return rest_client.ResponseBody(resp, body) 33 return rest_client.ResponseBody(resp, body)
34 34
35 def get_workflow(self): 35 def get_workflow(self, workflow_id=None):
36 resp, body = self.get('workflows/1') 36 resp, body = self.get('workflows/%s' % workflow_id)
37 self.expected_success(200, resp.status) 37 self.expected_success(200, resp.status)
38 body = json.loads(body) 38 body = json.loads(body)
39 return rest_client.ResponseBody(resp, body) 39 return rest_client.ResponseBody(resp, body)
diff --git a/airship_tempest_plugin/services/shipyard/json/document_staging_client.py b/airship_tempest_plugin/services/shipyard/json/document_staging_client.py
index 039e82a..2f33140 100644
--- a/airship_tempest_plugin/services/shipyard/json/document_staging_client.py
+++ b/airship_tempest_plugin/services/shipyard/json/document_staging_client.py
@@ -24,9 +24,7 @@ from tempest.lib.common import rest_client
24 24
25# NOTE(rb560u): The following will need to be rewritten in the future if 25# NOTE(rb560u): The following will need to be rewritten in the future if
26# functional testing is desired: 26# functional testing is desired:
27# - 'def post_configdocs` 27# - 'def create_configdocs`
28# - `def get_configdocs_within_collection`
29# - 'def post_commitconfigdocs'
30# This initial implementation is just to meet the first use case which is RBAC 28# This initial implementation is just to meet the first use case which is RBAC
31# testing. For RBAC testing, we only need to hit the API endpoint and check 29# testing. For RBAC testing, we only need to hit the API endpoint and check
32# role permission to that API. 30# role permission to that API.
@@ -41,16 +39,17 @@ class DocumentStagingClient(rest_client.RestClient):
41 body = json.loads(body) 39 body = json.loads(body)
42 return rest_client.ResponseBody(resp, body) 40 return rest_client.ResponseBody(resp, body)
43 41
44 def create_configdocs(self): 42 def create_configdocs(self, collection_id=None):
45 url = "configdocs/1" 43 url = "configdocs/%s" % collection_id
44 # Update post_body if functional testing is desired
46 post_body = json.dumps({}) 45 post_body = json.dumps({})
47 resp, body = self.post(url, post_body) 46 resp, body = self.post(url, post_body)
48 self.expected_success(201, resp.status) 47 self.expected_success(201, resp.status)
49 body = json.loads(body) 48 body = json.loads(body)
50 return rest_client.ResponseBody(resp, body) 49 return rest_client.ResponseBody(resp, body)
51 50
52 def get_configdocs(self): 51 def get_configdocs(self, collection_id=None):
53 resp, body = self.get('configdocs/1') 52 resp, body = self.get('configdocs/%s' % collection_id)
54 self.expected_success(200, resp.status) 53 self.expected_success(200, resp.status)
55 body = json.loads(body) 54 body = json.loads(body)
56 return rest_client.ResponseBody(resp, body) 55 return rest_client.ResponseBody(resp, body)
@@ -61,8 +60,8 @@ class DocumentStagingClient(rest_client.RestClient):
61 body = json.loads(body) 60 body = json.loads(body)
62 return rest_client.ResponseBody(resp, body) 61 return rest_client.ResponseBody(resp, body)
63 62
64 def commit_configdocs(self): 63 def commit_configdocs(self, force=False, dryrun=False):
65 post_body = json.dumps({}) 64 post_body = json.dumps({"force": force, "dryrun": dryrun})
66 resp, body = self.post("commitconfigdocs", post_body) 65 resp, body = self.post("commitconfigdocs", post_body)
67 self.expected_success(200, resp.status) 66 self.expected_success(200, resp.status)
68 body = json.loads(body) 67 body = json.loads(body)
diff --git a/airship_tempest_plugin/services/shipyard/json/log_retrieval_client.py b/airship_tempest_plugin/services/shipyard/json/log_retrieval_client.py
index c6239ac..d36d0b1 100644
--- a/airship_tempest_plugin/services/shipyard/json/log_retrieval_client.py
+++ b/airship_tempest_plugin/services/shipyard/json/log_retrieval_client.py
@@ -26,8 +26,9 @@ from tempest.lib.common import rest_client
26class LogRetrievalClient(rest_client.RestClient): 26class LogRetrievalClient(rest_client.RestClient):
27 api_version = "v1.0" 27 api_version = "v1.0"
28 28
29 def get_action_step_logs(self): 29 def get_action_step_logs(self, action_id=None, step_id=None):
30 resp, body = self.get('actions/1/steps/1/logs') 30 resp, body = \
31 self.get('actions/%s/steps/%s/logs' % (action_id, step_id))
31 self.expected_success(200, resp.status) 32 self.expected_success(200, resp.status)
32 body = json.loads(body) 33 body = json.loads(body)
33 return rest_client.ResponseBody(resp, body) 34 return rest_client.ResponseBody(resp, body)
diff --git a/airship_tempest_plugin/tests/api/common/rbac_roles.yaml b/airship_tempest_plugin/tests/api/common/rbac_roles.yaml
index 3cb5401..fd17b68 100644
--- a/airship_tempest_plugin/tests/api/common/rbac_roles.yaml
+++ b/airship_tempest_plugin/tests/api/common/rbac_roles.yaml
@@ -43,7 +43,6 @@ shipyard:
43 workflow_orchestrator:commit_configdocs: 43 workflow_orchestrator:commit_configdocs:
44 - admin 44 - admin
45 - admin_ucp 45 - admin_ucp
46 - admin_ucp_viewer
47 workflow_orchestrator:list_workflows: 46 workflow_orchestrator:list_workflows:
48 - admin 47 - admin
49 - admin_ucp 48 - admin_ucp
diff --git a/airship_tempest_plugin/tests/api/shipyard/rbac/test_actions_rbac.py b/airship_tempest_plugin/tests/api/shipyard/rbac/test_actions_rbac.py
index 9ef398a..3c569d7 100644
--- a/airship_tempest_plugin/tests/api/shipyard/rbac/test_actions_rbac.py
+++ b/airship_tempest_plugin/tests/api/shipyard/rbac/test_actions_rbac.py
@@ -41,9 +41,10 @@ class ActionsRbacTest(rbac_base.BaseShipyardRbacTest):
41 # As this is a RBAC test, we only care about whether the role has 41 # As this is a RBAC test, we only care about whether the role has
42 # permission or not. Role permission is checked prior to validating 42 # permission or not. Role permission is checked prior to validating
43 # the post body, therefore we will ignore a BadRequest exception 43 # the post body, therefore we will ignore a BadRequest exception
44 # and NotFound exception
44 try: 45 try:
45 self.shipyard_actions_client.create_action() 46 self.shipyard_actions_client.create_action()
46 except exceptions.BadRequest: 47 except (exceptions.BadRequest, exceptions.NotFound):
47 pass 48 pass
48 49
49 @rbac_rule_validation.action( 50 @rbac_rule_validation.action(
@@ -60,15 +61,19 @@ class ActionsRbacTest(rbac_base.BaseShipyardRbacTest):
60 except exceptions.NotFound: 61 except exceptions.NotFound:
61 pass 62 pass
62 63
63 ''' NEEDS REWORK AS SHIPYARD NOT DOING POLICY ENFORCEMENT FIRST
64 @rbac_rule_validation.action( 64 @rbac_rule_validation.action(
65 service="shipyard", 65 service="shipyard",
66 rules=["workflow_orchestrator:get_action_validation"]) 66 rules=["workflow_orchestrator:get_action_validation"])
67 @decorators.idempotent_id('a5156dcd-2674-4295-aa6a-d8db1bd4cf4b') 67 @decorators.idempotent_id('a5156dcd-2674-4295-aa6a-d8db1bd4cf4b')
68 def test_get_action_validation(self): 68 def test_get_action_validation(self):
69 with self.rbac_utils.override_role(self): 69 with self.rbac_utils.override_role(self):
70 self.shipyard_actions_client.get_action_validation() 70 # As this is a RBAC test, we only care about whether the role has
71 ''' 71 # permission or not. Role permission is checked prior to validating
72 # the post body, therefore we will ignore a NotFound exception
73 try:
74 self.shipyard_actions_client.get_action_validation()
75 except exceptions.NotFound:
76 pass
72 77
73 @rbac_rule_validation.action( 78 @rbac_rule_validation.action(
74 service="shipyard", 79 service="shipyard",
@@ -84,12 +89,16 @@ class ActionsRbacTest(rbac_base.BaseShipyardRbacTest):
84 except exceptions.NotFound: 89 except exceptions.NotFound:
85 pass 90 pass
86 91
87 ''' NEEDS REWORK AS SHIPYARD NOT DOING POLICY ENFORCEMENT FIRST
88 @rbac_rule_validation.action( 92 @rbac_rule_validation.action(
89 service="shipyard", 93 service="shipyard",
90 rules=["workflow_orchestrator:invoke_action_control"]) 94 rules=["workflow_orchestrator:invoke_action_control"])
91 @decorators.idempotent_id('4f6b6564-ff1d-463a-aee8-ed2d51e2a286') 95 @decorators.idempotent_id('4f6b6564-ff1d-463a-aee8-ed2d51e2a286')
92 def test_invoke_action_control(self): 96 def test_invoke_action_control(self):
93 with self.rbac_utils.override_role(self): 97 with self.rbac_utils.override_role(self):
94 self.shipyard_actions_client.invoke_action_control() 98 # As this is a RBAC test, we only care about whether the role has
95 ''' 99 # permission or not. Role permission is checked prior to validating
100 # the post body, therefore we will ignore a NotFound exception
101 try:
102 self.shipyard_actions_client.invoke_action_control()
103 except exceptions.NotFound:
104 pass