tplinkrouterc6u 5.0.3__py3-none-any.whl → 5.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- test/{test_client.py → test_client_c6u.py} +2 -1
- test/test_client_ex.py +339 -0
- test/test_client_mr.py +365 -0
- test/test_client_xdr.py +536 -0
- tplinkrouterc6u/__init__.py +16 -12
- tplinkrouterc6u/client/__init__.py +1 -0
- tplinkrouterc6u/client/c1200.py +102 -0
- tplinkrouterc6u/client/c5400x.py +109 -0
- tplinkrouterc6u/client/c6u.py +436 -0
- tplinkrouterc6u/client/c6v4.py +38 -0
- tplinkrouterc6u/client/deco.py +177 -0
- tplinkrouterc6u/client/ex.py +295 -0
- tplinkrouterc6u/client/mr.py +712 -0
- tplinkrouterc6u/client/xdr.py +263 -0
- tplinkrouterc6u/client_abstract.py +48 -0
- tplinkrouterc6u/common/__init__.py +1 -0
- tplinkrouterc6u/{dataclass.py → common/dataclass.py} +40 -1
- tplinkrouterc6u/{package_enum.py → common/package_enum.py} +5 -0
- tplinkrouterc6u/provider.py +39 -0
- {tplinkrouterc6u-5.0.3.dist-info → tplinkrouterc6u-5.2.0.dist-info}/METADATA +52 -2
- tplinkrouterc6u-5.2.0.dist-info/RECORD +30 -0
- {tplinkrouterc6u-5.0.3.dist-info → tplinkrouterc6u-5.2.0.dist-info}/WHEEL +1 -1
- tplinkrouterc6u/client.py +0 -1451
- tplinkrouterc6u-5.0.3.dist-info/RECORD +0 -17
- /tplinkrouterc6u/{encryption.py → common/encryption.py} +0 -0
- /tplinkrouterc6u/{exception.py → common/exception.py} +0 -0
- /tplinkrouterc6u/{helper.py → common/helper.py} +0 -0
- {tplinkrouterc6u-5.0.3.dist-info → tplinkrouterc6u-5.2.0.dist-info}/LICENSE +0 -0
- {tplinkrouterc6u-5.0.3.dist-info → tplinkrouterc6u-5.2.0.dist-info}/top_level.txt +0 -0
|
@@ -445,7 +445,7 @@ class TestTPLinkClient(TestCase):
|
|
|
445
445
|
{"mac": "54:b3:a2:f7:be:ea", "deviceTag":"iot_5G", "isGuest":false, "ip":"192.168.1.188",
|
|
446
446
|
"deviceName":"name3"},
|
|
447
447
|
{"mac": "3c:ae:e1:83:94:9d", "deviceTag":"iot_6G", "isGuest":false, "ip":"192.168.1.189",
|
|
448
|
-
"deviceName":"name4"}
|
|
448
|
+
"deviceName":"name4", "signal": -52}
|
|
449
449
|
],
|
|
450
450
|
"timeout": false,
|
|
451
451
|
"success": true
|
|
@@ -570,6 +570,7 @@ class TestTPLinkClient(TestCase):
|
|
|
570
570
|
self.assertEqual(status.devices[5].hostname, 'name4')
|
|
571
571
|
self.assertEqual(status.devices[5].packets_sent, None)
|
|
572
572
|
self.assertEqual(status.devices[5].packets_received, None)
|
|
573
|
+
self.assertEqual(status.devices[5].signal, -52)
|
|
573
574
|
self.assertIsInstance(status.devices[6], Device)
|
|
574
575
|
self.assertEqual(status.devices[6].type, Connection.HOST_5G)
|
|
575
576
|
self.assertEqual(status.devices[6].macaddr, '1F-7A-BD-F7-20-0D')
|
test/test_client_ex.py
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
from unittest import main, TestCase
|
|
2
|
+
from macaddress import EUI48
|
|
3
|
+
from ipaddress import IPv4Address
|
|
4
|
+
from tplinkrouterc6u import (
|
|
5
|
+
TPLinkEXClient,
|
|
6
|
+
Connection,
|
|
7
|
+
Firmware,
|
|
8
|
+
Status,
|
|
9
|
+
Device,
|
|
10
|
+
IPv4Reservation,
|
|
11
|
+
IPv4DHCPLease,
|
|
12
|
+
IPv4Status,
|
|
13
|
+
ClientException,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestTPLinkEXClient(TestCase):
|
|
18
|
+
def test_firmware(self) -> None:
|
|
19
|
+
response = ('{"data":{"hardwareVersion":"EX511 v2.0 00000000","modelName":"EX511",'
|
|
20
|
+
'"softwareVersion":"0.7.0 3.0.0 v607e.0 Build 240930 Rel.11206n","stack":"0,0,0,0,0,0"},'
|
|
21
|
+
'"operation":"go","oid":"DEV2_DEV_INFO","success":true}')
|
|
22
|
+
|
|
23
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
24
|
+
self._token = True
|
|
25
|
+
|
|
26
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
27
|
+
return 200, response
|
|
28
|
+
|
|
29
|
+
client = TPLinkEXClientTest('', '')
|
|
30
|
+
result = client.get_firmware()
|
|
31
|
+
|
|
32
|
+
self.assertIsInstance(result, Firmware)
|
|
33
|
+
self.assertEqual(result.hardware_version, 'EX511 v2.0 00000000')
|
|
34
|
+
self.assertEqual(result.model, 'EX511')
|
|
35
|
+
self.assertEqual(result.firmware_version, '0.7.0 3.0.0 v607e.0 Build 240930 Rel.11206n')
|
|
36
|
+
|
|
37
|
+
def test_get_status_with_5G(self) -> None:
|
|
38
|
+
|
|
39
|
+
DEV2_ADT_LAN = ('{"data":[{"MACAddress":"a0:28:84:de:dd:5c","IPAddress":"192.168.4.1","stack":"1,0,0,0,0,0"}],'
|
|
40
|
+
'"operation":"gl","oid":"DEV2_ADT_LAN","success":true}')
|
|
41
|
+
DEV2_ADT_WAN = ('{"data":[{"enable":"1","MACAddr":"BF-75-44-4C-DC-9E","connIPv4Address":"192.168.30.55",'
|
|
42
|
+
'"connIPv4Gateway":"192.168.30.1","stack":"1,0,0,0,0,0"}],"operation":"gl",'
|
|
43
|
+
'"oid":"DEV2_ADT_WAN","success":true}')
|
|
44
|
+
DEV2_ADT_WIFI_COMMON = ('{"data":[{"primaryEnable":"1","guestEnable":"0","stack":"1,0,0,0,0,0"},'
|
|
45
|
+
'{"primaryEnable":"0","guestEnable":"1","stack":"2,0,0,0,0,0"}],"operation":"gl",'
|
|
46
|
+
'"oid":"DEV2_ADT_WIFI_COMMON","success":true}')
|
|
47
|
+
DEV2_HOST_ENTRY = ('{"data":[{"active":"1","X_TP_LanConnType":"0","physAddress":"66-E2-02-BD-B5-1B",'
|
|
48
|
+
'"IPAddress":"192.168.30.10","hostName":"host1","stack":"1,0,0,0,0,0"},'
|
|
49
|
+
'{"active":"1","X_TP_LanConnType":"1","physAddress":"F4-A3-86-2D-41-B5",'
|
|
50
|
+
'"IPAddress":"192.168.30.11","hostName":"host2","stack":"2,0,0,0,0,0"}],"operation":"gl",'
|
|
51
|
+
'"oid":"DEV2_HOST_ENTRY","success":true}')
|
|
52
|
+
DEV2_MEM_STATUS = ('{"data":{"total":"192780","free":"78400","stack":"0,0,0,0,0,0"},"operation":"go",'
|
|
53
|
+
'"oid":"DEV2_MEM_STATUS","success":true}')
|
|
54
|
+
DEV2_PROC_STATUS = ('{"data":{"CPUUsage":"47","stack":"0,0,0,0,0,0"},"operation":"go",'
|
|
55
|
+
'"oid":"DEV2_PROC_STATUS","success":true}')
|
|
56
|
+
|
|
57
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
58
|
+
self._token = True
|
|
59
|
+
|
|
60
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
61
|
+
if 'DEV2_ADT_LAN' in data_str:
|
|
62
|
+
return 200, DEV2_ADT_LAN
|
|
63
|
+
elif 'DEV2_ADT_WAN' in data_str:
|
|
64
|
+
return 200, DEV2_ADT_WAN
|
|
65
|
+
elif 'DEV2_ADT_WIFI_COMMON' in data_str:
|
|
66
|
+
return 200, DEV2_ADT_WIFI_COMMON
|
|
67
|
+
elif 'DEV2_HOST_ENTRY' in data_str:
|
|
68
|
+
return 200, DEV2_HOST_ENTRY
|
|
69
|
+
elif 'DEV2_MEM_STATUS' in data_str:
|
|
70
|
+
return 200, DEV2_MEM_STATUS
|
|
71
|
+
elif 'DEV2_PROC_STATUS' in data_str:
|
|
72
|
+
return 200, DEV2_PROC_STATUS
|
|
73
|
+
raise ClientException()
|
|
74
|
+
|
|
75
|
+
client = TPLinkEXClientTest('', '')
|
|
76
|
+
status = client.get_status()
|
|
77
|
+
|
|
78
|
+
self.assertIsInstance(status, Status)
|
|
79
|
+
self.assertEqual(status.wan_macaddr, 'BF-75-44-4C-DC-9E')
|
|
80
|
+
self.assertIsInstance(status.wan_macaddress, EUI48)
|
|
81
|
+
self.assertEqual(status.lan_macaddr, 'A0-28-84-DE-DD-5C')
|
|
82
|
+
self.assertIsInstance(status.lan_macaddress, EUI48)
|
|
83
|
+
self.assertEqual(status.wan_ipv4_addr, '192.168.30.55')
|
|
84
|
+
self.assertIsInstance(status.lan_ipv4_address, IPv4Address)
|
|
85
|
+
self.assertEqual(status.lan_ipv4_addr, '192.168.4.1')
|
|
86
|
+
self.assertEqual(status.wan_ipv4_gateway, '192.168.30.1')
|
|
87
|
+
self.assertIsInstance(status.wan_ipv4_address, IPv4Address)
|
|
88
|
+
self.assertEqual(status.wired_total, 1)
|
|
89
|
+
self.assertEqual(status.wifi_clients_total, 1)
|
|
90
|
+
self.assertEqual(status.guest_clients_total, 0)
|
|
91
|
+
self.assertEqual(status.clients_total, 2)
|
|
92
|
+
self.assertEqual(status.guest_2g_enable, False)
|
|
93
|
+
self.assertEqual(status.guest_5g_enable, True)
|
|
94
|
+
self.assertEqual(status.iot_2g_enable, None)
|
|
95
|
+
self.assertEqual(status.iot_5g_enable, None)
|
|
96
|
+
self.assertEqual(status.wifi_2g_enable, True)
|
|
97
|
+
self.assertEqual(status.wifi_5g_enable, False)
|
|
98
|
+
self.assertEqual(status.wan_ipv4_uptime, None)
|
|
99
|
+
self.assertGreaterEqual(status.mem_usage, 0)
|
|
100
|
+
self.assertLessEqual(status.mem_usage, 1)
|
|
101
|
+
self.assertGreaterEqual(status.cpu_usage, 0)
|
|
102
|
+
self.assertLessEqual(status.cpu_usage, 1)
|
|
103
|
+
self.assertEqual(len(status.devices), 2)
|
|
104
|
+
self.assertIsInstance(status.devices[0], Device)
|
|
105
|
+
self.assertEqual(status.devices[0].type, Connection.WIRED)
|
|
106
|
+
self.assertEqual(status.devices[0].macaddr, '66-E2-02-BD-B5-1B')
|
|
107
|
+
self.assertIsInstance(status.devices[0].macaddress, EUI48)
|
|
108
|
+
self.assertEqual(status.devices[0].ipaddr, '192.168.30.10')
|
|
109
|
+
self.assertIsInstance(status.devices[0].ipaddress, IPv4Address)
|
|
110
|
+
self.assertEqual(status.devices[0].hostname, 'host1')
|
|
111
|
+
self.assertEqual(status.devices[0].packets_sent, None)
|
|
112
|
+
self.assertEqual(status.devices[0].packets_received, None)
|
|
113
|
+
self.assertIsInstance(status.devices[1], Device)
|
|
114
|
+
self.assertEqual(status.devices[1].type, Connection.HOST_2G)
|
|
115
|
+
self.assertEqual(status.devices[1].macaddr, 'F4-A3-86-2D-41-B5')
|
|
116
|
+
self.assertIsInstance(status.devices[1].macaddress, EUI48)
|
|
117
|
+
self.assertEqual(status.devices[1].ipaddr, '192.168.30.11')
|
|
118
|
+
self.assertIsInstance(status.devices[1].ipaddress, IPv4Address)
|
|
119
|
+
self.assertEqual(status.devices[1].hostname, 'host2')
|
|
120
|
+
self.assertEqual(status.devices[1].packets_sent, None) # TODO
|
|
121
|
+
self.assertEqual(status.devices[1].packets_received, None) # TODO
|
|
122
|
+
|
|
123
|
+
def test_get_ipv4_reservations(self) -> None:
|
|
124
|
+
|
|
125
|
+
response = ('{"data":[{"enable":"1","chaddr":"bf:75:44:4c:dc:9e","yiaddr":"192.168.8.21",'
|
|
126
|
+
'"stack":"1,1,0,0,0,0"}],"operation":"gl","oid":"DEV2_DHCPV4_POOL_STATICADDR","success":true}')
|
|
127
|
+
|
|
128
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
129
|
+
self._token = True
|
|
130
|
+
|
|
131
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
132
|
+
return 200, response
|
|
133
|
+
|
|
134
|
+
client = TPLinkEXClientTest('', '')
|
|
135
|
+
result = client.get_ipv4_reservations()
|
|
136
|
+
|
|
137
|
+
self.assertEqual(len(result), 1)
|
|
138
|
+
self.assertIsInstance(result[0], IPv4Reservation)
|
|
139
|
+
self.assertEqual(result[0].macaddr, 'BF-75-44-4C-DC-9E')
|
|
140
|
+
self.assertEqual(result[0].ipaddr, '192.168.8.21')
|
|
141
|
+
self.assertEqual(result[0].hostname, '')
|
|
142
|
+
self.assertEqual(result[0].enabled, True)
|
|
143
|
+
|
|
144
|
+
def test_get_ipv4_reservations_no_reservations(self) -> None:
|
|
145
|
+
response = '''
|
|
146
|
+
[error]0
|
|
147
|
+
|
|
148
|
+
'''
|
|
149
|
+
response = '{"data":[],"operation":"gl","oid":"DEV2_DHCPV4_POOL_STATICADDR","success":true}'
|
|
150
|
+
|
|
151
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
152
|
+
self._token = True
|
|
153
|
+
|
|
154
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
155
|
+
return 200, response
|
|
156
|
+
|
|
157
|
+
client = TPLinkEXClientTest('', '')
|
|
158
|
+
result = client.get_ipv4_reservations()
|
|
159
|
+
|
|
160
|
+
self.assertEqual(len(result), 0)
|
|
161
|
+
|
|
162
|
+
def test_get_ipv4_dhcp_leases_no_leases(self) -> None:
|
|
163
|
+
|
|
164
|
+
response = '{"data":[],"operation":"gl","oid":"DEV2_HOST_ENTRY","success":true}'
|
|
165
|
+
|
|
166
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
167
|
+
self._token = True
|
|
168
|
+
|
|
169
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
170
|
+
return 200, response
|
|
171
|
+
|
|
172
|
+
client = TPLinkEXClientTest('', '')
|
|
173
|
+
result = client.get_ipv4_dhcp_leases()
|
|
174
|
+
|
|
175
|
+
self.assertEqual(len(result), 0)
|
|
176
|
+
|
|
177
|
+
def test_get_ipv4_dhcp_leases(self) -> None:
|
|
178
|
+
|
|
179
|
+
response = ('{"data":[{"alias":"","physAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.32.175",'
|
|
180
|
+
'"addressSource":"Static","leaseTimeRemaining":"85841","X_TP_IPv6Address":"",'
|
|
181
|
+
'"X_TP_IPv6LinkLocal":"","layer1Interface":"",'
|
|
182
|
+
'"X_TP_Layer2Interface":"Device.WiFi.AccessPoint.1.","vendorClassID":"","clientID":"",'
|
|
183
|
+
'"hostName":"name1","interfaceType":"Wi-Fi","X_TP_LanConnType":"1","X_TP_LanConnDev":"br0",'
|
|
184
|
+
'"active":"1","IPv4AddressNumberOfEntries":"0","X_TP_Vendor":"","X_TP_ClientType":"Other",'
|
|
185
|
+
'"X_TP_DevphyAddress":"","IPv6AddressNumberOfEntries":"0","X_TP_NetworkReadyTime":"0",'
|
|
186
|
+
'"stack":"1,0,0,0,0,0"}],"operation":"gl","oid":"DEV2_HOST_ENTRY","success":true}')
|
|
187
|
+
|
|
188
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
189
|
+
self._token = True
|
|
190
|
+
|
|
191
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
192
|
+
return 200, response
|
|
193
|
+
|
|
194
|
+
client = TPLinkEXClientTest('', '')
|
|
195
|
+
result = client.get_ipv4_dhcp_leases()
|
|
196
|
+
|
|
197
|
+
self.assertEqual(len(result), 1)
|
|
198
|
+
self.assertIsInstance(result[0], IPv4DHCPLease)
|
|
199
|
+
self.assertEqual(result[0].macaddr, 'BF-75-44-4C-DC-9E')
|
|
200
|
+
self.assertEqual(result[0].ipaddr, '192.168.32.175')
|
|
201
|
+
self.assertEqual(result[0].hostname, 'name1')
|
|
202
|
+
self.assertEqual(result[0].lease_time, '23:50:41')
|
|
203
|
+
|
|
204
|
+
def test_get_ipv4_dhcp_leases_permanent(self) -> None:
|
|
205
|
+
|
|
206
|
+
response = ('{"data":[{"alias":"","physAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.32.175",'
|
|
207
|
+
'"addressSource":"Static","leaseTimeRemaining":"0","X_TP_IPv6Address":"",'
|
|
208
|
+
'"X_TP_IPv6LinkLocal":"","layer1Interface":"","X_TP_Layer2Interface":"Device.WiFi.AccessPoint.1.",'
|
|
209
|
+
'"vendorClassID":"","clientID":"","hostName":"name1","interfaceType":"Wi-Fi",'
|
|
210
|
+
'"X_TP_LanConnType":"1","X_TP_LanConnDev":"br0","active":"1","IPv4AddressNumberOfEntries":"0",'
|
|
211
|
+
'"X_TP_Vendor":"","X_TP_ClientType":"Other","X_TP_DevphyAddress":"",'
|
|
212
|
+
'"IPv6AddressNumberOfEntries":"0","X_TP_NetworkReadyTime":"0","stack":"1,0,0,0,0,0"},'
|
|
213
|
+
'{"alias":"","physAddress":"a0:28:84:de:dd:5c","IPAddress":"192.168.32.176",'
|
|
214
|
+
'"addressSource":"Static","leaseTimeRemaining":"86372","X_TP_IPv6Address":"",'
|
|
215
|
+
'"X_TP_IPv6LinkLocal":"","layer1Interface":"","X_TP_Layer2Interface":"Device.WiFi.AccessPoint.1.",'
|
|
216
|
+
'"vendorClassID":"","clientID":"","hostName":"name2","interfaceType":"Wi-Fi",'
|
|
217
|
+
'"X_TP_LanConnType":"1","X_TP_LanConnDev":"br0","active":"1","IPv4AddressNumberOfEntries":"0",'
|
|
218
|
+
'"X_TP_Vendor":"","X_TP_ClientType":"Other","X_TP_DevphyAddress":"",'
|
|
219
|
+
'"IPv6AddressNumberOfEntries":"0","X_TP_NetworkReadyTime":"0","stack":"1,0,0,0,0,0"}],'
|
|
220
|
+
'"operation":"gl","oid":"DEV2_HOST_ENTRY","success":true}')
|
|
221
|
+
|
|
222
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
223
|
+
self._token = True
|
|
224
|
+
|
|
225
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
226
|
+
return 200, response
|
|
227
|
+
|
|
228
|
+
client = TPLinkEXClientTest('', '')
|
|
229
|
+
result = client.get_ipv4_dhcp_leases()
|
|
230
|
+
|
|
231
|
+
self.assertEqual(len(result), 2)
|
|
232
|
+
self.assertEqual(result[0].macaddr, 'BF-75-44-4C-DC-9E')
|
|
233
|
+
self.assertEqual(result[0].ipaddr, '192.168.32.175')
|
|
234
|
+
self.assertEqual(result[0].hostname, 'name1')
|
|
235
|
+
self.assertEqual(result[0].lease_time, 'Permanent')
|
|
236
|
+
self.assertEqual(result[1].macaddr, 'A0-28-84-DE-DD-5C')
|
|
237
|
+
self.assertEqual(result[1].ipaddr, '192.168.32.176')
|
|
238
|
+
self.assertEqual(result[1].hostname, 'name2')
|
|
239
|
+
self.assertEqual(result[1].lease_time, '23:59:32')
|
|
240
|
+
|
|
241
|
+
def test_get_ipv4_status(self) -> None:
|
|
242
|
+
|
|
243
|
+
DEV2_ADT_LAN = ('{"data":[{"MACAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.5.1",'
|
|
244
|
+
'"IPSubnetMask":"255.255.255.0","DHCPv4Enable":"1","stack":"1,0,0,0,0,0"}],'
|
|
245
|
+
'"operation":"gl","oid":"DEV2_ADT_LAN","success":true}')
|
|
246
|
+
DEV2_ADT_WAN = ('{"data":[{"enable":"1","MACAddr":"a0:28:84:de:dd:5c","connIPv4Address":"10.10.11.5",'
|
|
247
|
+
'"connIPv4Gateway":"11.11.11.11","name":"ipoe_0_0_d","connIPv4SubnetMask":"1.1.1.1",'
|
|
248
|
+
'"connIPv4DnsServer":"8.8.8.8,8.8.4.4","stack":"1,0,0,0,0,0"}],"operation":"gl",'
|
|
249
|
+
'"oid":"DEV2_ADT_WAN","success":true}')
|
|
250
|
+
|
|
251
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
252
|
+
self._token = True
|
|
253
|
+
|
|
254
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
255
|
+
if 'DEV2_ADT_LAN' in data_str:
|
|
256
|
+
return 200, DEV2_ADT_LAN
|
|
257
|
+
elif 'DEV2_ADT_WAN' in data_str:
|
|
258
|
+
return 200, DEV2_ADT_WAN
|
|
259
|
+
raise ClientException()
|
|
260
|
+
|
|
261
|
+
client = TPLinkEXClientTest('', '')
|
|
262
|
+
result = client.get_ipv4_status()
|
|
263
|
+
|
|
264
|
+
self.assertIsInstance(result, IPv4Status)
|
|
265
|
+
self.assertEqual(result.wan_macaddr, 'A0-28-84-DE-DD-5C')
|
|
266
|
+
self.assertEqual(result.wan_ipv4_ipaddr, '10.10.11.5')
|
|
267
|
+
self.assertEqual(result.wan_ipv4_gateway, '11.11.11.11')
|
|
268
|
+
self.assertEqual(result.wan_ipv4_conntype, 'ipoe_0_0_d')
|
|
269
|
+
self.assertEqual(result.wan_ipv4_netmask, '1.1.1.1')
|
|
270
|
+
self.assertEqual(result.wan_ipv4_pridns, '8.8.8.8')
|
|
271
|
+
self.assertEqual(result.wan_ipv4_snddns, '8.8.4.4')
|
|
272
|
+
self.assertEqual(result.lan_macaddr, 'BF-75-44-4C-DC-9E')
|
|
273
|
+
self.assertEqual(result.lan_ipv4_ipaddr, '192.168.5.1')
|
|
274
|
+
self.assertEqual(result.lan_ipv4_netmask, '255.255.255.0')
|
|
275
|
+
self.assertEqual(result.lan_ipv4_dhcp_enable, True)
|
|
276
|
+
self.assertEqual(result.remote, None)
|
|
277
|
+
|
|
278
|
+
def test_get_ipv4_status_one_wlan(self) -> None:
|
|
279
|
+
|
|
280
|
+
DEV2_ADT_LAN = ('{"data":[{"MACAddress":"bf:75:44:4c:dc:9e","IPAddress":"192.168.5.1",'
|
|
281
|
+
'"IPSubnetMask":"255.255.255.0","DHCPv4Enable":"1","stack":"1,0,0,0,0,0"}],'
|
|
282
|
+
'"operation":"gl","oid":"DEV2_ADT_LAN","success":true}')
|
|
283
|
+
DEV2_ADT_WAN = ('{"data":[{"enable":"1","MACAddr":"ba:7a:a4:4a:dc:7e","connIPv4Address":"0.0.0.0",'
|
|
284
|
+
'"connIPv4Gateway":"0.0.0.0","name":"ipoe_0_0_d","connIPv4SubnetMask":"0.0.0.0",'
|
|
285
|
+
'"connIPv4DnsServer":"0.0.0.0,0.0.0.0","stack":"1,0,0,0,0,0"}],"operation":"gl",'
|
|
286
|
+
'"oid":"DEV2_ADT_WAN","success":true}')
|
|
287
|
+
|
|
288
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
289
|
+
self._token = True
|
|
290
|
+
|
|
291
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
292
|
+
if 'DEV2_ADT_LAN' in data_str:
|
|
293
|
+
return 200, DEV2_ADT_LAN
|
|
294
|
+
elif 'DEV2_ADT_WAN' in data_str:
|
|
295
|
+
return 200, DEV2_ADT_WAN
|
|
296
|
+
raise ClientException()
|
|
297
|
+
|
|
298
|
+
client = TPLinkEXClientTest('', '')
|
|
299
|
+
result = client.get_ipv4_status()
|
|
300
|
+
|
|
301
|
+
self.assertIsInstance(result, IPv4Status)
|
|
302
|
+
self.assertEqual(result.wan_macaddr, 'BA-7A-A4-4A-DC-7E')
|
|
303
|
+
self.assertEqual(result.wan_ipv4_ipaddr, '0.0.0.0')
|
|
304
|
+
self.assertEqual(result.wan_ipv4_gateway, '0.0.0.0')
|
|
305
|
+
self.assertEqual(result.wan_ipv4_conntype, 'ipoe_0_0_d')
|
|
306
|
+
self.assertEqual(result.wan_ipv4_netmask, '0.0.0.0')
|
|
307
|
+
self.assertEqual(result.wan_ipv4_pridns, '0.0.0.0')
|
|
308
|
+
self.assertEqual(result.wan_ipv4_snddns, '0.0.0.0')
|
|
309
|
+
self.assertEqual(result.lan_macaddr, 'BF-75-44-4C-DC-9E')
|
|
310
|
+
self.assertEqual(result.lan_ipv4_ipaddr, '192.168.5.1')
|
|
311
|
+
self.assertEqual(result.lan_ipv4_netmask, '255.255.255.0')
|
|
312
|
+
self.assertEqual(result.lan_ipv4_dhcp_enable, True)
|
|
313
|
+
self.assertEqual(result.remote, None)
|
|
314
|
+
|
|
315
|
+
def test_set_wifi(self) -> None:
|
|
316
|
+
response = '{"success":true, "errorcode":0}'
|
|
317
|
+
|
|
318
|
+
check_url = ''
|
|
319
|
+
check_data = ''
|
|
320
|
+
|
|
321
|
+
class TPLinkEXClientTest(TPLinkEXClient):
|
|
322
|
+
self._token = True
|
|
323
|
+
|
|
324
|
+
def _request(self, url, method='POST', data_str=None, encrypt=False):
|
|
325
|
+
nonlocal check_url, check_data
|
|
326
|
+
check_url = url
|
|
327
|
+
check_data = data_str
|
|
328
|
+
return 200, response
|
|
329
|
+
|
|
330
|
+
client = TPLinkEXClientTest('', '')
|
|
331
|
+
client.set_wifi(Connection.HOST_2G, True)
|
|
332
|
+
|
|
333
|
+
self.assertIn('http:///cgi_gdpr?9?_=', check_url)
|
|
334
|
+
self.assertEqual(check_data, '{"data":{"stack":"1,0,0,0,0,0","pstack":"0,0,0,0,0,0",'
|
|
335
|
+
'"primaryEnable":"1"},"operation":"so","oid":"DEV2_ADT_WIFI_COMMON"}')
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
if __name__ == '__main__':
|
|
339
|
+
main()
|