tplinkrouterc6u 5.0.2__tar.gz → 5.1.0__tar.gz
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.
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/PKG-INFO +18 -2
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/README.md +17 -1
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/setup.py +1 -1
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/test/test_client_deco.py +2 -2
- tplinkrouterc6u-5.1.0/test/test_client_ex.py +339 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/test/test_client_mr.py +185 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/__init__.py +20 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/__init__.py +1 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/api_cgi_bin.py +435 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/c1200.py +102 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/c5400x.py +109 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/c6v4.py +38 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/deco.py +177 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/ex.py +295 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client/mr.py +645 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/client_abstract.py +48 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/common/__init__.py +1 -0
- {tplinkrouterc6u-5.0.2/tplinkrouterc6u → tplinkrouterc6u-5.1.0/tplinkrouterc6u/common}/dataclass.py +12 -1
- {tplinkrouterc6u-5.0.2/tplinkrouterc6u → tplinkrouterc6u-5.1.0/tplinkrouterc6u/common}/helper.py +8 -0
- tplinkrouterc6u-5.1.0/tplinkrouterc6u/provider.py +37 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/tplinkrouterc6u.egg-info/PKG-INFO +18 -2
- tplinkrouterc6u-5.1.0/tplinkrouterc6u.egg-info/SOURCES.txt +31 -0
- tplinkrouterc6u-5.0.2/tplinkrouterc6u/__init__.py +0 -19
- tplinkrouterc6u-5.0.2/tplinkrouterc6u/client.py +0 -1451
- tplinkrouterc6u-5.0.2/tplinkrouterc6u.egg-info/SOURCES.txt +0 -20
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/LICENSE +0 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/setup.cfg +0 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/test/__init__.py +0 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/test/test_client.py +0 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/test/test_client_c1200.py +0 -0
- {tplinkrouterc6u-5.0.2/tplinkrouterc6u → tplinkrouterc6u-5.1.0/tplinkrouterc6u/common}/encryption.py +0 -0
- {tplinkrouterc6u-5.0.2/tplinkrouterc6u → tplinkrouterc6u-5.1.0/tplinkrouterc6u/common}/exception.py +0 -0
- {tplinkrouterc6u-5.0.2/tplinkrouterc6u → tplinkrouterc6u-5.1.0/tplinkrouterc6u/common}/package_enum.py +0 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/tplinkrouterc6u.egg-info/dependency_links.txt +0 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/tplinkrouterc6u.egg-info/requires.txt +0 -0
- {tplinkrouterc6u-5.0.2 → tplinkrouterc6u-5.1.0}/tplinkrouterc6u.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tplinkrouterc6u
|
|
3
|
-
Version: 5.0
|
|
3
|
+
Version: 5.1.0
|
|
4
4
|
Summary: TP-Link Router API
|
|
5
5
|
Home-page: https://github.com/AlexandrErohin/TP-Link-Archer-C6U
|
|
6
6
|
Author: Alex Erohin
|
|
@@ -44,6 +44,7 @@ from tplinkrouterc6u import (
|
|
|
44
44
|
TplinkC1200Router,
|
|
45
45
|
TplinkC5400XRouter,
|
|
46
46
|
TPLinkMRClient,
|
|
47
|
+
TPLinkEXClient,
|
|
47
48
|
TPLinkDecoClient,
|
|
48
49
|
Connection
|
|
49
50
|
)
|
|
@@ -107,6 +108,10 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
107
108
|
| get_ipv4_dhcp_leases | | Gets IPv4 addresses assigned via DHCP | [[IPv4DHCPLease]](#IPv4DHCPLease) |
|
|
108
109
|
| set_wifi | wifi: [Connection](#connection), enable: bool | Allow to turn on/of 4 wifi networks | |
|
|
109
110
|
| send_sms | phone_number: str, message: str | Send sms for LTE routers | |
|
|
111
|
+
| send_ussd | command: str | Send USSD command for LTE routers | str |
|
|
112
|
+
| get_sms | | Get sms messages from the first page for LTE routers | [[SMS]](#sms) |
|
|
113
|
+
| set_sms_read | sms: [SMS](#sms) | Set sms message read from the first page for LTE routers | |
|
|
114
|
+
| delete_sms | sms: [SMS](#sms) | Delete sms message from the first page for LTE routers | |
|
|
110
115
|
| reboot | | reboot router |
|
|
111
116
|
| authorize | | authorize for actions |
|
|
112
117
|
| logout | | logout after all is done |
|
|
@@ -210,6 +215,15 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
210
215
|
| lan_ipv4_netmask_address | router LAN gateway IP netmask | ipaddress |
|
|
211
216
|
| remote | router remote | bool, None |
|
|
212
217
|
|
|
218
|
+
### <a id="sms">SMS</a>
|
|
219
|
+
| Field | Description | Type |
|
|
220
|
+
| --- |---|---|
|
|
221
|
+
| id | message index | int |
|
|
222
|
+
| sender| sender | str |
|
|
223
|
+
| content| sms text | str |
|
|
224
|
+
| received_at| received datetime | datetime |
|
|
225
|
+
| unread| is message unread | bool |
|
|
226
|
+
|
|
213
227
|
## Enum
|
|
214
228
|
### <a id="connection">Connection</a>
|
|
215
229
|
- Connection.HOST_2G - host wifi 2.4G
|
|
@@ -257,8 +271,9 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
257
271
|
- Archer GX90 v1.0
|
|
258
272
|
- Archer MR200 (v5, v5.3)
|
|
259
273
|
- Archer MR600 (v1, v2, v3)
|
|
260
|
-
- Archer
|
|
274
|
+
- Archer VR600 v3
|
|
261
275
|
- Archer VR900v
|
|
276
|
+
- Archer VR2100v v1
|
|
262
277
|
- Deco M4 2.0
|
|
263
278
|
- Deco M4R 2.0
|
|
264
279
|
- Deco M5 v3
|
|
@@ -270,6 +285,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
270
285
|
- Deco X60 V3
|
|
271
286
|
- Deco X90
|
|
272
287
|
- Deco XE75 (v1.0, v2.0)
|
|
288
|
+
- EX511 v2.0
|
|
273
289
|
- TD-W9960 (v1, V1.20)
|
|
274
290
|
- TL-MR100 v2.0
|
|
275
291
|
- TL-MR105
|
|
@@ -22,6 +22,7 @@ from tplinkrouterc6u import (
|
|
|
22
22
|
TplinkC1200Router,
|
|
23
23
|
TplinkC5400XRouter,
|
|
24
24
|
TPLinkMRClient,
|
|
25
|
+
TPLinkEXClient,
|
|
25
26
|
TPLinkDecoClient,
|
|
26
27
|
Connection
|
|
27
28
|
)
|
|
@@ -85,6 +86,10 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
85
86
|
| get_ipv4_dhcp_leases | | Gets IPv4 addresses assigned via DHCP | [[IPv4DHCPLease]](#IPv4DHCPLease) |
|
|
86
87
|
| set_wifi | wifi: [Connection](#connection), enable: bool | Allow to turn on/of 4 wifi networks | |
|
|
87
88
|
| send_sms | phone_number: str, message: str | Send sms for LTE routers | |
|
|
89
|
+
| send_ussd | command: str | Send USSD command for LTE routers | str |
|
|
90
|
+
| get_sms | | Get sms messages from the first page for LTE routers | [[SMS]](#sms) |
|
|
91
|
+
| set_sms_read | sms: [SMS](#sms) | Set sms message read from the first page for LTE routers | |
|
|
92
|
+
| delete_sms | sms: [SMS](#sms) | Delete sms message from the first page for LTE routers | |
|
|
88
93
|
| reboot | | reboot router |
|
|
89
94
|
| authorize | | authorize for actions |
|
|
90
95
|
| logout | | logout after all is done |
|
|
@@ -188,6 +193,15 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
188
193
|
| lan_ipv4_netmask_address | router LAN gateway IP netmask | ipaddress |
|
|
189
194
|
| remote | router remote | bool, None |
|
|
190
195
|
|
|
196
|
+
### <a id="sms">SMS</a>
|
|
197
|
+
| Field | Description | Type |
|
|
198
|
+
| --- |---|---|
|
|
199
|
+
| id | message index | int |
|
|
200
|
+
| sender| sender | str |
|
|
201
|
+
| content| sms text | str |
|
|
202
|
+
| received_at| received datetime | datetime |
|
|
203
|
+
| unread| is message unread | bool |
|
|
204
|
+
|
|
191
205
|
## Enum
|
|
192
206
|
### <a id="connection">Connection</a>
|
|
193
207
|
- Connection.HOST_2G - host wifi 2.4G
|
|
@@ -235,8 +249,9 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
235
249
|
- Archer GX90 v1.0
|
|
236
250
|
- Archer MR200 (v5, v5.3)
|
|
237
251
|
- Archer MR600 (v1, v2, v3)
|
|
238
|
-
- Archer
|
|
252
|
+
- Archer VR600 v3
|
|
239
253
|
- Archer VR900v
|
|
254
|
+
- Archer VR2100v v1
|
|
240
255
|
- Deco M4 2.0
|
|
241
256
|
- Deco M4R 2.0
|
|
242
257
|
- Deco M5 v3
|
|
@@ -248,6 +263,7 @@ or you have TP-link C5400X or similar router you need to get web encrypted passw
|
|
|
248
263
|
- Deco X60 V3
|
|
249
264
|
- Deco X90
|
|
250
265
|
- Deco XE75 (v1.0, v2.0)
|
|
266
|
+
- EX511 v2.0
|
|
251
267
|
- TD-W9960 (v1, V1.20)
|
|
252
268
|
- TL-MR100 v2.0
|
|
253
269
|
- TL-MR105
|
|
@@ -70,7 +70,7 @@ class TestTPLinkDecoClient(TestCase):
|
|
|
70
70
|
"connection_type": "band5", "space_id": "1", "ip": "192.168.68.104", "client_mesh": true,
|
|
71
71
|
"online": true, "name": "d2lyZWxlc3M0", "enable_priority": false, "remain_time": 0, "owner_id": "",
|
|
72
72
|
"client_type": "other", "interface": "guest"},
|
|
73
|
-
{"mac": "
|
|
73
|
+
{"mac": "", "up_speed": 3, "down_speed": 1, "wire_type": "wireless", "access_host": "1",
|
|
74
74
|
"connection_type": "band2_4", "space_id": "1", "ip": "UNKNOWN", "client_mesh": true,
|
|
75
75
|
"online": true, "name": "d2lyZWxlc3M1", "enable_priority": false, "remain_time": 0, "owner_id": "",
|
|
76
76
|
"client_type": "other", "interface": "guest"}
|
|
@@ -149,7 +149,7 @@ class TestTPLinkDecoClient(TestCase):
|
|
|
149
149
|
self.assertEqual(status.devices[3].packets_received, None)
|
|
150
150
|
self.assertIsInstance(status.devices[4], Device)
|
|
151
151
|
self.assertEqual(status.devices[4].type, Connection.GUEST_2G)
|
|
152
|
-
self.assertEqual(status.devices[4].macaddr, '
|
|
152
|
+
self.assertEqual(status.devices[4].macaddr, '00-00-00-00-00-00')
|
|
153
153
|
self.assertEqual(status.devices[4].ipaddr, '0.0.0.0')
|
|
154
154
|
self.assertEqual(status.devices[4].hostname, 'wireless5')
|
|
155
155
|
self.assertEqual(status.devices[4].packets_sent, None)
|
|
@@ -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()
|