- INT-01: Add E2E streaming tests (upload -> HLS auth) - INT-02: Add E2E cloud tests (CRUD auth, public gear) - INT-03: Split track/handler.go into 4 focused sub-handlers - INT-04: Create migration squash script + MIGRATIONS.md - INT-05: Add Trivy container image scanning CI workflow - INT-06: Replace production console.log with structured logger
55 lines
1.8 KiB
Go
55 lines
1.8 KiB
Go
//go:build integration
|
|
// +build integration
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestE2E_UploadTrackTriggerHLS(t *testing.T) {
|
|
router, cleanup := setupE2ETestRouter(t)
|
|
defer cleanup()
|
|
ts := httptest.NewServer(router)
|
|
defer ts.Close()
|
|
|
|
t.Run("health check before streaming", func(t *testing.T) {
|
|
resp, err := http.Get(ts.URL + "/api/v1/health")
|
|
require.NoError(t, err)
|
|
defer resp.Body.Close()
|
|
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
|
})
|
|
|
|
t.Run("unauthenticated track upload is rejected", func(t *testing.T) {
|
|
resp, err := http.Post(ts.URL+"/api/v1/tracks", "application/json", nil)
|
|
require.NoError(t, err)
|
|
defer resp.Body.Close()
|
|
assert.True(t, resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusBadRequest)
|
|
})
|
|
|
|
t.Run("waveform endpoint returns 404 for nonexistent track", func(t *testing.T) {
|
|
resp, err := http.Get(ts.URL + "/api/v1/tracks/00000000-0000-0000-0000-000000000000/waveform")
|
|
require.NoError(t, err)
|
|
defer resp.Body.Close()
|
|
assert.Equal(t, http.StatusNotFound, resp.StatusCode)
|
|
})
|
|
|
|
t.Run("HLS manifest requires authentication", func(t *testing.T) {
|
|
resp, err := http.Get(ts.URL + "/api/v1/tracks/00000000-0000-0000-0000-000000000000/hls/master.m3u8")
|
|
require.NoError(t, err)
|
|
defer resp.Body.Close()
|
|
assert.True(t, resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusNotFound)
|
|
})
|
|
|
|
t.Run("stream token endpoint requires auth", func(t *testing.T) {
|
|
resp, err := http.Post(ts.URL+"/api/v1/auth/stream-token", "application/json", nil)
|
|
require.NoError(t, err)
|
|
defer resp.Body.Close()
|
|
assert.True(t, resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusBadRequest)
|
|
})
|
|
}
|