//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) }) }