mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-20 23:21:06 +02:00
test(proxy): cover dataimpulse sticky-session urls
This commit is contained in:
parent
f1ee166f19
commit
b5b700c853
1 changed files with 46 additions and 0 deletions
46
surfsense_backend/tests/unit/platforms/amazon/test_proxy.py
Normal file
46
surfsense_backend/tests/unit/platforms/amazon/test_proxy.py
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from app.config import Config
|
||||||
|
from app.utils.proxy.providers.dataimpulse import DataImpulseProvider
|
||||||
|
|
||||||
|
|
||||||
|
def test_dataimpulse_sticky_url_is_deterministic(monkeypatch):
|
||||||
|
monkeypatch.setattr(
|
||||||
|
Config,
|
||||||
|
"PROXY_URL",
|
||||||
|
"http://token__cr.us:secret@gw.dataimpulse.com:823",
|
||||||
|
)
|
||||||
|
provider = DataImpulseProvider()
|
||||||
|
|
||||||
|
first = provider.get_sticky_proxy_url("location-123")
|
||||||
|
second = provider.get_sticky_proxy_url("location-123")
|
||||||
|
|
||||||
|
assert first == second
|
||||||
|
assert "token__cr.us__sid.location-123" in first
|
||||||
|
assert first.endswith("@gw.dataimpulse.com:823")
|
||||||
|
|
||||||
|
|
||||||
|
def test_dataimpulse_sticky_url_replaces_existing_session(monkeypatch):
|
||||||
|
monkeypatch.setattr(
|
||||||
|
Config,
|
||||||
|
"PROXY_URL",
|
||||||
|
"http://token__cr.us__sid.old:secret@gw.dataimpulse.com:823",
|
||||||
|
)
|
||||||
|
|
||||||
|
result = DataImpulseProvider().get_sticky_proxy_url("new")
|
||||||
|
|
||||||
|
assert "__sid.old" not in result
|
||||||
|
assert result.count("__sid.new") == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_dataimpulse_sticky_url_rejects_empty_session(monkeypatch):
|
||||||
|
monkeypatch.setattr(
|
||||||
|
Config,
|
||||||
|
"PROXY_URL",
|
||||||
|
"http://token:secret@gw.dataimpulse.com:823",
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
DataImpulseProvider().get_sticky_proxy_url("...")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue