From 6ebb4e49e9bc4d2b38b1c27fe63bdef54b0be0ac Mon Sep 17 00:00:00 2001 From: Mathias Date: Thu, 1 Oct 2026 17:14:29 +0200 Subject: [PATCH] test(audio): opt-in live ffprobe check on hostile playlists and real audio Skipped unless TAPIR_LIVE_FFPROBE is set. Synthetic/crafted files only. Co-Authored-By: Claude Sonnet 5.5 --- internal/adapters/audio/hostile_live_test.go | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 internal/adapters/audio/hostile_live_test.go diff --git a/internal/adapters/audio/hostile_live_test.go b/internal/adapters/audio/hostile_live_test.go new file mode 100644 index 0000000..35a0958 --- /dev/null +++ b/internal/adapters/audio/hostile_live_test.go @@ -0,0 +1,32 @@ +package audio_test + +import ( + "context" + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "git.d-ma.be/mathias/tapir/internal/adapters/audio" + "git.d-ma.be/mathias/tapir/internal/uploads" +) + +// TestFFprobeLive_HostilePlaylistsAreRefusedAndRealAudioIsNot runs the REAL ffprobe +// (opt-in: TAPIR_LIVE_FFPROBE) on crafted concat/HLS files and on a real m4a. +func TestFFprobeLive_HostilePlaylistsAreRefusedAndRealAudioIsNot(t *testing.T) { + bin := os.Getenv("TAPIR_LIVE_FFPROBE") + if bin == "" { + t.Skip("set TAPIR_LIVE_FFPROBE (and TAPIR_LIVE_HOSTILE_DIR, TAPIR_LIVE_M4A) to run against the real ffprobe") + } + p := &audio.FFprobe{Bin: bin} + for _, name := range []string{"up-concat", "up-hls"} { + _, err := p.Probe(context.Background(), os.Getenv("TAPIR_LIVE_HOSTILE_DIR")+"/"+name) + assert.ErrorIs(t, err, uploads.ErrUnreadable, name) + } + got, err := p.Probe(context.Background(), os.Getenv("TAPIR_LIVE_M4A")) + require.NoError(t, err) + assert.True(t, got.HasAudio) + assert.False(t, got.HasVideo) + assert.InDelta(t, 82.5, got.Duration.Seconds(), 1) +}