18 lines
747 B
Python
18 lines
747 B
Python
|
|
"""Tests for Baota signed download URLs."""
|
||
|
|
|
||
|
|
from server.infrastructure.btpanel.credentials import BtPanelCredentials
|
||
|
|
from server.infrastructure.btpanel.file_urls import signed_download_url
|
||
|
|
|
||
|
|
|
||
|
|
def test_signed_download_url_encodes_path_and_includes_token(monkeypatch):
|
||
|
|
monkeypatch.setattr("server.infrastructure.btpanel.file_urls.time.time", lambda: 1700000000)
|
||
|
|
creds = BtPanelCredentials(
|
||
|
|
base_url="https://1.2.3.4:8888",
|
||
|
|
api_key="test-api-key",
|
||
|
|
)
|
||
|
|
url = signed_download_url(creds, "/tmp/nexus-bt-xfer-abc.tar.gz")
|
||
|
|
assert url.startswith("https://1.2.3.4:8888/download?filename=")
|
||
|
|
assert "%2Ftmp%2Fnexus-bt-xfer-abc.tar.gz" in url
|
||
|
|
assert "request_time=1700000000" in url
|
||
|
|
assert "request_token=" in url
|