Skip to content

Commit

Permalink
add tests for ssl_verify
Browse files Browse the repository at this point in the history
  • Loading branch information
scetron committed Feb 5, 2024
1 parent ba44755 commit 4256838
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/unit/test_nautobot_inventory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pytest of Nautobot Inventory."""

# Standard Library Imports
from os import path

Expand All @@ -23,11 +24,26 @@
"url": "http://mock.example.com/api/",
"method": "get",
},
{
"fixture_path": f"{HERE}/mocks/00_api_root.json",
"url": "https://mock.example.com/api/",
"method": "get",
},
{
"fixture_path": f"{HERE}/mocks/01_get_devices.json",
"url": "http://mock.example.com/api/dcim/devices/?depth=1",
"method": "get",
},
{
"fixture_path": f"{HERE}/mocks/01_get_devices.json",
"url": "https://mock.example.com/api/dcim/devices/?depth=1",
"method": "get",
},
{
"fixture_path": f"{HERE}/mocks/01_get_devices.json",
"url": "https://mock.example.com/api/dcim/devices/?depth=1&limit=0",
"method": "get",
},
{
"fixture_path": f"{HERE}/mocks/02_get_device1.json",
"url": "http://mock.example.com/api/dcim/devices/?name=den-dist01",
Expand Down Expand Up @@ -89,6 +105,28 @@ def test_nornir_nautobot_initialization():
assert no_exception_found


def test_nornir_nautobot_initialization_ssl_verify_default():
with Mocker() as mock:
load_api_calls(mock)
nornir_nautobot_class = NautobotInventory(
nautobot_url="https://mock.example.com", nautobot_token="0123456789abcdef01234567890"
)
assert nornir_nautobot_class.pynautobot_obj.http_session.verify == True
assert nornir_nautobot_class.api_session.verify == True
assert nornir_nautobot_class.ssl_verify == True


def test_nornir_nautobot_initialization_ssl_verify_false():
with Mocker() as mock:
load_api_calls(mock)
nornir_nautobot_class = NautobotInventory(
nautobot_url="https://mock.example.com", nautobot_token="0123456789abcdef01234567890", ssl_verify=False
)
assert nornir_nautobot_class.pynautobot_obj.http_session.verify == False
assert nornir_nautobot_class.api_session.verify == False
assert nornir_nautobot_class.ssl_verify == False


def test_nornir_nautobot_missing_url():
with pytest.raises(ValueError) as err:
NautobotInventory(nautobot_url=None, nautobot_token="0123456789abcdef01234567890")
Expand Down

0 comments on commit 4256838

Please sign in to comment.