From 741eccb5759608c31d61b6afae5a5311b5f83b5e Mon Sep 17 00:00:00 2001 From: Mathias Date: Fri, 2 Oct 2026 16:43:46 +0200 Subject: [PATCH] test: the duration limit is checked against what is converted, not what the header claims (red; adversarial review F2) Co-Authored-By: Claude Sonnet 5.5 --- cmd/tapir/uploads_converter_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cmd/tapir/uploads_converter_test.go diff --git a/cmd/tapir/uploads_converter_test.go b/cmd/tapir/uploads_converter_test.go new file mode 100644 index 0000000..a8bde82 --- /dev/null +++ b/cmd/tapir/uploads_converter_test.go @@ -0,0 +1,26 @@ +package main + +import ( + "testing" + "time" + + "git.d-ma.be/mathias/tapir/internal/config" +) + +// The converter is told the configured maximum, so a file whose header lies about its +// length cannot become hours of WAV (adversarial review F2). + +func TestNewConverter_IsCappedAtTheConfiguredMaximumDuration(t *testing.T) { + var cfg config.Config + cfg.FFmpegBin = "/usr/local/bin/ffmpeg" + cfg.UploadMaxDuration = 90 * time.Minute + + c := newConverter(cfg) + + if c.Bin != "/usr/local/bin/ffmpeg" { + t.Errorf("Bin = %q", c.Bin) + } + if c.MaxSeconds != 5400 { + t.Errorf("MaxSeconds = %v, want 5400", c.MaxSeconds) + } +}