aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/tests/utils
diff options
context:
space:
mode:
authorThomas Duval <thomas.duval@orange.com>2017-11-22 11:46:44 +0100
committerThomas Duval <thomas.duval@orange.com>2017-11-22 11:46:44 +0100
commitef3eefca70d8abb4a00dafb9419ad32738e934b2 (patch)
treec1cd6dbcff2b25cc865f5fbce8d17a70a2f00367 /moonv4/tests/utils
parent14665f2c9f093fee6630d1f66d2556ddb97f814a (diff)
push the modifications from moonv4/templates/moonforming to moonv4/tests
Change-Id: Id9abe1c299f2cfbf95c5026d74ccb74c1429834e
Diffstat (limited to 'moonv4/tests/utils')
-rw-r--r--moonv4/tests/utils/pdp.py8
-rw-r--r--moonv4/tests/utils/policies.py5
2 files changed, 12 insertions, 1 deletions
diff --git a/moonv4/tests/utils/pdp.py b/moonv4/tests/utils/pdp.py
index 4f513aa6..f3c6df37 100644
--- a/moonv4/tests/utils/pdp.py
+++ b/moonv4/tests/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'],
@@ -15,7 +17,7 @@ KEYSTONE_SERVER = config['openstack']['keystone']['url']
pdp_template = {
"name": "test_pdp",
"security_pipeline": [],
- "keystone_project_id": "",
+ "keystone_project_id": None,
"description": "test",
}
@@ -46,6 +48,8 @@ def get_keystone_projects():
}
req = requests.post("{}/auth/tokens".format(KEYSTONE_SERVER), json=data_auth, headers=HEADERS)
+ 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
@@ -95,6 +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)
+ 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/tests/utils/policies.py b/moonv4/tests/utils/policies.py
index df7f5f57..bd08291a 100644
--- a/moonv4/tests/utils/policies.py
+++ b/moonv4/tests/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