Skip to content
Snippets Groups Projects
Verified Commit e9a7d85d authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

remove the need for keeping an extra copy of example configuration inside conftest.py

Just use the oss-params-example.json from now on
parent b1a5e7bd
No related branches found
No related tags found
1 merge request!171Externalise the high ISIS metric into oss-params
Pipeline #85875 passed
...@@ -16,37 +16,37 @@ ...@@ -16,37 +16,37 @@
"password": "robot-user-password" "password": "robot-user-password"
}, },
"LO": { "LO": {
"V4": {"containers": [], "networks": ["1.1.0.0/24"], "mask": 0}, "V4": {"containers": [], "networks": ["10.255.255.0/26"], "mask": 32},
"V6": {"containers": [], "networks": ["dead:beef::/64"], "mask": 0}, "V6": {"containers": [], "networks": ["dead:beef::/80"], "mask": 128},
"domain_name": ".lo", "domain_name": ".geant.net",
"dns_view": "default", "dns_view": "default",
"network_view": "default" "network_view": "default"
}, },
"TRUNK": { "TRUNK": {
"V4": {"containers": ["1.1.1.0/24"], "networks": [], "mask": 31}, "V4": {"containers": ["10.255.255.0/24", "10.255.254.0/24"], "networks": [], "mask": 31},
"V6": {"containers": ["dead:beef::/64"], "networks": [], "mask": 126}, "V6": {"containers": ["dead:beef::/64", "dead:beee::/64"], "networks": [], "mask": 126},
"domain_name": ".trunk", "domain_name": ".trunk",
"dns_view": "default", "dns_view": "default",
"network_view": "default" "network_view": "default"
}, },
"GEANT_IP": { "GEANT_IP": {
"V4": {"containers": ["1.1.2.0/24"], "networks": [], "mask": 31}, "V4": {"containers": ["10.255.255.0/24", "10.255.254.0/24"], "networks": [], "mask": 31},
"V6": {"containers": ["dead:beef::/64"], "networks": [], "mask": 126}, "V6": {"containers": ["dead:beef::/64", "dead:beee::/64"], "networks": [], "mask": 126},
"domain_name": ".geantip", "domain_name": ".geantip",
"dns_view": "default", "dns_view": "default",
"network_view": "default" "network_view": "default"
}, },
"SI": { "SI": {
"V4": {"containers": ["1.1.3.0/24"], "networks": [], "mask": 31}, "V4": {"containers": ["10.255.253.128/25"], "networks": [], "mask": 31},
"V6": {"containers": ["dead:beef::/64"], "networks": [], "mask": 126}, "V6": {"containers": [], "networks": [], "mask": 126},
"domain_name": ".si", "domain_name": ".geantip",
"dns_view": "default", "dns_view": "default",
"network_view": "default" "network_view": "default"
}, },
"LT_IAS": { "LT_IAS": {
"V4": {"containers": ["1.1.4.0/24"], "networks": [], "mask": 31}, "V4": {"containers": ["10.255.255.0/24"], "networks": [], "mask": 31},
"V6": {"containers": ["dead:beef::/64"], "networks": [], "mask": 126}, "V6": {"containers": ["dead:beef:cc::/48"], "networks": [], "mask": 126},
"domain_name": ".ltias", "domain_name": ".geantip",
"dns_view": "default", "dns_view": "default",
"network_view": "default" "network_view": "default"
} }
......
...@@ -11,7 +11,7 @@ def test_router_subscriptions_endpoint_with_valid_api_key(test_client, nokia_rou ...@@ -11,7 +11,7 @@ def test_router_subscriptions_endpoint_with_valid_api_key(test_client, nokia_rou
nokia_router_subscription_factory(status=SubscriptionLifecycle.INITIAL) nokia_router_subscription_factory(status=SubscriptionLifecycle.INITIAL)
response = test_client.get( response = test_client.get(
ROUTER_SUBSCRIPTION_ENDPOINT, headers={"Authorization": "Bearer REALY_random_AND_3cure_T0keN"} ROUTER_SUBSCRIPTION_ENDPOINT, headers={"Authorization": "Bearer another_REALY_random_AND_3cure_T0keN"}
) )
assert response.status_code == 200 assert response.status_code == 200
......
import contextlib import contextlib
import json
import logging import logging
import os import os
import socket
import tempfile
from pathlib import Path from pathlib import Path
import orchestrator import orchestrator
...@@ -91,149 +88,14 @@ def faker() -> Faker: ...@@ -91,149 +88,14 @@ def faker() -> Faker:
return fake return fake
@pytest.fixture(scope="session")
def configuration_data() -> dict:
with contextlib.closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
s.bind(("", 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
yield {
"GENERAL": {"public_hostname": "https://orchestrator.dev.gap.geant.org", "isis_high_metric": 999999},
"NETBOX": {"api": "https://127.0.0.1:8000", "token": "TOKEN"},
"IPAM": {
"INFOBLOX": {
"scheme": "https",
"wapi_version": "2.12",
"host": "10.0.0.1",
"username": "robot-user",
"password": "robot-user-password",
},
"LO": {
"V4": {
"containers": [],
"networks": ["10.255.255.0/26"],
"mask": 32,
},
"V6": {
"containers": [],
"networks": ["dead:beef::/80"],
"mask": 128,
},
"domain_name": ".geant.net",
"dns_view": "default",
"network_view": "default",
},
"TRUNK": {
"V4": {
"containers": ["10.255.255.0/24", "10.255.254.0/24"],
"networks": [],
"mask": 31,
},
"V6": {
"containers": ["dead:beef::/64", "dead:beee::/64"],
"networks": [],
"mask": 126,
},
"domain_name": ".trunk",
"dns_view": "default",
"network_view": "default",
},
"GEANT_IP": {
"V4": {
"containers": ["10.255.255.0/24", "10.255.254.0/24"],
"networks": [],
"mask": 31,
},
"V6": {
"containers": ["dead:beef::/64", "dead:beee::/64"],
"networks": [],
"mask": 126,
},
"domain_name": ".geantip",
"dns_view": "default",
"network_view": "default",
},
"SI": {
"V4": {
"containers": ["10.255.253.128/25"],
"networks": [],
"mask": 31,
},
"V6": {"containers": [], "networks": [], "mask": 126},
"domain_name": ".geantip",
"dns_view": "default",
"network_view": "default",
},
"LT_IAS": {
"V4": {
"containers": ["10.255.255.0/24"],
"networks": [],
"mask": 31,
},
"V6": {
"containers": ["dead:beef:cc::/48"],
"networks": [],
"mask": 126,
},
"domain_name": ".geantip",
"dns_view": "default",
"network_view": "default",
},
},
"MONITORING": {
"LIBRENMS": {
"base_url": "http://librenms",
"token": "secret-token",
},
"SNMP": {
"v2c": {
"community": "fake-community",
},
"v3": {
"authlevel": "AuthPriv",
"authname": "librenms",
"authpass": "<password1>",
"authalgo": "sha",
"cryptopass": "<password2>",
"cryptoalgo": "aes",
},
},
},
"PROVISIONING_PROXY": {
"scheme": "https",
"api_base": "localhost:44444",
"auth": "Bearer <token>",
"api_version": 1123,
},
"CELERY": {
"broker_url": "redis://localhost:6379",
"result_backend": "rpc://localhost:6379/0",
"result_expires": 3600,
},
"THIRD_PARTY_API_KEYS": {
"AnsibleDynamicInventoryGenerator": "REALY_random_AND_3cure_T0keN",
"Application_2": "another_REALY_random_AND_3cure_T0keN",
},
"EMAIL": {
"from_address": "noreply@nren.local",
"smtp_host": "smtp.nren.local",
"smtp_port": 487,
"starttls_enabled": True,
"smtp_username": "username",
"smtp_password": "password",
},
}
@pytest.fixture(scope="session", autouse=True) @pytest.fixture(scope="session", autouse=True)
def data_config_filename(configuration_data) -> str: def data_config_filename() -> str:
"""Create a temporary file with configuration data and set an environment variable to its path.""" """Set an environment variable to the path of the example OSS parameters file."""
with tempfile.NamedTemporaryFile(mode="w+", delete=False) as f: config_filename = "gso/oss-params-example.json"
json.dump(configuration_data, f, ensure_ascii=False)
os.environ["OSS_PARAMS_FILENAME"] = f.name
yield f.name os.environ["OSS_PARAMS_FILENAME"] = config_filename
yield config_filename
del os.environ["OSS_PARAMS_FILENAME"] del os.environ["OSS_PARAMS_FILENAME"]
Path(f.name).unlink()
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment