aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/tests
diff options
context:
space:
mode:
Diffstat (limited to 'moonv4/tests')
-rw-r--r--moonv4/tests/populate_default_values.py18
-rw-r--r--moonv4/tests/send_authz.py8
2 files changed, 16 insertions, 10 deletions
diff --git a/moonv4/tests/populate_default_values.py b/moonv4/tests/populate_default_values.py
index 740ad8ed..cd06ab1a 100644
--- a/moonv4/tests/populate_default_values.py
+++ b/moonv4/tests/populate_default_values.py
@@ -7,8 +7,11 @@ from utils.policies import *
parser = argparse.ArgumentParser()
parser.add_argument('filename', help='scenario filename', nargs=1)
-parser.add_argument("--verbose", "-v", action='store_true', help="verbose mode")
+parser.add_argument("--verbose", "-v", action='store_true',
+ help="verbose mode")
parser.add_argument("--debug", "-d", action='store_true', help="debug mode")
+parser.add_argument("--keystone-pid", "-k", dest="keystone_pid", default="",
+ help="Force a particular Keystone Project ID")
args = parser.parse_args()
FORMAT = '%(asctime)-15s %(levelname)s %(message)s'
@@ -202,11 +205,12 @@ def create_policy(model_id, meta_rule_list):
def create_pdp(policy_id=None):
logger.info("Creating PDP {}".format(scenario.pdp_name))
projects = get_keystone_projects()
- admin_project_id = None
- for _project in projects['projects']:
- if _project['name'] == "admin":
- admin_project_id = _project['id']
- assert admin_project_id
+ project_id = args.keystone_pid
+ if not project_id:
+ for _project in projects['projects']:
+ if _project['name'] == "admin":
+ project_id = _project['id']
+ assert project_id
pdps = check_pdp()["pdps"]
for pdp_id, pdp_value in pdps.items():
if scenario.pdp_name == pdp_value["name"]:
@@ -214,7 +218,7 @@ def create_pdp(policy_id=None):
logger.debug("Found existing PDP named {} (will add policy {})".format(scenario.pdp_name, policy_id))
return pdp_id
_pdp_id = add_pdp(name=scenario.pdp_name, policy_id=policy_id)
- map_to_keystone(pdp_id=_pdp_id, keystone_project_id=admin_project_id)
+ map_to_keystone(pdp_id=_pdp_id, keystone_project_id=project_id)
return _pdp_id
if __name__ == "__main__":
diff --git a/moonv4/tests/send_authz.py b/moonv4/tests/send_authz.py
index a6ad7339..c21c8bca 100644
--- a/moonv4/tests/send_authz.py
+++ b/moonv4/tests/send_authz.py
@@ -136,7 +136,9 @@ def _send(url, stress_test=False):
return {}
if not stress_test:
if res.status_code == 200:
- logger.info("\033[1m{}\033[m {}".format(url, res.status_code))
+ logger.warning("\033[1m{}\033[m \033[32mGrant\033[m".format(url))
+ elif res.status_code == 401:
+ logger.warning("\033[1m{}\033[m \033[31mDeny\033[m".format(url))
else:
logger.error("\033[1m{}\033[m {} {}".format(url, res.status_code, res.text))
try:
@@ -146,11 +148,11 @@ def _send(url, stress_test=False):
logger.error(res.text)
else:
if j.get("result"):
- logger.warning("{} \033[32m{}\033[m".format(url, j.get("result")))
+ # logger.warning("{} \033[32m{}\033[m".format(url, j.get("result")))
logger.debug("{}".format(j.get("error", "")))
current_request['result'] = "Grant"
else:
- logger.warning("{} \033[31m{}\033[m".format(url, "Deny"))
+ # logger.warning("{} \033[31m{}\033[m".format(url, "Deny"))
logger.debug("{}".format(j))
current_request['result'] = "Deny"
return current_request