Capture, decrypt, and restream toolkit with compiled-in app modules (RTE, TG4, BBC), on-device MITM proxy, streamd control plane, and www. BBC module.yaml is published (clear streams); other module values stay local.
80 lines
2 KiB
Go
80 lines
2 KiB
Go
package bbc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
appreg "drmdecryption/app"
|
|
"drmdecryption/capture"
|
|
"drmdecryption/modcfg"
|
|
"drmdecryption/modules/provider"
|
|
"drmdecryption/mpd"
|
|
)
|
|
|
|
var (
|
|
_ appreg.App = (*App)(nil)
|
|
_ appreg.StreamDefaults = (*App)(nil)
|
|
_ appreg.TransparentMITM = (*App)(nil)
|
|
)
|
|
|
|
func testApp(t *testing.T) *App {
|
|
t.Helper()
|
|
cfg := Config{
|
|
Channels: map[string]Channel{
|
|
"bbcone": {Label: "BBC One", VPID: "bbc_one_london"},
|
|
"bbctwo": {Label: "BBC Two", VPID: "bbc_two_england"},
|
|
},
|
|
Common: provider.Common{
|
|
Package: "bbc.iplayer.android",
|
|
Aliases: map[string]string{"one": "bbcone", "bbc1": "bbcone"},
|
|
Score: capture.ScoreCfg{
|
|
Hosts: []string{"open.live.bbc.co.uk", "vs-cmaf-push-uk"},
|
|
},
|
|
},
|
|
}.withDefaults()
|
|
labels := map[string]string{}
|
|
for id, ch := range cfg.Channels {
|
|
labels[id] = ch.Label
|
|
}
|
|
return &App{Base: provider.New(Name, cfg.Common, labels, modcfg.Result{Path: "test"}), cfg: cfg}
|
|
}
|
|
|
|
func TestNoHardcodedSecrets(t *testing.T) {
|
|
cfg := Config{}.withDefaults()
|
|
if cfg.Package != "" || cfg.LicenseURL != "" {
|
|
t.Fatalf("empty config must not invent package/license: %+v", cfg)
|
|
}
|
|
}
|
|
|
|
func TestKeyModeNoneAndMPDOnly(t *testing.T) {
|
|
a := testApp(t)
|
|
if a.KeyMode() != "none" {
|
|
t.Fatalf("KeyMode = %q, want none", a.KeyMode())
|
|
}
|
|
h := a.CaptureHints()
|
|
if len(h.Require) != 1 || h.Require[0] != "mpd" {
|
|
t.Fatalf("Require = %v, want [mpd]", h.Require)
|
|
}
|
|
if !a.UseTransparentMITM() {
|
|
t.Fatal("BBC must use transparent MITM (UK VPN)")
|
|
}
|
|
if _, ok := a.MPDRewriter().(mpd.Passthrough); !ok {
|
|
t.Fatal("expected Passthrough rewriter")
|
|
}
|
|
}
|
|
|
|
func TestAliases(t *testing.T) {
|
|
a := testApp(t)
|
|
id, err := a.Resolve("one")
|
|
if err != nil || id != "bbcone" {
|
|
t.Fatalf("Resolve(one) = %q %v", id, err)
|
|
}
|
|
}
|
|
|
|
func TestCaptureHintsScoreHosts(t *testing.T) {
|
|
a := testApp(t)
|
|
h := a.CaptureHints()
|
|
u := "https://vs-cmaf-push-uk.live.fastly.md.bbci.co.uk/x/mobile.mpd"
|
|
if h.Score.Score(u) <= 0 {
|
|
t.Fatalf("expected positive score for %s (score=%d)", u, h.Score.Score(u))
|
|
}
|
|
}
|