toDus-API 1.3.3__tar.gz → 1.3.5__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.
- {todus_api-1.3.3 → todus_api-1.3.5}/CHANGELOG.md +34 -0
- {todus_api-1.3.3/toDus_API.egg-info → todus_api-1.3.5}/PKG-INFO +5 -5
- {todus_api-1.3.3 → todus_api-1.3.5}/README.md +4 -4
- todus_api-1.3.5/tests/test_proxy.py +134 -0
- {todus_api-1.3.3 → todus_api-1.3.5/toDus_API.egg-info}/PKG-INFO +5 -5
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/__init__.py +1 -1
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/client/file.py +1 -1
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/client/profile.py +2 -2
- todus_api-1.3.3/tests/test_proxy.py +0 -65
- {todus_api-1.3.3 → todus_api-1.3.5}/LICENSE +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/MANIFEST.in +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/pyproject.toml +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/setup.cfg +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/tests/test_stanzas.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/tests/test_types.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/tests/test_util.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/toDus_API.egg-info/SOURCES.txt +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/toDus_API.egg-info/dependency_links.txt +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/toDus_API.egg-info/requires.txt +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/toDus_API.egg-info/top_level.txt +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/client/__init__.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/client/auth.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/client/base.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/client/message.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/constants.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/errors.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/group.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/parser.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/stanza.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/stanzas/__init__.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/stanzas/group.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/stanzas/presence.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/stanzas/private.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/stanzas/utils.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/types.py +0 -0
- {todus_api-1.3.3 → todus_api-1.3.5}/todus/util.py +0 -0
|
@@ -5,6 +5,35 @@ Todos los cambios notables en este proyecto se documentan en este archivo.
|
|
|
5
5
|
El formato está basado en [Keep a Changelog](https://keepachangelog.com/es-ES/1.1.0/),
|
|
6
6
|
y este proyecto sigue [Semantic Versioning](https://semver.org/lang/es/).
|
|
7
7
|
|
|
8
|
+
## [1.3.5] - 2026-06-20
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Corregidos y optimizados los badges del `README.md` para dar soporte a repositorios privados utilizando badges nativos de GitHub Actions y un badge estático para la licencia.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Migrado el flujo de publicación de PyPI en GitHub Actions a Trusted Publishing (OIDC) para evitar fallos de autenticación con tokens y simplificar el proceso.
|
|
15
|
+
|
|
16
|
+
## [1.3.4] - 2026-06-20
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- Asegurado que las operaciones de subida de archivos (`upload_file`) y avatares (`upload_avatar`) utilicen el proxy configurado al direccionarlas a través de la sesión del cliente.
|
|
20
|
+
- Agregados tests unitarios para verificar el comportamiento de proxies en la subida de archivos y avatares.
|
|
21
|
+
|
|
22
|
+
## [1.3.3] - 2026-06-19
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- Renombrado el paquete a `toDus-API`.
|
|
26
|
+
|
|
27
|
+
## [1.3.2] - 2026-06-19
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
- Corregido el flujo de publicación en GitHub Actions para usar `secrets.PYPI_API_TOKEN`.
|
|
31
|
+
|
|
32
|
+
## [1.3.1] - 2026-06-19
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- Soporte inicial para proxy HTTP y SOCKS5 en peticiones HTTP y sockets XMPP.
|
|
36
|
+
|
|
8
37
|
## [1.3.0] - 2026-06-19
|
|
9
38
|
|
|
10
39
|
### Added
|
|
@@ -55,6 +84,11 @@ y este proyecto sigue [Semantic Versioning](https://semver.org/lang/es/).
|
|
|
55
84
|
- Manejo de excepciones personalizadas
|
|
56
85
|
- Constantes del protocolo ToDus
|
|
57
86
|
|
|
87
|
+
[1.3.5]: https://github.com/ElJoker63/toDus-API/compare/v1.3.4...v1.3.5
|
|
88
|
+
[1.3.4]: https://github.com/ElJoker63/toDus-API/compare/v1.3.3...v1.3.4
|
|
89
|
+
[1.3.3]: https://github.com/ElJoker63/toDus-API/compare/v1.3.2...v1.3.3
|
|
90
|
+
[1.3.2]: https://github.com/ElJoker63/toDus-API/compare/v1.3.1...v1.3.2
|
|
91
|
+
[1.3.1]: https://github.com/ElJoker63/toDus-API/compare/v1.3.0...v1.3.1
|
|
58
92
|
[1.3.0]: https://github.com/ElJoker63/toDus-API/compare/v1.2.0...v1.3.0
|
|
59
93
|
[1.2.0]: https://github.com/ElJoker63/toDus-API/compare/v1.1.0...v1.2.0
|
|
60
94
|
[1.1.0]: https://github.com/ElJoker63/toDus-API/compare/v1.0.0...v1.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: toDus-API
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
4
4
|
Summary: Cliente Python para ToDus (mensajería cubana) — chat, grupos, archivos, stickers y más
|
|
5
5
|
Author: ElJoker63
|
|
6
6
|
License-Expression: MIT
|
|
@@ -34,15 +34,15 @@ Dynamic: license-file
|
|
|
34
34
|
<p align="center">
|
|
35
35
|
<a href="https://pypi.org/project/toDus-API/"><img src="https://img.shields.io/pypi/v/toDus-API" alt="PyPI"></a>
|
|
36
36
|
<a href="https://pypi.org/project/toDus-API/"><img src="https://img.shields.io/pypi/pyversions/toDus-API" alt="Python"></a>
|
|
37
|
-
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml"><img src="https://
|
|
38
|
-
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml"><img src="https://
|
|
39
|
-
<a href="https://github.com/ElJoker63/toDus-API/blob/main/LICENSE"><img src="https://img.shields.io/
|
|
37
|
+
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml"><img src="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml/badge.svg?branch=main" alt="Tests"></a>
|
|
38
|
+
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml"><img src="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml/badge.svg?branch=main" alt="Publish"></a>
|
|
39
|
+
<a href="https://github.com/ElJoker63/toDus-API/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"></a>
|
|
40
40
|
</p>
|
|
41
41
|
|
|
42
42
|
<p><strong>Cliente Python para ToDus</strong> — la plataforma de mensajería instantánea cubana. Soporta chat privado, grupos MUC Light, archivos, imágenes, videos, stickers, botones interactivos y más.</p>
|
|
43
43
|
|
|
44
44
|
<ul>
|
|
45
|
-
<li><strong>Versión:</strong> 1.3.
|
|
45
|
+
<li><strong>Versión:</strong> 1.3.5</li>
|
|
46
46
|
<li><strong>Python:</strong> >= 3.11</li>
|
|
47
47
|
<li><strong>Autor:</strong> ElJoker63</li>
|
|
48
48
|
<li><strong>Licencia:</strong> MIT</li>
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<a href="https://pypi.org/project/toDus-API/"><img src="https://img.shields.io/pypi/v/toDus-API" alt="PyPI"></a>
|
|
5
5
|
<a href="https://pypi.org/project/toDus-API/"><img src="https://img.shields.io/pypi/pyversions/toDus-API" alt="Python"></a>
|
|
6
|
-
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml"><img src="https://
|
|
7
|
-
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml"><img src="https://
|
|
8
|
-
<a href="https://github.com/ElJoker63/toDus-API/blob/main/LICENSE"><img src="https://img.shields.io/
|
|
6
|
+
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml"><img src="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml/badge.svg?branch=main" alt="Tests"></a>
|
|
7
|
+
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml"><img src="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml/badge.svg?branch=main" alt="Publish"></a>
|
|
8
|
+
<a href="https://github.com/ElJoker63/toDus-API/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"></a>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p><strong>Cliente Python para ToDus</strong> — la plataforma de mensajería instantánea cubana. Soporta chat privado, grupos MUC Light, archivos, imágenes, videos, stickers, botones interactivos y más.</p>
|
|
12
12
|
|
|
13
13
|
<ul>
|
|
14
|
-
<li><strong>Versión:</strong> 1.3.
|
|
14
|
+
<li><strong>Versión:</strong> 1.3.5</li>
|
|
15
15
|
<li><strong>Python:</strong> >= 3.11</li>
|
|
16
16
|
<li><strong>Autor:</strong> ElJoker63</li>
|
|
17
17
|
<li><strong>Licencia:</strong> MIT</li>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""Tests para el soporte de proxy en ToDus."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
import socks
|
|
5
|
+
from todus.client.base import ToDusClientBase
|
|
6
|
+
from todus.client import ToDusClient2
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TestProxySupport:
|
|
10
|
+
def test_parse_socks5_proxy_basic(self):
|
|
11
|
+
client = ToDusClientBase()
|
|
12
|
+
proxy_type, host, port, username, password = client._parse_proxy("socks5://127.0.0.1:1080")
|
|
13
|
+
assert proxy_type == socks.SOCKS5
|
|
14
|
+
assert host == "127.0.0.1"
|
|
15
|
+
assert port == 1080
|
|
16
|
+
assert username is None
|
|
17
|
+
assert password is None
|
|
18
|
+
|
|
19
|
+
def test_parse_socks5_proxy_auth(self):
|
|
20
|
+
client = ToDusClientBase()
|
|
21
|
+
proxy_type, host, port, username, password = client._parse_proxy("socks5://user:pass@127.0.0.1:1080")
|
|
22
|
+
assert proxy_type == socks.SOCKS5
|
|
23
|
+
assert host == "127.0.0.1"
|
|
24
|
+
assert port == 1080
|
|
25
|
+
assert username == "user"
|
|
26
|
+
assert password == "pass"
|
|
27
|
+
|
|
28
|
+
def test_parse_http_proxy_default_port(self):
|
|
29
|
+
client = ToDusClientBase()
|
|
30
|
+
proxy_type, host, port, username, password = client._parse_proxy("http://proxy.example.com")
|
|
31
|
+
assert proxy_type == socks.HTTP
|
|
32
|
+
assert host == "proxy.example.com"
|
|
33
|
+
assert port == 8080
|
|
34
|
+
assert username is None
|
|
35
|
+
assert password is None
|
|
36
|
+
|
|
37
|
+
def test_parse_socks5h_proxy(self):
|
|
38
|
+
client = ToDusClientBase()
|
|
39
|
+
proxy_type, host, port, username, password = client._parse_proxy("socks5h://127.0.0.1")
|
|
40
|
+
assert proxy_type == socks.SOCKS5
|
|
41
|
+
assert host == "127.0.0.1"
|
|
42
|
+
assert port == 1080
|
|
43
|
+
|
|
44
|
+
def test_parse_unsupported_scheme(self):
|
|
45
|
+
client = ToDusClientBase()
|
|
46
|
+
with pytest.raises(ValueError):
|
|
47
|
+
client._parse_proxy("ftp://127.0.0.1")
|
|
48
|
+
|
|
49
|
+
def test_client_init_with_proxy(self):
|
|
50
|
+
proxy_url = "socks5://127.0.0.1:1080"
|
|
51
|
+
client = ToDusClientBase(proxy=proxy_url)
|
|
52
|
+
assert client.proxy == proxy_url
|
|
53
|
+
assert client.session.proxies == {
|
|
54
|
+
"http": proxy_url,
|
|
55
|
+
"https": proxy_url,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
def test_client2_init_with_proxy(self):
|
|
59
|
+
proxy_url = "http://127.0.0.1:8080"
|
|
60
|
+
client = ToDusClient2(phone_number="5312345678", password="pass", proxy=proxy_url)
|
|
61
|
+
assert client.proxy == proxy_url
|
|
62
|
+
assert client.session.proxies == {
|
|
63
|
+
"http": proxy_url,
|
|
64
|
+
"https": proxy_url,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
def test_upload_file_uses_session(self, monkeypatch):
|
|
68
|
+
client = ToDusClient2(phone_number="5312345678", password="pass", proxy="http://127.0.0.1:8080")
|
|
69
|
+
client._token = "mock_token"
|
|
70
|
+
|
|
71
|
+
def mock_reserve(*args, **kwargs):
|
|
72
|
+
return "https://upload.todus.cu/put", "https://download.todus.cu/get"
|
|
73
|
+
monkeypatch.setattr(client, "reserve_upload_url", mock_reserve)
|
|
74
|
+
|
|
75
|
+
called_args = []
|
|
76
|
+
class MockResponse:
|
|
77
|
+
def raise_for_status(self):
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
def mock_put(url, *args, **kwargs):
|
|
81
|
+
called_args.append(url)
|
|
82
|
+
return MockResponse()
|
|
83
|
+
|
|
84
|
+
monkeypatch.setattr(client.session, "put", mock_put)
|
|
85
|
+
|
|
86
|
+
down_url = client.upload_file(b"test data", file_name="test.txt")
|
|
87
|
+
|
|
88
|
+
assert down_url == "https://download.todus.cu/get"
|
|
89
|
+
assert len(called_args) == 1
|
|
90
|
+
assert called_args[0] == "https://upload.todus.cu/put"
|
|
91
|
+
assert client.session.proxies == {
|
|
92
|
+
"http": "http://127.0.0.1:8080",
|
|
93
|
+
"https": "http://127.0.0.1:8080",
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
def test_upload_avatar_uses_session(self, monkeypatch):
|
|
97
|
+
client = ToDusClient2(phone_number="5312345678", password="pass", proxy="http://127.0.0.1:8080")
|
|
98
|
+
client._token = "mock_token"
|
|
99
|
+
|
|
100
|
+
urls = [
|
|
101
|
+
("https://upload.todus.cu/put_main", "https://download.todus.cu/get_main"),
|
|
102
|
+
("https://upload.todus.cu/put_thumb", "https://download.todus.cu/get_thumb")
|
|
103
|
+
]
|
|
104
|
+
url_idx = 0
|
|
105
|
+
def mock_reserve(*args, **kwargs):
|
|
106
|
+
nonlocal url_idx
|
|
107
|
+
val = urls[url_idx]
|
|
108
|
+
url_idx += 1
|
|
109
|
+
return val
|
|
110
|
+
monkeypatch.setattr(client, "reserve_upload_url", mock_reserve)
|
|
111
|
+
|
|
112
|
+
called_urls = []
|
|
113
|
+
class MockResponse:
|
|
114
|
+
def raise_for_status(self):
|
|
115
|
+
pass
|
|
116
|
+
|
|
117
|
+
def mock_put(url, *args, **kwargs):
|
|
118
|
+
called_urls.append(url)
|
|
119
|
+
return MockResponse()
|
|
120
|
+
|
|
121
|
+
monkeypatch.setattr(client.session, "put", mock_put)
|
|
122
|
+
|
|
123
|
+
profile_url, thumb_url = client.upload_avatar(b"main_image", b"thumb_image")
|
|
124
|
+
|
|
125
|
+
assert profile_url == "https://download.todus.cu/get_main"
|
|
126
|
+
assert thumb_url == "https://download.todus.cu/get_thumb"
|
|
127
|
+
assert len(called_urls) == 2
|
|
128
|
+
assert called_urls[0] == "https://upload.todus.cu/put_main"
|
|
129
|
+
assert called_urls[1] == "https://upload.todus.cu/put_thumb"
|
|
130
|
+
assert client.session.proxies == {
|
|
131
|
+
"http": "http://127.0.0.1:8080",
|
|
132
|
+
"https": "http://127.0.0.1:8080",
|
|
133
|
+
}
|
|
134
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: toDus-API
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
4
4
|
Summary: Cliente Python para ToDus (mensajería cubana) — chat, grupos, archivos, stickers y más
|
|
5
5
|
Author: ElJoker63
|
|
6
6
|
License-Expression: MIT
|
|
@@ -34,15 +34,15 @@ Dynamic: license-file
|
|
|
34
34
|
<p align="center">
|
|
35
35
|
<a href="https://pypi.org/project/toDus-API/"><img src="https://img.shields.io/pypi/v/toDus-API" alt="PyPI"></a>
|
|
36
36
|
<a href="https://pypi.org/project/toDus-API/"><img src="https://img.shields.io/pypi/pyversions/toDus-API" alt="Python"></a>
|
|
37
|
-
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml"><img src="https://
|
|
38
|
-
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml"><img src="https://
|
|
39
|
-
<a href="https://github.com/ElJoker63/toDus-API/blob/main/LICENSE"><img src="https://img.shields.io/
|
|
37
|
+
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml"><img src="https://github.com/ElJoker63/toDus-API/actions/workflows/ci.yml/badge.svg?branch=main" alt="Tests"></a>
|
|
38
|
+
<a href="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml"><img src="https://github.com/ElJoker63/toDus-API/actions/workflows/pypi-publish.yml/badge.svg?branch=main" alt="Publish"></a>
|
|
39
|
+
<a href="https://github.com/ElJoker63/toDus-API/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"></a>
|
|
40
40
|
</p>
|
|
41
41
|
|
|
42
42
|
<p><strong>Cliente Python para ToDus</strong> — la plataforma de mensajería instantánea cubana. Soporta chat privado, grupos MUC Light, archivos, imágenes, videos, stickers, botones interactivos y más.</p>
|
|
43
43
|
|
|
44
44
|
<ul>
|
|
45
|
-
<li><strong>Versión:</strong> 1.3.
|
|
45
|
+
<li><strong>Versión:</strong> 1.3.5</li>
|
|
46
46
|
<li><strong>Python:</strong> >= 3.11</li>
|
|
47
47
|
<li><strong>Autor:</strong> ElJoker63</li>
|
|
48
48
|
<li><strong>Licencia:</strong> MIT</li>
|
|
@@ -18,7 +18,7 @@ from .errors import (
|
|
|
18
18
|
from .util import normalize_phone, build_jid, generate_token, jwt_decode_payload, timestamp_ms, format_size
|
|
19
19
|
from .parser import IncrementalParser, parse_tdack
|
|
20
20
|
|
|
21
|
-
__version__ = "1.3.
|
|
21
|
+
__version__ = "1.3.5"
|
|
22
22
|
__all__ = [
|
|
23
23
|
"ToDusClient",
|
|
24
24
|
"ToDusClient2",
|
|
@@ -94,7 +94,7 @@ class ToDusFileMixin:
|
|
|
94
94
|
def upload_file(self, token: str, data: bytes, file_type: FileType = FileType.FILE, progress_callback: Callable[[int, int], None] = None, file_name: str = "") -> str:
|
|
95
95
|
up_url, down_url = self.reserve_upload_url(token, len(data), file_type, file_name=file_name)
|
|
96
96
|
upload_data = _ProgressReader(data, progress_callback) if progress_callback else data
|
|
97
|
-
resp =
|
|
97
|
+
resp = self.session.put(
|
|
98
98
|
up_url,
|
|
99
99
|
data=upload_data,
|
|
100
100
|
headers={"Content-Length": str(len(data))},
|
|
@@ -34,7 +34,7 @@ class ToDusProfileMixin:
|
|
|
34
34
|
thumbnail_data = image_data
|
|
35
35
|
|
|
36
36
|
up_url, down_url = self.reserve_upload_url(token, len(image_data), FileType.PROFILE)
|
|
37
|
-
resp =
|
|
37
|
+
resp = self.session.put(
|
|
38
38
|
up_url,
|
|
39
39
|
data=image_data,
|
|
40
40
|
headers={"Content-Length": str(len(image_data)), "Content-Type": "application/octet-stream"},
|
|
@@ -44,7 +44,7 @@ class ToDusProfileMixin:
|
|
|
44
44
|
profile_url = down_url
|
|
45
45
|
|
|
46
46
|
up_url, down_url = self.reserve_upload_url(token, len(thumbnail_data), FileType.PROFILE_THUMBNAIL)
|
|
47
|
-
resp =
|
|
47
|
+
resp = self.session.put(
|
|
48
48
|
up_url,
|
|
49
49
|
data=thumbnail_data,
|
|
50
50
|
headers={"Content-Length": str(len(thumbnail_data)), "Content-Type": "application/octet-stream"},
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"""Tests para el soporte de proxy en ToDus."""
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
import socks
|
|
5
|
-
from todus.client.base import ToDusClientBase
|
|
6
|
-
from todus.client import ToDusClient2
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class TestProxySupport:
|
|
10
|
-
def test_parse_socks5_proxy_basic(self):
|
|
11
|
-
client = ToDusClientBase()
|
|
12
|
-
proxy_type, host, port, username, password = client._parse_proxy("socks5://127.0.0.1:1080")
|
|
13
|
-
assert proxy_type == socks.SOCKS5
|
|
14
|
-
assert host == "127.0.0.1"
|
|
15
|
-
assert port == 1080
|
|
16
|
-
assert username is None
|
|
17
|
-
assert password is None
|
|
18
|
-
|
|
19
|
-
def test_parse_socks5_proxy_auth(self):
|
|
20
|
-
client = ToDusClientBase()
|
|
21
|
-
proxy_type, host, port, username, password = client._parse_proxy("socks5://user:pass@127.0.0.1:1080")
|
|
22
|
-
assert proxy_type == socks.SOCKS5
|
|
23
|
-
assert host == "127.0.0.1"
|
|
24
|
-
assert port == 1080
|
|
25
|
-
assert username == "user"
|
|
26
|
-
assert password == "pass"
|
|
27
|
-
|
|
28
|
-
def test_parse_http_proxy_default_port(self):
|
|
29
|
-
client = ToDusClientBase()
|
|
30
|
-
proxy_type, host, port, username, password = client._parse_proxy("http://proxy.example.com")
|
|
31
|
-
assert proxy_type == socks.HTTP
|
|
32
|
-
assert host == "proxy.example.com"
|
|
33
|
-
assert port == 8080
|
|
34
|
-
assert username is None
|
|
35
|
-
assert password is None
|
|
36
|
-
|
|
37
|
-
def test_parse_socks5h_proxy(self):
|
|
38
|
-
client = ToDusClientBase()
|
|
39
|
-
proxy_type, host, port, username, password = client._parse_proxy("socks5h://127.0.0.1")
|
|
40
|
-
assert proxy_type == socks.SOCKS5
|
|
41
|
-
assert host == "127.0.0.1"
|
|
42
|
-
assert port == 1080
|
|
43
|
-
|
|
44
|
-
def test_parse_unsupported_scheme(self):
|
|
45
|
-
client = ToDusClientBase()
|
|
46
|
-
with pytest.raises(ValueError):
|
|
47
|
-
client._parse_proxy("ftp://127.0.0.1")
|
|
48
|
-
|
|
49
|
-
def test_client_init_with_proxy(self):
|
|
50
|
-
proxy_url = "socks5://127.0.0.1:1080"
|
|
51
|
-
client = ToDusClientBase(proxy=proxy_url)
|
|
52
|
-
assert client.proxy == proxy_url
|
|
53
|
-
assert client.session.proxies == {
|
|
54
|
-
"http": proxy_url,
|
|
55
|
-
"https": proxy_url,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
def test_client2_init_with_proxy(self):
|
|
59
|
-
proxy_url = "http://127.0.0.1:8080"
|
|
60
|
-
client = ToDusClient2(phone_number="5312345678", password="pass", proxy=proxy_url)
|
|
61
|
-
assert client.proxy == proxy_url
|
|
62
|
-
assert client.session.proxies == {
|
|
63
|
-
"http": proxy_url,
|
|
64
|
-
"https": proxy_url,
|
|
65
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|