From dcf2ce1b8cd039b3a13e7c70ef94ce968ffc4de0 Mon Sep 17 00:00:00 2001 From: Thomas Duval Date: Wed, 22 Nov 2017 11:26:41 +0100 Subject: Add waiting code for Keystone, re-add the ability to connect a PDP to the "admin" Keystone project and fix some bugs Change-Id: Ic3afdb1306a72bd09f9071e96aabfae602153e94 --- moonv4/templates/moonforming/utils/pdp.py | 10 ++++++---- moonv4/templates/moonforming/utils/policies.py | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'moonv4/templates/moonforming/utils') diff --git a/moonv4/templates/moonforming/utils/pdp.py b/moonv4/templates/moonforming/utils/pdp.py index 676b216b..f3c6df37 100644 --- a/moonv4/templates/moonforming/utils/pdp.py +++ b/moonv4/templates/moonforming/utils/pdp.py @@ -1,7 +1,9 @@ +import logging import requests import utils.config config = utils.config.get_config_data() +logger = logging.getLogger("moonforming.utils.policies") URL = "http://{}:{}".format( config['components']['manager']['hostname'], @@ -46,8 +48,8 @@ def get_keystone_projects(): } req = requests.post("{}/auth/tokens".format(KEYSTONE_SERVER), json=data_auth, headers=HEADERS) - print("{}/auth/tokens".format(KEYSTONE_SERVER)) - print(req.text) + logger.debug("{}/auth/tokens".format(KEYSTONE_SERVER)) + logger.debug(req.text) assert req.status_code in (200, 201) TOKEN = req.headers['X-Subject-Token'] HEADERS['X-Auth-Token'] = TOKEN @@ -97,8 +99,8 @@ def add_pdp(name="test_pdp", policy_id=None): if policy_id: pdp_template['security_pipeline'].append(policy_id) req = requests.post(URL + "/pdp", json=pdp_template, headers=HEADERS) - print(req.status_code) - print(req) + logger.debug(req.status_code) + logger.debug(req) assert req.status_code == 200 result = req.json() assert type(result) is dict diff --git a/moonv4/templates/moonforming/utils/policies.py b/moonv4/templates/moonforming/utils/policies.py index df7f5f57..bd08291a 100644 --- a/moonv4/templates/moonforming/utils/policies.py +++ b/moonv4/templates/moonforming/utils/policies.py @@ -1,7 +1,9 @@ +import logging import requests import utils.config config = utils.config.get_config_data() +logger = logging.getLogger("moonforming.utils.policies") URL = "http://{}:{}".format(config['components']['manager']['hostname'], config['components']['manager']['port']) URL = URL + "{}" @@ -108,10 +110,13 @@ def delete_policy(policy_id): def add_subject(policy_id=None, name="test_subject"): subject_template['name'] = name if policy_id: + logger.debug(URL.format("/policies/{}/subjects".format(policy_id))) req = requests.post(URL.format("/policies/{}/subjects".format(policy_id)), json=subject_template, headers=HEADERS) else: + logger.debug(URL.format("/subjects")) req = requests.post(URL.format("/subjects"), json=subject_template, headers=HEADERS) + logger.debug(req.text) assert req.status_code == 200 result = req.json() assert "subjects" in result -- cgit 1.2.3-korg