Files
shelfmark/tests/prowlarr/test_torznab.py
Alex ac36d539c8 Patch: Various fixes (#660)
Various fixes from the last couple days: 

- Add manual approval option for book/audiobook requests (#651)
- Add flagged HTTP headers 
- Add filesystem fallback - copy + delete when hardlink/move fails
across filesystems (#647)
- Dependency updates
- Tweak frontend test config (simplified tsconfig for tests)
- Fix overlapping sort scoring in release modal - duplicate scoring keys
caused incorrect release ordering (#654 )
- Fix stale search session after download - search state was not
refreshed when returning from a download (#659)
- Fix multi-format release filtering - releases with multiple formats
were incorrectly excluded by the format filter (#658)
- Fix config persistence when action button is used - clicking "Test
connection" reset unsaved settings (#657)
- Fix request grid text positioning in admin request policy panel 
- Fix rTorrent path discovery (#653)
- Fix `/login` API check (#650)
2026-02-25 18:44:46 +00:00

52 lines
1.5 KiB
Python

"""Tests for Torznab XML parsing helpers."""
from shelfmark.release_sources.prowlarr.torznab import parse_torznab_xml
def test_parse_torznab_xml_parses_basic_item():
xml_text = """<?xml version="1.0"?>
<rss>
<channel>
<item>
<title>Example Release</title>
<guid>abc-123</guid>
<link>https://example.com/download</link>
<size>12345</size>
<enclosure type="application/x-bittorrent" url="https://example.com/file.torrent" />
<prowlarrindexer id="42">Test Indexer</prowlarrindexer>
<newznab:attr xmlns:newznab="http://www.newznab.com/DTD/2010/feeds/attributes/"
name="seeders" value="10" />
<newznab:attr xmlns:newznab="http://www.newznab.com/DTD/2010/feeds/attributes/"
name="peers" value="15" />
</item>
</channel>
</rss>
"""
results = parse_torznab_xml(xml_text)
assert len(results) == 1
result = results[0]
assert result["title"] == "Example Release"
assert result["guid"] == "abc-123"
assert result["indexerId"] == 42
assert result["indexer"] == "Test Indexer"
assert result["protocol"] == "torrent"
assert result["seeders"] == 10
assert result["leechers"] == 5
def test_parse_torznab_xml_rejects_entity_expansion_payload():
xml_text = """<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<rss>
<channel>
<item>
<title>&xxe;</title>
</item>
</channel>
</rss>
"""
assert parse_torznab_xml(xml_text) == []