Skip to content

Commit

Permalink
Updated unit test and api docs
Browse files Browse the repository at this point in the history
  • Loading branch information
acelebanski committed Jan 24, 2024
1 parent 9958eab commit 74f989a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
7 changes: 4 additions & 3 deletions docs/panos-upgrade-assurance/api/firewall_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,15 @@ order:

* virtual router name,
* destination CIDR,
* network interface name if one is available, empty string otherwise.
* network interface name if one is available, empty string otherwise,
* next-hop address or name.

The key does not provide any meaningful information, it's there only to introduce uniqueness for each entry. All
properties that make a key are also available in the value of a dictionary element.

```python showLineNumbers title="Sample output"
{
private_0.0.0.0/0_private/i3': {
private_0.0.0.0/0_private/i3_vr-public': {
'age': None,
'destination': '0.0.0.0/0',
'flags': 'A S',
Expand All @@ -526,7 +527,7 @@ properties that make a key are also available in the value of a dictionary eleme
'route-table': 'unicast',
'virtual-router': 'private'
},
'public_10.0.0.0/8_public/i3': {
'public_10.0.0.0/8_public/i3_vr-private': {
'age': None,
'destination': '10.0.0.0/8',
'flags': 'A S',
Expand Down
12 changes: 6 additions & 6 deletions docs/panos-upgrade-assurance/api/snapshot_compare.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ when comparing route tables snapshots are formatted like:
```python showLineNumbers
{
"routes": {
"default_0.0.0.0/0_ethernet1/3": {
"default_0.0.0.0/0_ethernet1/3_10.26.129.129": {
"virtual-router": "default",
"destination": "0.0.0.0/0",
"nexthop": "10.26.129.129",
Expand Down Expand Up @@ -376,7 +376,7 @@ To illustrate that, the `passed` flag added by this method is highlighted:
},
'missing': {
'missing_keys': [
'default_0.0.0.0/0_ethernet1/3'
'default_0.0.0.0/0_ethernet1/3_10.26.129.129'
],
'passed': False
},
Expand Down Expand Up @@ -427,21 +427,21 @@ An example for the route tables, crafted in a way that almost each level fails:
{
"added": {
"added_keys": [
"default_10.26.129.0/25_ethernet1/2",
"default_168.63.129.16/32_ethernet1/3"
"default_10.26.129.0/25_ethernet1/2_10.26.129.1",
"default_168.63.129.16/32_ethernet1/3_10.26.129.129"
],
"passed": "False"
},
"missing": {
"missing_keys": [
"default_0.0.0.0/0_ethernet1/3"
"default_0.0.0.0/0_ethernet1/3_10.26.129.129"
],
"passed": "False"
},
"changed": {
# highlight-start
"changed_raw": {
"default_10.26.130.0/25_ethernet1/2": {
"default_10.26.130.0/25_ethernet1/2_10.26.129.1": {
"added": {
"added_keys": [],
"passed": "True"
Expand Down
8 changes: 6 additions & 2 deletions panos_upgrade_assurance/firewall_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,12 @@ def get_routes(self) -> dict:
routes = response["entry"]
for route in routes if isinstance(routes, list) else [routes]:
result[
f"{route['virtual-router']}_{route['destination']}_{route['interface'] if route['interface'] else ''}_\
{route['nexthop'].replace(' ', '-')}"
(
f"{route['virtual-router']}_"
f"{route['destination']}_"
f"{route['interface'] if route['interface'] else ''}_"
f"{route['nexthop'].replace(' ', '-')}"
)
] = dict(route)

return result
Expand Down
2 changes: 1 addition & 1 deletion tests/test_firewall_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def test_get_routes(self, fw_proxy_mock):
fw_proxy_mock.op.return_value = raw_response

assert fw_proxy_mock.get_routes() == {
"default_0.0.0.0/0_ethernet1/1": {
"default_0.0.0.0/0_ethernet1/1_10.10.11.1": {
"age": None,
"destination": "0.0.0.0/0",
"flags": "A S E",
Expand Down

0 comments on commit 74f989a

Please sign in to comment.