Null-DRM-Official/apps/modules/all/all_test.go
404errordeveloper 2fa8f2435f Initial commit: Null DRM Official
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.
2026-10-06 00:25:35 +02:00

72 lines
1.8 KiB
Go

package all
import (
"flag"
"testing"
appreg "drmdecryption/app"
)
// Every module must be constructible with no module.yaml present — a fresh clone
// has none, and the binary still has to start and list its providers.
func TestAllModulesRegisterAndConstruct(t *testing.T) {
names := appreg.Names()
if len(names) == 0 {
t.Fatal("no app modules registered — check the blank imports in all.go")
}
for _, n := range names {
a, err := appreg.Get(n)
if err != nil {
t.Fatalf("construct %s: %v", n, err)
}
if a.Name() != n {
t.Errorf("%s: Name() = %q", n, a.Name())
}
switch a.KeyMode() {
case "raw", "modulardrm", "none":
default:
t.Errorf("%s: KeyMode() = %q, want raw, modulardrm, or none", n, a.KeyMode())
}
if a.CAHash() == "" {
t.Errorf("%s: CAHash() empty", n)
}
if a.ProxyBin() == "" {
t.Errorf("%s: ProxyBin() empty", n)
}
if a.MPDRewriter() == nil {
t.Errorf("%s: MPDRewriter() nil", n)
}
if a.CaptureHints().RemoteLog == "" {
t.Errorf("%s: CaptureHints has no remote log", n)
}
}
}
// Flag binding must not construct any app, so overrides land before config load.
func TestBindFlagsRegistersOverrides(t *testing.T) {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
appreg.BindFlags(fs)
count := 0
fs.VisitAll(func(*flag.Flag) { count++ })
if count == 0 {
t.Fatal("no module override flags registered")
}
}
// A module declaring a rewriter must have registered it under that name.
func TestDeclaredRewritersAreRegistered(t *testing.T) {
for _, a := range appreg.All() {
sd, ok := a.(appreg.StreamDefaults)
if !ok {
continue
}
name := sd.RewriterName()
if name == "" || name == "none" {
continue
}
if a.MPDRewriter().Name() != name {
t.Errorf("%s: RewriterName()=%q but MPDRewriter().Name()=%q",
a.Name(), name, a.MPDRewriter().Name())
}
}
}