diff options
Diffstat (limited to 'test/mocks/ran-nssmf-simulator/test')
4 files changed, 36 insertions, 0 deletions
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" } |