mirror of
https://github.com/bluenviron/mediamtx
synced 2025-02-09 07:58:04 +00:00
speed up tests
This commit is contained in:
parent
d4af264fe4
commit
64d9d7f342
@ -283,22 +283,22 @@ func TestClientRTSPAuthFail(t *testing.T) {
|
||||
pass string
|
||||
}{
|
||||
{
|
||||
"publish_wronguser",
|
||||
"wronguser",
|
||||
"test1user",
|
||||
"testpass",
|
||||
},
|
||||
{
|
||||
"publish_wrongpass",
|
||||
"wrongpass",
|
||||
"testuser",
|
||||
"test1pass",
|
||||
},
|
||||
{
|
||||
"publish_wrongboth",
|
||||
"wrongboth",
|
||||
"test1user",
|
||||
"test1pass",
|
||||
},
|
||||
} {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
t.Run("publish_"+ca.name, func(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"hlsDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
@ -308,30 +308,14 @@ func TestClientRTSPAuthFail(t *testing.T) {
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
||||
cnt1, err := newContainer("ffmpeg", "source", []string{
|
||||
"-re",
|
||||
"-stream_loop", "-1",
|
||||
"-i", "emptyvideo.mkv",
|
||||
"-c", "copy",
|
||||
"-f", "rtsp",
|
||||
"-rtsp_transport", "udp",
|
||||
"rtsp://" + ca.user + ":" + ca.pass + "@" + ownDockerIP + ":8554/test/stream",
|
||||
})
|
||||
track, err := gortsplib.NewTrackH264(68, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04})
|
||||
require.NoError(t, err)
|
||||
defer cnt1.close()
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
cnt2, err := newContainer("ffmpeg", "dest", []string{
|
||||
"-rtsp_transport", "udp",
|
||||
"-i", "rtsp://" + ownDockerIP + ":8554/test/stream",
|
||||
"-vframes", "1",
|
||||
"-f", "image2",
|
||||
"-y", "/dev/null",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer cnt2.close()
|
||||
require.Equal(t, 1, cnt2.wait())
|
||||
_, err = gortsplib.DialPublish(
|
||||
"rtsp://"+ca.user+":"+ca.pass+"@"+ownDockerIP+":8554/test/stream",
|
||||
gortsplib.Tracks{track},
|
||||
)
|
||||
require.Equal(t, "wrong status code: 401 (Unauthorized)", err.Error())
|
||||
})
|
||||
}
|
||||
|
||||
@ -341,22 +325,22 @@ func TestClientRTSPAuthFail(t *testing.T) {
|
||||
pass string
|
||||
}{
|
||||
{
|
||||
"read_wronguser",
|
||||
"wronguser",
|
||||
"test1user",
|
||||
"testpass",
|
||||
},
|
||||
{
|
||||
"read_wrongpass",
|
||||
"wrongpass",
|
||||
"testuser",
|
||||
"test1pass",
|
||||
},
|
||||
{
|
||||
"read_wrongboth",
|
||||
"wrongboth",
|
||||
"test1user",
|
||||
"test1pass",
|
||||
},
|
||||
} {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
t.Run("read_"+ca.name, func(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"hlsDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
@ -366,55 +350,31 @@ func TestClientRTSPAuthFail(t *testing.T) {
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
||||
cnt1, err := newContainer("ffmpeg", "source", []string{
|
||||
"-re",
|
||||
"-stream_loop", "-1",
|
||||
"-i", "emptyvideo.mkv",
|
||||
"-c", "copy",
|
||||
"-f", "rtsp",
|
||||
"-rtsp_transport", "udp",
|
||||
"rtsp://" + ownDockerIP + ":8554/test/stream",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer cnt1.close()
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
cnt2, err := newContainer("ffmpeg", "dest", []string{
|
||||
"-rtsp_transport", "udp",
|
||||
"-i", "rtsp://" + ca.user + ":" + ca.pass + "@" + ownDockerIP + ":8554/test/stream",
|
||||
"-vframes", "1",
|
||||
"-f", "image2",
|
||||
"-y", "/dev/null",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer cnt2.close()
|
||||
require.Equal(t, 1, cnt2.wait())
|
||||
_, err := gortsplib.DialRead(
|
||||
"rtsp://" + ca.user + ":" + ca.pass + "@" + ownDockerIP + ":8554/test/stream",
|
||||
)
|
||||
require.Equal(t, "wrong status code: 401 (Unauthorized)", err.Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientRTSPAuthIpFail(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"hlsDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
" all:\n" +
|
||||
" publishIps: [127.0.0.1/32]\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
t.Run("ip", func(t *testing.T) {
|
||||
p, ok := testProgram("rtmpDisable: yes\n" +
|
||||
"hlsDisable: yes\n" +
|
||||
"paths:\n" +
|
||||
" all:\n" +
|
||||
" publishIps: [127.0.0.1/32]\n")
|
||||
require.Equal(t, true, ok)
|
||||
defer p.close()
|
||||
|
||||
cnt1, err := newContainer("ffmpeg", "source", []string{
|
||||
"-re",
|
||||
"-stream_loop", "-1",
|
||||
"-i", "emptyvideo.mkv",
|
||||
"-c", "copy",
|
||||
"-f", "rtsp",
|
||||
"-rtsp_transport", "udp",
|
||||
"rtsp://" + ownDockerIP + ":8554/test/stream",
|
||||
track, err := gortsplib.NewTrackH264(68, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = gortsplib.DialPublish(
|
||||
"rtsp://"+ownDockerIP+":8554/test/stream",
|
||||
gortsplib.Tracks{track},
|
||||
)
|
||||
require.Equal(t, "wrong status code: 401 (Unauthorized)", err.Error())
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer cnt1.close()
|
||||
require.NotEqual(t, 0, cnt1.wait())
|
||||
}
|
||||
|
||||
func TestClientRTSPAutomaticProtocol(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user