Resolve the full review backlog (issues #1-#13)
Some checks failed
Build TV app / build (push) Failing after 2s
Some checks failed
Build TV app / build (push) Failing after 2s
Control server security and robustness: - Socket read timeout, handshake deadline and a client cap so an idle or hostile connection can no longer pin threads forever (#1) - Per-address rate limiting that counts every failed hello, Origin checking on the upgrade, and a separate revocable session token for code-authenticated clients so the guessable path no longer yields the QR credential (#2) - Credentials excluded from cloud backup and device transfer, constant time comparisons, and a pairing reset in the settings (#3) - Playlist fetches restricted to http(s), capped at 24 MB and bounded by an overall transfer deadline (#4) - Port conflicts and MediaSession id collisions no longer crash the app; the remote degrades to unavailable with a plain-language note (#11) Player: - Seeking no longer collapses to position 0 when the duration is unknown (#5) - Pause acts on playWhenReady, so pausing during a stall works and playback cannot resume in the background after leaving the app (#6) - Playback failures stay on screen with a retry action instead of silently dropping back to the list (#7) - Reconnects are spaced 1s/3s/8s and re-entering the channel just closed waits out a short grace period, which is what the provider needs to release the previous session (#12) Channel list and remote: - Leaving playback returns to the channel the viewer came from (#13) - The remote only rebuilds its list when the data changed, never overwrites a focused input and carries indices instead of scanning (#8) - Pairing retry reconnects properly, resets its backoff and validates the code before spending an attempt (#9) - M3U parsing keeps commas in names, strips a BOM and rejects payloads that are not playlists, covered by unit tests under tests/ (#10) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
80
tests/unit/M3uParserTest.kt
Normal file
80
tests/unit/M3uParserTest.kt
Normal file
@@ -0,0 +1,80 @@
|
||||
package dev.castarr.tv.playlist
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class M3uParserTest {
|
||||
|
||||
@Test
|
||||
fun `keeps commas inside display names`() {
|
||||
val channels = M3uParser.parse(
|
||||
"""
|
||||
#EXTM3U
|
||||
#EXTINF:-1 group-title="Doku",Comedy Central, HD
|
||||
http://example.com/a.ts
|
||||
""".trimIndent()
|
||||
)
|
||||
assertEquals(1, channels.size)
|
||||
assertEquals("Comedy Central, HD", channels[0].name)
|
||||
assertEquals("Doku", channels[0].group)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `commas inside attributes do not split the name`() {
|
||||
val channels = M3uParser.parse(
|
||||
"""
|
||||
#EXTM3U
|
||||
#EXTINF:-1 group-title="News, Sport" tvg-id="x",Das Erste HD
|
||||
http://example.com/b.ts
|
||||
""".trimIndent()
|
||||
)
|
||||
assertEquals("Das Erste HD", channels[0].name)
|
||||
assertEquals("News, Sport", channels[0].group)
|
||||
assertEquals("x", channels[0].tvgId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `strips a UTF-8 BOM instead of inventing a channel`() {
|
||||
val channels = M3uParser.parse(
|
||||
"#EXTM3U\n#EXTINF:-1,Channel A\nhttp://example.com/a.ts\n"
|
||||
)
|
||||
assertEquals(1, channels.size)
|
||||
assertEquals("Channel A", channels[0].name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `rejects HTML instead of turning it into channels`() {
|
||||
assertThrows(M3uParser.NotAPlaylistException::class.java) {
|
||||
M3uParser.parse("<!DOCTYPE html>\n<html>\n<body>404</body>\n</html>")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `rejects an empty payload`() {
|
||||
assertThrows(M3uParser.NotAPlaylistException::class.java) {
|
||||
M3uParser.parse("")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `accepts a playlist whose header is missing but has entries`() {
|
||||
val channels = M3uParser.parse("#EXTINF:-1,Nur ein Sender\nhttp://example.com/c.ts")
|
||||
assertEquals(1, channels.size)
|
||||
assertEquals("Nur ein Sender", channels[0].name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `falls back to the url when the name is empty`() {
|
||||
val channels = M3uParser.parse("#EXTM3U\n#EXTINF:-1,\nhttp://example.com/d.ts")
|
||||
assertEquals("http://example.com/d.ts", channels[0].name)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `carries EXTGRP over to a bare url`() {
|
||||
val channels = M3uParser.parse("#EXTM3U\n#EXTGRP:Sport\nhttp://example.com/e.ts")
|
||||
assertTrue(channels.isNotEmpty())
|
||||
assertEquals("Sport", channels[0].group)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user