aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mocks/ran-nssmf-simulator/.gitignore4
-rw-r--r--test/mocks/ran-nssmf-simulator/test-requirements.txt2
-rw-r--r--test/mocks/ran-nssmf-simulator/test/conftest.py13
-rw-r--r--test/mocks/ran-nssmf-simulator/test/test_auth.json7
-rw-r--r--test/mocks/ran-nssmf-simulator/test/test_main.py10
-rw-r--r--test/mocks/ran-nssmf-simulator/test/test_settings.py6
-rw-r--r--test/mocks/ran-nssmf-simulator/tox.ini10
7 files changed, 52 insertions, 0 deletions
diff --git a/test/mocks/ran-nssmf-simulator/.gitignore b/test/mocks/ran-nssmf-simulator/.gitignore
new file mode 100644
index 000000000..2b5a0df16
--- /dev/null
+++ b/test/mocks/ran-nssmf-simulator/.gitignore
@@ -0,0 +1,4 @@
+__pycache__
+.tox
+*.pyc
+RanNssmfSimulator.egg-info/
diff --git a/test/mocks/ran-nssmf-simulator/test-requirements.txt b/test/mocks/ran-nssmf-simulator/test-requirements.txt
new file mode 100644
index 000000000..547de5c5b
--- /dev/null
+++ b/test/mocks/ran-nssmf-simulator/test-requirements.txt
@@ -0,0 +1,2 @@
+pytest
+requests
diff --git a/test/mocks/ran-nssmf-simulator/test/conftest.py b/test/mocks/ran-nssmf-simulator/test/conftest.py
new file mode 100644
index 000000000..cfa00cd24
--- /dev/null
+++ b/test/mocks/ran-nssmf-simulator/test/conftest.py
@@ -0,0 +1,13 @@
+import pytest
+from test_settings import TEST_AUTH_DB_FILE
+from json import load
+import requests
+from requests.packages.urllib3.exceptions import InsecureRequestWarning
+
+requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
+
+@pytest.fixture(scope="module")
+def auth_credentials():
+ '''A fixture returning credentials for the simulator request'''
+ with open(TEST_AUTH_DB_FILE) as creds:
+ return load(creds)
diff --git a/test/mocks/ran-nssmf-simulator/test/test_auth.json b/test/mocks/ran-nssmf-simulator/test/test_auth.json
new file mode 100644
index 000000000..b8f6f93bd
--- /dev/null
+++ b/test/mocks/ran-nssmf-simulator/test/test_auth.json
@@ -0,0 +1,7 @@
+[
+ {
+ "grantType": "password",
+ "userName": "testuser",
+ "value": "Vue&W{ah0uch|ae&"
+ }
+]
diff --git a/test/mocks/ran-nssmf-simulator/test/test_main.py b/test/mocks/ran-nssmf-simulator/test/test_main.py
new file mode 100644
index 000000000..337b99997
--- /dev/null
+++ b/test/mocks/ran-nssmf-simulator/test/test_main.py
@@ -0,0 +1,10 @@
+from requests import post, codes
+from test_settings import TEST_REST_URL, TEST_REST_GET_ACCESS_TOKEN_ENDPOINT, TEST_REST_HEADERS
+
+def test_get_auth_token(auth_credentials):
+ url = f"{TEST_REST_URL}{TEST_REST_GET_ACCESS_TOKEN_ENDPOINT}"
+ response = post(url, headers=TEST_REST_HEADERS, verify=False, json=auth_credentials[0])
+ json_response = response.json()
+ assert "accessToken" in json_response
+ assert "expires" in json_response
+ assert response.status_code == codes.created
diff --git a/test/mocks/ran-nssmf-simulator/test/test_settings.py b/test/mocks/ran-nssmf-simulator/test/test_settings.py
new file mode 100644
index 000000000..445d9728f
--- /dev/null
+++ b/test/mocks/ran-nssmf-simulator/test/test_settings.py
@@ -0,0 +1,6 @@
+TEST_AUTH_DB_FILE = "test/test_auth.json"
+TEST_REST_PORT = 8443
+TEST_REST_IP = "127.0.0.1"
+TEST_REST_URL = f"https://{TEST_REST_IP}:{TEST_REST_PORT}"
+TEST_REST_GET_ACCESS_TOKEN_ENDPOINT = "/api/rest/securityManagement/v1/oauth/token"
+TEST_REST_HEADERS = { "Content-Type": "application/json" }
diff --git a/test/mocks/ran-nssmf-simulator/tox.ini b/test/mocks/ran-nssmf-simulator/tox.ini
new file mode 100644
index 000000000..a874ee4a7
--- /dev/null
+++ b/test/mocks/ran-nssmf-simulator/tox.ini
@@ -0,0 +1,10 @@
+[tox]
+envlist =nssmf
+
+[testenv]
+basepython = python3
+deps = -r{toxinidir}/test-requirements.txt
+
+[testenv:nssmf]
+commands_pre = /bin/bash -c "RAN_NSSMF_REST_PORT=8443 RAN_NSSMF_AUTH_DB=test/test_auth.json python main.py &"
+commands = pytest -v