aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_interface/tests/apitests/utils
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2017-07-06 15:37:03 +0200
committerasteroide <thomas.duval@orange.com>2017-07-06 15:37:03 +0200
commit5cc39c4b3a2de6d670f357ed3329a4d6587c7fc7 (patch)
tree76f4220f458f073f24e3d3a2fc11d66d397f697e /moonv4/moon_interface/tests/apitests/utils
parent19dd4e461d1239754bd1a82e30f2a770c99a7f90 (diff)
Update test and visualization scripts
Change-Id: I62d50d8d3e839a1d6c8ff948cc84ecc45bb0e92f
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]