aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_interface/tests/apitests/utils
diff options
context:
space:
mode:
Diffstat (limited to 'moonv4/moon_interface/tests/apitests/utils')
-rw-r--r--moonv4/moon_interface/tests/apitests/utils/models.py8
-rw-r--r--moonv4/moon_interface/tests/apitests/utils/policies.py13
2 files changed, 18 insertions, 3 deletions
diff --git a/moonv4/moon_interface/tests/apitests/utils/models.py b/moonv4/moon_interface/tests/apitests/utils/models.py
index 8343f77e..5039d185 100644
--- a/moonv4/moon_interface/tests/apitests/utils/models.py
+++ b/moonv4/moon_interface/tests/apitests/utils/models.py
@@ -1,7 +1,13 @@
import requests
import copy
+import configparser
-URL = "http://172.18.0.11:38001{}"
+config = configparser.ConfigParser()
+if not config.read("moon.conf"):
+ config.read("/etc/moon/moon.conf")
+
+URL = "http://{}:{}".format(config['interface']['host'], config['interface']['port'])
+URL = URL + "{}"
HEADERS = {"content-type": "application/json"}
model_template = {
diff --git a/moonv4/moon_interface/tests/apitests/utils/policies.py b/moonv4/moon_interface/tests/apitests/utils/policies.py
index e6df7f71..444f34d7 100644
--- a/moonv4/moon_interface/tests/apitests/utils/policies.py
+++ b/moonv4/moon_interface/tests/apitests/utils/policies.py
@@ -1,6 +1,12 @@
import requests
+import configparser
-URL = "http://172.18.0.11:38001{}"
+config = configparser.ConfigParser()
+if not config.read("moon.conf"):
+ config.read("/etc/moon/moon.conf")
+
+URL = "http://{}:{}".format(config['interface']['host'], config['interface']['port'])
+URL = URL + "{}"
HEADERS = {"content-type": "application/json"}
FILE = open("/tmp/test.log", "w")
@@ -580,7 +586,10 @@ def add_rule(policy_id, meta_rule_id, rule, instructions={"chain": [{"security_p
assert req.status_code == 200
result = req.json()
assert "rules" in result
- rule_id = list(result["rules"].keys())[0]
+ try:
+ rule_id = list(result["rules"].keys())[0]
+ except Exception as e:
+ return False
assert "policy_id" in result["rules"][rule_id]
assert policy_id == result["rules"][rule_id]["policy_id"]
assert "meta_rule_id" in result["rules"][rule_id]