Add service validation to Patrole framework
Verify that the service being passed in the rbac_rule_validation
decorator is a valid service. The Tempest Identity v3 services_client
is being used to make a call to Keystone to list the services that
are available.
If an invalid service is passed in the decorator, then an exception
is thrown.
Change-Id: I3de3fccf18456bb8382864eeabcbfe64e2cffebb
Implements: blueprint add-service-validation
diff --git a/patrole_tempest_plugin/rbac_rule_validation.py b/patrole_tempest_plugin/rbac_rule_validation.py
index 36784b7..284d8f0 100644
--- a/patrole_tempest_plugin/rbac_rule_validation.py
+++ b/patrole_tempest_plugin/rbac_rule_validation.py
@@ -41,6 +41,12 @@
try:
func(*args)
+ except rbac_exceptions.RbacInvalidService as e:
+ msg = ("%s is not a valid service." % service)
+ LOG.error(msg)
+ raise exceptions.NotFound(
+ "%s RbacInvalidService was: %s" %
+ (msg, e))
except exceptions.Forbidden as e:
if allowed:
msg = ("Role %s was not allowed to perform %s." %