Skip to content

Commit 4350fc3

Browse files
authored
Merge pull request #178 from telekom-mms/fix/associated-interface
fix: address interface attribute is "associated-interface" and not "interface"
2 parents c44e9f0 + 359d6ff commit 4350fc3

5 files changed

Lines changed: 18 additions & 16 deletions

File tree

fortilib/address.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77

88
class FortigateAddress(FortigateNamedObject, FortigateInterfaceMixin):
9+
interface_attribute = "associated-interface"
10+
911
"""Fortigate object for addresses.
1012
1113
:ivar interface: Interface the address is connected to
@@ -55,7 +57,7 @@ def render(self) -> dict:
5557
"name": "Test_address",
5658
"type": "ipmask",
5759
"subnet": "10.10.10.1 255.255.255.255",
58-
"interface": "port4",
60+
"associated-interface": "port4",
5961
"comments": "Test comment",
6062
}
6163
"""
@@ -64,7 +66,7 @@ def render(self) -> dict:
6466
"type": "ipmask",
6567
"subnet": f"{self.subnet.network_address} {self.subnet.netmask}",
6668
"comment": self.comment,
67-
"interface": self.interface.name if self.interface else "",
69+
"associated-interface": self.interface.name if self.interface else "",
6870
"color": self.color,
6971
}
7072

@@ -103,7 +105,7 @@ def render(self) -> dict:
103105
"type": "iprange",
104106
"start-ip": "10.10.10.1",
105107
"end-ip": "10.10.10.15",
106-
"interface": "port4",
108+
"associated-interface": "port4",
107109
"comments": "Test comment",
108110
}
109111
"""
@@ -113,7 +115,7 @@ def render(self) -> dict:
113115
"start-ip": str(self.ip_start),
114116
"end-ip": str(self.ip_end),
115117
"comment": self.comment,
116-
"interface": self.interface.name if self.interface else "",
118+
"associated-interface": self.interface.name if self.interface else "",
117119
"color": self.color,
118120
}
119121

@@ -145,7 +147,7 @@ def render(self) -> dict:
145147
"name": "Test_fqdn",
146148
"type": "fqdn",
147149
"fqdn": "kernel.org",
148-
"interface": "port4",
150+
"associated-interface": "port4",
149151
"comments": "Test comment",
150152
}
151153
"""
@@ -154,6 +156,6 @@ def render(self) -> dict:
154156
"type": "fqdn",
155157
"fqdn": self.fqdn,
156158
"comment": self.comment,
157-
"interface": self.interface.name if self.interface else "",
159+
"associated-interface": self.interface.name if self.interface else "",
158160
"color": self.color,
159161
}

fortilib/vipgroup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
class FortigateVIPGroup(
1010
FortigateAddress, FortigateInterfaceMixin, FortigateGroupMixin
1111
):
12+
interface_attribute = "interface"
13+
1214
"""Fortigate object for VIP groups.
1315
1416
:ivar member: Collection of vip objects of :class:`fortilib.vip.FortigateVIP`

tests/data.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
"cache-ttl": 0,
1414
"sdn": "",
1515
"fsso-group": [],
16-
"interface": "port4",
16+
"associated-interface": "port4",
1717
"comment": "test comment",
1818
"visibility": "enable",
19-
"associated-interface": "",
2019
"color": 0,
2120
"filter": "",
2221
"sdn-addr-type": "private",
@@ -119,10 +118,9 @@
119118
"cache-ttl": 0,
120119
"sdn": "",
121120
"fsso-group": [],
122-
"interface": "port4",
123121
"obj-type": "ip",
124122
"comment": "",
125-
"associated-interface": "",
123+
"associated-interface": "port4",
126124
"color": 19,
127125
"filter": "",
128126
"sdn-addr-type": "private",

tests/tests_fortilib_firewall_read/test_fortilib_firewall_addresses.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_firewall_base_addresses_ipmask(
1919
"name": "NET_198.141.216.0_22",
2020
"subnet": "198.141.216.0 255.255.252.0",
2121
"comment": "",
22-
"interface": "",
22+
"associated-interface": "",
2323
"color": 0,
2424
},
2525
)
@@ -36,7 +36,7 @@ def test_firewall_base_addresses_ipmask_with_interface(self):
3636
"name": "NET_199.40.1.0_24",
3737
"subnet": "199.40.1.0 255.255.255.0",
3838
"comment": "test comment",
39-
"interface": "port4",
39+
"associated-interface": "port4",
4040
"color": 0,
4141
},
4242
)
@@ -60,7 +60,7 @@ def test_firewall_base_addresses_iprange(
6060
"start-ip": "10.188.128.106",
6161
"end-ip": "10.188.128.108",
6262
"comment": "snke 20200122 DPDHL 2020012170002501",
63-
"interface": "",
63+
"associated-interface": "",
6464
"color": 0,
6565
},
6666
)
@@ -79,7 +79,7 @@ def test_firewall_base_addresses_fqdn(
7979
"name": "FQDN_aadcdn.msauth.net",
8080
"fqdn": "aadcdn.msauth.net",
8181
"comment": "",
82-
"interface": "",
82+
"associated-interface": "",
8383
"color": 19,
8484
},
8585
)

tests/tests_fortilib_firewall_write/test_fortilib_firewall_address.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_firewall_base_address_create(self):
2525
"type": "ipmask",
2626
"subnet": "10.0.0.0 255.255.255.0",
2727
"comment": "Kommentar",
28-
"interface": "",
28+
"associated-interface": "",
2929
"color": 0,
3030
},
3131
)
@@ -54,7 +54,7 @@ def test_firewall_base_address_update(self):
5454
"name": "NET_198.141.216.0_22",
5555
"subnet": "198.141.216.0 255.255.255.0",
5656
"comment": "Kommentar",
57-
"interface": "",
57+
"associated-interface": "",
5858
"color": 0,
5959
},
6060
)

0 commit comments

Comments
 (0)