requests_log.setLevel(logging.WARNING)
requests_log.propagate = True
-logger = logging.getLogger(__name__)
+logger = logging.getLogger("moonforming")
if args.filename:
print("Loading: {}".format(args.filename[0]))
+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'],
pdp_template = {
"name": "test_pdp",
"security_pipeline": [],
- "keystone_project_id": "",
+ "keystone_project_id": None,
"description": "test",
}
}
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
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
+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 + "{}"
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