Skip to content

Commit

Permalink
fix(anta.tests): Fix wrong type used for inputs for VerifyInterfaceIP…
Browse files Browse the repository at this point in the history
…v4 (#977)
  • Loading branch information
gmuloc authored Dec 24, 2024
1 parent 5afc61d commit 4e13729
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions anta/tests/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from __future__ import annotations

import re
from ipaddress import IPv4Network
from ipaddress import IPv4Interface
from typing import Any, ClassVar

from pydantic import BaseModel, Field
Expand Down Expand Up @@ -629,9 +629,9 @@ class VerifyInterfaceIPv4(AntaTest):
- VerifyInterfaceIPv4:
interfaces:
- name: Ethernet2
primary_ip: 172.30.11.0/31
primary_ip: 172.30.11.1/31
secondary_ips:
- 10.10.10.0/31
- 10.10.10.1/31
- 10.10.10.10/31
```
"""
Expand All @@ -651,9 +651,9 @@ class InterfaceDetail(BaseModel):

name: Interface
"""Name of the interface."""
primary_ip: IPv4Network
primary_ip: IPv4Interface
"""Primary IPv4 address in CIDR notation."""
secondary_ips: list[IPv4Network] | None = None
secondary_ips: list[IPv4Interface] | None = None
"""Optional list of secondary IPv4 addresses in CIDR notation."""

def render(self, template: AntaTemplate) -> list[AntaCommand]:
Expand Down
4 changes: 2 additions & 2 deletions examples/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ anta.tests.interfaces:
# Verifies the interface IPv4 addresses.
interfaces:
- name: Ethernet2
primary_ip: 172.30.11.0/31
primary_ip: 172.30.11.1/31
secondary_ips:
- 10.10.10.0/31
- 10.10.10.1/31
- 10.10.10.10/31
- VerifyInterfaceUtilization:
# Verifies that the utilization of interfaces is below a certain threshold.
Expand Down
6 changes: 3 additions & 3 deletions tests/units/anta_tests/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -1969,8 +1969,8 @@
"interfaces": {
"Ethernet2": {
"interfaceAddress": {
"primaryIp": {"address": "172.30.11.0", "maskLen": 31},
"secondaryIpsOrderedList": [{"address": "10.10.10.0", "maskLen": 31}, {"address": "10.10.10.10", "maskLen": 31}],
"primaryIp": {"address": "172.30.11.1", "maskLen": 31},
"secondaryIpsOrderedList": [{"address": "10.10.10.1", "maskLen": 31}, {"address": "10.10.10.10", "maskLen": 31}],
}
}
}
Expand All @@ -1988,7 +1988,7 @@
],
"inputs": {
"interfaces": [
{"name": "Ethernet2", "primary_ip": "172.30.11.0/31", "secondary_ips": ["10.10.10.0/31", "10.10.10.10/31"]},
{"name": "Ethernet2", "primary_ip": "172.30.11.1/31", "secondary_ips": ["10.10.10.1/31", "10.10.10.10/31"]},
{"name": "Ethernet12", "primary_ip": "172.30.11.10/31", "secondary_ips": ["10.10.10.10/31", "10.10.10.20/31"]},
]
},
Expand Down

0 comments on commit 4e13729

Please sign in to comment.