Skip to content

Commit

Permalink
Release/v2.8.0 (#124)
Browse files Browse the repository at this point in the history
* SIMPLE-7063 Added group_display_attribute and refactored test_auth (#122)

  Do not fail if importing topologies for previous CML versions

* Removed unexpected behavior of import lab method (#120)

  When a lab with a specific title existed on a CML instance,
  we joined that lab instead of creating a new lab with the same
  title which would had been perfectly fine.  I believe that this
  was some obsolete feature request from pre-CML 2.0 era where labs
  possibly were enforced to have unique titles.

* SIMPLE-6969 Changed PUT to PATCH for /system/auth/config

* SIMPLE-6964 Dropped smart annotation tag and font properties (#119)

* SIMPLE-6883 Support for smart annotations (#118)

* SIMPLE-6813 Added deployed_mac_address property to Interface (#116)

* SIMPLE-6776 local groups should still work with unset group filter (#115)

* SIMPLE-6827 - removed MAC address block support (#114)

* Dropped support for python3.8 in github actions

* SIMPLE-6834 integration tests for ldap groups (#113)

* Added the virlutils option to disable SSL check via ENV (#111)

* SIMPLE-6706 fixed the 'owner' attribute of a joined lab (#108)

* SIMPLE-6764 ldap group tests and system auth test (#110)

* SIMPLE-6615 custom mac addresses implementation (#106)

* SIMPLE-6397 Added support for 2.8, updated obsolete controller versions (#102)

* SIMPLE-6345 refactored API error handling for better tracebacks (#98)

* SIMPLE-6506 removed/deprecated offline mode leftovers (#97)

* SIMPLE-6429 fix potentially mishandled data structures (#94)

* SIMPLE-6384 Added rotation attribute to ellipse and rectangle annotations (#96)

* Re-added api/* to the doc source tree removed by mistake

* SIMPLE-6410 SQ issues is PCL (#90)
  • Loading branch information
tmikuska committed Nov 21, 2024
1 parent 2b9e98f commit 72ff767
Show file tree
Hide file tree
Showing 31 changed files with 2,746 additions and 1,533 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v2
Expand All @@ -32,7 +37,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi
pip install -r tests/requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
12 changes: 9 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: [--profile, black]
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.8.0
hooks:
- id: black
language_version: python3
7 changes: 4 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

sys.path.insert(0, os.path.abspath("../virl2_client"))

VIRL2_DOC = "virl2_client Documentation"

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -139,7 +140,7 @@
(
master_doc,
"virl2_client.tex",
"virl2_client Documentation",
VIRL2_DOC,
"VIRL2 team <[email protected]>",
"manual",
),
Expand All @@ -150,7 +151,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "virl2_client", "virl2_client Documentation", [author], 1)]
man_pages = [(master_doc, "virl2_client", VIRL2_DOC, [author], 1)]


# -- Options for Texinfo output ----------------------------------------------
Expand All @@ -162,7 +163,7 @@
(
master_doc,
"virl2_client",
"virl2_client Documentation",
VIRL2_DOC,
author,
"virl2_client",
"One line description of project.",
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CML 2 controller.

intro
examples
api/*

.. only:: internal

Expand Down
2,359 changes: 1,263 additions & 1,096 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "virl2_client"
version = "2.7.1"
version = "2.8.0"
description = "VIRL2 Client Library"
authors = ["Simon Knight <[email protected]>", "Ralph Schmieder <[email protected]>"]
license = "Apache-2.0"
Expand All @@ -15,13 +15,13 @@ classifiers = [
"Environment :: Console",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.12",
"Topic :: System :: Networking",
]

[tool.poetry.dependencies]
python = "^3.8.1"
httpx = "^0.26.0"
python = "^3.9.0"
httpx = "^0.27.0"

# https://github.com/python-poetry/poetry/pull/606 -- no support for optional dev-deps
# optional package for events
Expand All @@ -33,15 +33,15 @@ aiohttp = {version = "^3.8", optional = true}
pyats = {version = "^24", optional = true}

# optional packages for documentation build
sphinx_rtd_theme = {version="^1", optional = true}
sphinx_rtd_theme = {version="^2", optional = true}
# version 8 is available but requires python>=3.10
sphinx = {version="^7", optional = true}

[tool.poetry.group.dev.dependencies]
flake8 = "^7"
pre-commit = "^3"
# https://github.com/pytest-dev/pytest-asyncio/issues/737
pytest = "<8"
respx = "^0.20.0"
pytest = "*"
respx = "^0.21.0"

[tool.poetry.extras]
events = ["aiohttp"]
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ addopts =
junit_family=xunit1

asyncio_mode=auto
asyncio_default_fixture_loop_scope=function

# start pytest with --log-level=info
# log_cli=True
Expand Down
11 changes: 4 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import httpx
import pytest

from virl2_client.models import authentication
from virl2_client.virl2_client import ClientLibrary

CURRENT_VERSION = ClientLibrary.VERSION.version_str
Expand All @@ -48,11 +49,6 @@ def client_library_server_2_0_0():
yield from client_library_patched_system_info(version="2.0.0")


@pytest.fixture
def client_library_server_1_0_0():
yield from client_library_patched_system_info(version="1.0.0")


@pytest.fixture
def client_library_server_2_9_0():
yield from client_library_patched_system_info(version="2.9.0")
Expand All @@ -65,7 +61,7 @@ def client_library_server_2_19_0():

@pytest.fixture
def mocked_session():
with patch.object(httpx, "Client", autospec=True) as session:
with patch.object(authentication, "CustomClient", autospec=True) as session:
yield session


Expand Down Expand Up @@ -97,13 +93,14 @@ def respx_mock_with_labs(respx_mock):
some runtime data, like node states and simulation_statistics.
"""
respx_mock.get(FAKE_HOST_API + "system_information").respond(
json={"version": CURRENT_VERSION, "ready": True},
json={"version": CURRENT_VERSION, "ready": True, "oui": "52:54:00:00:00:00"},
)
respx_mock.post(FAKE_HOST_API + "authenticate").respond(json="BOGUS_TOKEN")
respx_mock.get(FAKE_HOST_API + "authok")
respx_mock.get(
FAKE_HOST_API + "labs/444a78d1-575c-4746-8469-696e580f17b6/resource_pools"
).respond(json=[])
respx_mock.get(FAKE_HOST_API + "users").respond(json=[])
respx_mock.get(FAKE_HOST_API + "resource_pools?data=true").respond(json=[])
nodes = [
"99cda47a-ecb2-4d31-86c4-74e7a8201958",
Expand Down
59 changes: 29 additions & 30 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
anyio==4.3.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
certifi==2024.2.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
cfgv==3.4.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
colorama==0.4.6 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" and sys_platform == "win32"
distlib==0.3.8 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
exceptiongroup==1.2.1 ; python_full_version >= "3.8.1" and python_version < "3.11"
filelock==3.14.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
flake8==7.0.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
h11==0.14.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
httpcore==1.0.5 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
httpx==0.26.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
identify==2.5.36 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
idna==3.7 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
iniconfig==2.0.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
mccabe==0.7.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
nodeenv==1.8.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
packaging==24.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
platformdirs==4.2.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
pluggy==1.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
pre-commit==3.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
pycodestyle==2.11.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
pyflakes==3.2.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
pytest==7.4.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
pyyaml==6.0.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
respx==0.20.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
setuptools==69.5.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
sniffio==1.3.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
tomli==2.0.1 ; python_full_version >= "3.8.1" and python_version < "3.11"
typing-extensions==4.11.0 ; python_full_version >= "3.8.1" and python_version < "3.11"
virtualenv==20.26.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
anyio==4.6.1 ; python_version >= "3.9" and python_full_version < "4.0.0"
certifi==2024.8.30 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
cfgv==3.4.0 ; python_version >= "3.9" and python_full_version < "4.0.0"
colorama==0.4.6 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0" and sys_platform == "win32"
distlib==0.3.9 ; python_version >= "3.9" and python_full_version < "4.0.0"
exceptiongroup==1.2.2 ; python_version >= "3.9" and python_version < "3.11"
filelock==3.16.1 ; python_version >= "3.9" and python_full_version < "4.0.0"
flake8==7.1.1 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
h11==0.14.0 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
httpcore==1.0.6 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
httpx==0.27.2 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
identify==2.6.1 ; python_version >= "3.9" and python_full_version < "4.0.0"
idna==3.10 ; python_version >= "3.9" and python_full_version < "4.0.0"
iniconfig==2.0.0 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
mccabe==0.7.0 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
nodeenv==1.9.1 ; python_version >= "3.9" and python_full_version < "4.0.0"
packaging==24.1 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
platformdirs==4.3.6 ; python_version >= "3.9" and python_full_version < "4.0.0"
pluggy==1.5.0 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
pre-commit==3.8.0 ; python_version >= "3.9" and python_full_version < "4.0.0"
pycodestyle==2.12.1 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
pyflakes==3.2.0 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
pytest==8.3.3 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
pyyaml==6.0.2 ; python_version >= "3.9" and python_full_version < "4.0.0"
respx==0.21.1 ; python_full_version >= "3.9.0" and python_full_version < "4.0.0"
sniffio==1.3.1 ; python_version >= "3.9" and python_full_version < "4.0.0"
tomli==2.0.2 ; python_full_version >= "3.9.0" and python_version < "3.11"
typing-extensions==4.12.2 ; python_version >= "3.9" and python_version < "3.11"
virtualenv==20.26.6 ; python_version >= "3.9" and python_full_version < "4.0.0"
35 changes: 11 additions & 24 deletions tests/test_client_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,17 @@ def test_import_lab_from_path_virl(
Lab.sync = Mock()

(tmp_path / "topology.virl").write_text("<?xml version='1.0' encoding='UTF-8'?>")
with patch.object(Lab, "sync", autospec=True) as sync_mock:
lab = cl.import_lab_from_path(path=(tmp_path / "topology.virl").as_posix())
lab = cl.import_lab_from_path(path=(tmp_path / "topology.virl").as_posix())

assert lab.title is not None
assert lab._url_for("lab").startswith("labs/")

cl._session.post.assert_called_once_with(
"import/virl-1x",
params=None,
content="<?xml version='1.0' encoding='UTF-8'?>",
)
cl._session.post.assert_called_once()
sync_mock.assert_called_once_with()


@python37_or_newer
Expand All @@ -94,10 +93,9 @@ def test_import_lab_from_path_virl_title(
Lab.sync = Mock()
new_title = "new_title"
(tmp_path / "topology.virl").write_text("<?xml version='1.0' encoding='UTF-8'?>")
with patch.object(Lab, "sync", autospec=True):
lab = cl.import_lab_from_path(
path=(tmp_path / "topology.virl").as_posix(), title=new_title
)
lab = cl.import_lab_from_path(
path=(tmp_path / "topology.virl").as_posix(), title=new_title
)
assert lab.title is not None
assert lab._url_for("lab").startswith("labs/")

Expand Down Expand Up @@ -142,15 +140,13 @@ def initial_different_response(initial, subsequent=httpx.Response(200)):
while True:
yield subsequent

# mock failed and successful authentication:
respx.post(
"https://0.0.0.0/fake_url/api/v0/authenticate"
).side_effect = initial_different_response(
# mock failed and successful authentication
side_effect = initial_different_response(
httpx.Response(403), httpx.Response(200, json="7bbcan78a98bch7nh3cm7hao3nc7")
)
respx.get(
"https://0.0.0.0/fake_url/api/v0/authok"
).side_effect = initial_different_response(httpx.Response(401))
respx.post("https://0.0.0.0/fake_url/api/v0/authenticate").side_effect = side_effect
side_effect = initial_different_response(httpx.Response(401))
respx.get("https://0.0.0.0/fake_url/api/v0/authok").side_effect = side_effect

# mock get labs
respx.get("https://0.0.0.0/fake_url/api/v0/labs").respond(json=[])
Expand Down Expand Up @@ -367,15 +363,6 @@ def test_client_library_str_and_repr(client_library_server_current):
assert str(client_library) == "ClientLibrary URL: https://somehost/api/v0/"


def test_major_version_mismatch(client_library_server_1_0_0):
with pytest.raises(InitializationError) as err:
ClientLibrary("somehost", "virl2", password="virl2")
assert (
str(err.value)
== f"Major version mismatch. Client {CURRENT_VERSION}, controller 1.0.0."
)


def test_incompatible_version(client_library_server_2_0_0):
with pytest.raises(InitializationError) as err:
with patch.object(
Expand Down Expand Up @@ -714,7 +701,7 @@ def test_different_version_strings():
Version("54dev0+build8.7ee86bf8")


def test_import_lab_offline(
def test_import_lab_offline_deprecated(
client_library_server_current, mocked_session, tmp_path: Path, test_dir
):
client_library = ClientLibrary(
Expand Down
Loading

0 comments on commit 72ff767

Please sign in to comment.