aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/templates/moonforming/utils
diff options
context:
space:
mode:
authorThomas Duval <thomas.duval@orange.com>2017-11-22 11:26:41 +0100
committerThomas Duval <thomas.duval@orange.com>2017-11-22 11:26:41 +0100
commitdcf2ce1b8cd039b3a13e7c70ef94ce968ffc4de0 (patch)
tree5bf8e2a2071525c28f76b99a0e1eec8945528a66 /moonv4/templates/moonforming/utils
parentcb739df188d2c7c465a3d4fbc857c6417e2a3073 (diff)
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
Diffstat (limited to 'moonv4/templates/moonforming/utils')
-rw-r--r--moonv4/templates/moonforming/utils/pdp.py10
-rw-r--r--moonv4/templates/moonforming/utils/policies.py5
2 files changed, 11 insertions, 4 deletions
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