package updownctrl import ( "net/url" "strings" "testing" "time" "91porn-server/common/hevcpull" ) func TestSignedTranscodeChildPlaylistURI(t *testing.T) { now := time.Date(2026, 7, 25, 12, 0, 0, 0, time.UTC) expiresAt := now.Add(time.Hour) secret := "test-pull-secret-strong-32-bytes!!" childURI, err := signedTranscodeChildPlaylistURI( "sp/movie/master.m3u8", "720/index.m3u8", secret, expiresAt, ) if err != nil { t.Fatalf("signedTranscodeChildPlaylistURI failed: %v", err) } if !strings.HasPrefix(childURI, transcodeM3u8RoutePrefix+"sp/movie/720/index.m3u8?") { t.Fatalf("unexpected child URI: %s", childURI) } parsed, err := url.Parse("https://app.example.com" + childURI) if err != nil { t.Fatalf("parse child URI: %v", err) } if err = hevcpull.VerifyURL(parsed, secret, now); err != nil { t.Fatalf("child URI signature failed: %v", err) } if _, err = signedTranscodeChildPlaylistURI( "sp/movie/master.m3u8", "https://external.example.com/index.m3u8", secret, expiresAt, ); err == nil { t.Fatal("absolute child playlist was accepted") } } func TestTranscodePlaybackSourcePreservesExistingM3u8Semantics(t *testing.T) { for _, source := range []string{ "sp/movie/index.m3u8", "pms/movie/index.m3u8", "laosiji/m3m/movie/index.m3u8", } { got := transcodePlaybackSource(source) if got != "/"+source { t.Fatalf("transcodePlaybackSource(%q) = %q", source, got) } } }