aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_interface/tests/apitests
diff options
context:
space:
mode:
Diffstat (limited to 'moonv4/moon_interface/tests/apitests')
-rw-r--r--moonv4/moon_interface/tests/apitests/utils/models.py25
-rw-r--r--moonv4/moon_interface/tests/apitests/utils/pdp.py34
-rw-r--r--moonv4/moon_interface/tests/apitests/utils/policies.py24
3 files changed, 63 insertions, 20 deletions
diff --git a/moonv4/moon_interface/tests/apitests/utils/models.py b/moonv4/moon_interface/tests/apitests/utils/models.py
index 5039d185..68133b5b 100644
--- a/moonv4/moon_interface/tests/apitests/utils/models.py
+++ b/moonv4/moon_interface/tests/apitests/utils/models.py
@@ -1,12 +1,27 @@
+import os
+import yaml
import requests
import copy
-import configparser
-config = configparser.ConfigParser()
-if not config.read("moon.conf"):
- config.read("/etc/moon/moon.conf")
-URL = "http://{}:{}".format(config['interface']['host'], config['interface']['port'])
+for path in (
+ "moon.conf",
+ "../moon.conf",
+ "{}/moon_orchestrator/conf/moon.conf".format(os.getenv("MOON_HOME")),
+ "/etc/moon/moon.conf"
+):
+ try:
+ config = yaml.safe_load(open(path))
+ except FileNotFoundError:
+ config = None
+ continue
+ else:
+ print("Using {}".format(path))
+ break
+if not config:
+ raise Exception("Configuration file not found...")
+
+URL = "http://{}:{}".format(config['components']['interface']['hostname'], config['components']['interface']['port'])
URL = URL + "{}"
HEADERS = {"content-type": "application/json"}
diff --git a/moonv4/moon_interface/tests/apitests/utils/pdp.py b/moonv4/moon_interface/tests/apitests/utils/pdp.py
index 6a27224e..03259818 100644
--- a/moonv4/moon_interface/tests/apitests/utils/pdp.py
+++ b/moonv4/moon_interface/tests/apitests/utils/pdp.py
@@ -1,16 +1,30 @@
+import os
+import yaml
import requests
-import configparser
-config = configparser.ConfigParser()
-if not config.read("moon.conf"):
- config.read("/etc/moon/moon.conf")
-
-URL = "http://{}:{}".format(config['interface']['host'], config['interface']['port'])
+for path in (
+ "moon.conf",
+ "../moon.conf",
+ "{}/moon_orchestrator/conf/moon.conf".format(os.getenv("MOON_HOME")),
+ "/etc/moon/moon.conf"
+):
+ try:
+ config = yaml.safe_load(open(path))
+ except FileNotFoundError:
+ config = None
+ continue
+ else:
+ print("Using {}".format(path))
+ break
+if not config:
+ raise Exception("Configuration file not found...")
+
+URL = "http://{}:{}".format(config['components']['interface']['hostname'], config['components']['interface']['port'])
HEADERS = {"content-type": "application/json"}
-KEYSTONE_USER = config['keystone']['user']
-KEYSTONE_PASSWORD = config['keystone']['password']
-KEYSTONE_PROJECT = config['keystone']['project']
-KEYSTONE_SERVER = config['keystone']['url']
+KEYSTONE_USER = config['openstack']['keystone']['user']
+KEYSTONE_PASSWORD = config['openstack']['keystone']['password']
+KEYSTONE_PROJECT = config['openstack']['keystone']['project']
+KEYSTONE_SERVER = config['openstack']['keystone']['url']
pdp_template = {
"name": "test_pdp",
diff --git a/moonv4/moon_interface/tests/apitests/utils/policies.py b/moonv4/moon_interface/tests/apitests/utils/policies.py
index 444f34d7..fdde92ef 100644
--- a/moonv4/moon_interface/tests/apitests/utils/policies.py
+++ b/moonv4/moon_interface/tests/apitests/utils/policies.py
@@ -1,11 +1,25 @@
+import os
+import yaml
import requests
-import configparser
-config = configparser.ConfigParser()
-if not config.read("moon.conf"):
- config.read("/etc/moon/moon.conf")
+for path in (
+ "moon.conf",
+ "../moon.conf",
+ "{}/moon_orchestrator/conf/moon.conf".format(os.getenv("MOON_HOME")),
+ "/etc/moon/moon.conf"
+):
+ try:
+ config = yaml.safe_load(open(path))
+ except FileNotFoundError:
+ config = None
+ continue
+ else:
+ print("Using {}".format(path))
+ break
+if not config:
+ raise Exception("Configuration file not found...")
-URL = "http://{}:{}".format(config['interface']['host'], config['interface']['port'])
+URL = "http://{}:{}".format(config['components']['interface']['hostname'], config['components']['interface']['port'])
URL = URL + "{}"
HEADERS = {"content-type": "application/json"}
FILE = open("/tmp/test.log", "w")