update external authentication tests

This commit is contained in:
aler9 2022-01-23 23:03:58 +01:00 committed by Alessandro Ros
parent e3f63a43c9
commit c208cb9aff
3 changed files with 13 additions and 9 deletions

View File

@ -48,6 +48,7 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) {
Password string `json:"password"`
Path string `json:"path"`
Action string `json:"action"`
Query string `json:"query"`
}
err := json.NewDecoder(ctx.Request.Body).Decode(&in)
if err != nil {
@ -66,7 +67,10 @@ func (ts *testHTTPAuthenticator) onAuth(ctx *gin.Context) {
in.User != user ||
in.Password != "testpass" ||
in.Path != "teststream" ||
in.Action != ts.action {
in.Action != ts.action ||
(in.Query != "user=testreader&pass=testpass&param=value" &&
in.Query != "user=testpublisher&pass=testpass&param=value" &&
in.Query != "param=value") {
ctx.AbortWithStatus(http.StatusBadRequest)
return
}
@ -156,7 +160,7 @@ func TestHLSServerAuth(t *testing.T) {
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "rtsp",
"rtsp://testpublisher:testpass@127.0.0.1:8554/teststream",
"rtsp://testpublisher:testpass@127.0.0.1:8554/teststream?param=value",
})
require.NoError(t, err)
defer cnt1.close()
@ -178,7 +182,7 @@ func TestHLSServerAuth(t *testing.T) {
usr = "testreader2"
}
res, err := http.Get("http://" + usr + ":testpass@127.0.0.1:8888/teststream/index.m3u8")
res, err := http.Get("http://" + usr + ":testpass@127.0.0.1:8888/teststream/index.m3u8?param=value")
require.NoError(t, err)
defer res.Body.Close()

View File

@ -120,7 +120,7 @@ func TestRTMPServerAuth(t *testing.T) {
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "flv",
"rtmp://127.0.0.1/teststream?user=testpublisher&pass=testpass",
"rtmp://127.0.0.1/teststream?user=testpublisher&pass=testpass&param=value",
})
require.NoError(t, err)
defer cnt1.close()
@ -135,7 +135,7 @@ func TestRTMPServerAuth(t *testing.T) {
}
conn, err := rtmp.DialContext(context.Background(),
"rtmp://127.0.0.1/teststream?user=testreader&pass=testpass")
"rtmp://127.0.0.1/teststream?user=testreader&pass=testpass&param=value")
require.NoError(t, err)
defer conn.Close()
@ -189,7 +189,7 @@ func TestRTMPServerAuthFail(t *testing.T) {
"-i", "emptyvideo.mkv",
"-c", "copy",
"-f", "flv",
"rtmp://localhost/teststream?user=testuser2&pass=testpass",
"rtmp://localhost/teststream?user=testuser2&pass=testpass&param=value",
})
require.NoError(t, err)
defer cnt1.close()

View File

@ -236,7 +236,7 @@ func TestRTSPServerAuth(t *testing.T) {
source := gortsplib.Client{}
err = source.StartPublishing(
"rtsp://testpublisher:testpass@127.0.0.1:8554/teststream",
"rtsp://testpublisher:testpass@127.0.0.1:8554/teststream?param=value",
gortsplib.Tracks{track})
require.NoError(t, err)
defer source.Close()
@ -251,7 +251,7 @@ func TestRTSPServerAuth(t *testing.T) {
reader := gortsplib.Client{}
err = reader.StartReading("rtsp://testreader:testpass@127.0.0.1:8554/teststream")
err = reader.StartReading("rtsp://testreader:testpass@127.0.0.1:8554/teststream?param=value")
require.NoError(t, err)
defer reader.Close()
})
@ -407,7 +407,7 @@ func TestRTSPServerAuthFail(t *testing.T) {
c := gortsplib.Client{}
err = c.StartPublishing(
"rtsp://testpublisher2:testpass@localhost:8554/teststream",
"rtsp://testpublisher2:testpass@localhost:8554/teststream?param=value",
gortsplib.Tracks{track},
)
require.EqualError(t, err, "bad status code: 401 (Unauthorized)")