Browse Source

rewrite TestAuth and TestPath

pull/235/head
aler9 5 years ago
parent
commit
4920a1d6a1
  1. 69
      main_test.go

69
main_test.go

@ -348,13 +348,25 @@ func TestTCPOnly(t *testing.T) { @@ -348,13 +348,25 @@ func TestTCPOnly(t *testing.T) {
require.Equal(t, 0, cnt2.wait())
}
func TestPathWithSlash(t *testing.T) {
func TestPath(t *testing.T) {
for _, ca := range []struct {
name string
path string
}{
{
"with slash",
"test/stream",
},
{
"with query",
"test?param1=val&param2=val",
},
} {
t.Run(ca.name, func(t *testing.T) {
p, ok := testProgram("")
require.Equal(t, true, ok)
defer p.close()
time.Sleep(1 * time.Second)
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
@ -362,54 +374,23 @@ func TestPathWithSlash(t *testing.T) { @@ -362,54 +374,23 @@ func TestPathWithSlash(t *testing.T) {
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
"rtsp://" + ownDockerIP + ":8554/test/stream",
"rtsp://" + ownDockerIP + ":8554/" + ca.path,
})
require.NoError(t, err)
defer cnt1.close()
cnt2, err := newContainer("ffmpeg", "dest", []string{
"-rtsp_transport", "udp",
"-i", "rtsp://" + ownDockerIP + ":8554/test/stream",
"-i", "rtsp://" + ownDockerIP + ":8554/" + ca.path,
"-vframes", "1",
"-f", "image2",
"-y", "/dev/null",
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
}
func TestPathWithQuery(t *testing.T) {
p, ok := testProgram("")
require.Equal(t, true, ok)
defer p.close()
time.Sleep(1 * time.Second)
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
"-i", "emptyvideo.ts",
"-c", "copy",
"-f", "rtsp",
"-rtsp_transport", "udp",
"rtsp://" + ownDockerIP + ":8554/test?param1=val&param2=val",
})
require.NoError(t, err)
defer cnt1.close()
cnt2, err := newContainer("ffmpeg", "dest", []string{
"-rtsp_transport", "udp",
"-i", "rtsp://" + ownDockerIP + ":8554/test?param3=otherval",
"-vframes", "1",
"-f", "image2",
"-y", "/dev/null",
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
}
}
func TestAuth(t *testing.T) {
@ -422,8 +403,6 @@ func TestAuth(t *testing.T) { @@ -422,8 +403,6 @@ func TestAuth(t *testing.T) {
require.Equal(t, true, ok)
defer p.close()
time.Sleep(1 * time.Second)
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
@ -447,7 +426,6 @@ func TestAuth(t *testing.T) { @@ -447,7 +426,6 @@ func TestAuth(t *testing.T) {
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
})
@ -464,8 +442,6 @@ func TestAuth(t *testing.T) { @@ -464,8 +442,6 @@ func TestAuth(t *testing.T) {
require.Equal(t, true, ok)
defer p.close()
time.Sleep(1 * time.Second)
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
@ -490,7 +466,6 @@ func TestAuth(t *testing.T) { @@ -490,7 +466,6 @@ func TestAuth(t *testing.T) {
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
} else {
@ -499,14 +474,12 @@ func TestAuth(t *testing.T) { @@ -499,14 +474,12 @@ func TestAuth(t *testing.T) {
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
}
})
}
}
func TestAuthHashed(t *testing.T) {
t.Run("hashed", func(t *testing.T) {
p, ok := testProgram("paths:\n" +
" all:\n" +
" readUser: sha256:rl3rgi4NcZkpAEcacZnQ2VuOfJ0FxAqCRaKB/SwdZoQ=\n" +
@ -514,8 +487,6 @@ func TestAuthHashed(t *testing.T) { @@ -514,8 +487,6 @@ func TestAuthHashed(t *testing.T) {
require.Equal(t, true, ok)
defer p.close()
time.Sleep(1 * time.Second)
cnt1, err := newContainer("ffmpeg", "source", []string{
"-re",
"-stream_loop", "-1",
@ -537,8 +508,8 @@ func TestAuthHashed(t *testing.T) { @@ -537,8 +508,8 @@ func TestAuthHashed(t *testing.T) {
})
require.NoError(t, err)
defer cnt2.close()
require.Equal(t, 0, cnt2.wait())
})
}
func TestAuthFail(t *testing.T) {

Loading…
Cancel
Save