|
|
|
@ -283,22 +283,22 @@ func TestClientRTSPAuthFail(t *testing.T) { |
|
|
|
pass string |
|
|
|
pass string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
"publish_wronguser", |
|
|
|
"wronguser", |
|
|
|
"test1user", |
|
|
|
"test1user", |
|
|
|
"testpass", |
|
|
|
"testpass", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
"publish_wrongpass", |
|
|
|
"wrongpass", |
|
|
|
"testuser", |
|
|
|
"testuser", |
|
|
|
"test1pass", |
|
|
|
"test1pass", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
"publish_wrongboth", |
|
|
|
"wrongboth", |
|
|
|
"test1user", |
|
|
|
"test1user", |
|
|
|
"test1pass", |
|
|
|
"test1pass", |
|
|
|
}, |
|
|
|
}, |
|
|
|
} { |
|
|
|
} { |
|
|
|
t.Run(ca.name, func(t *testing.T) { |
|
|
|
t.Run("publish_"+ca.name, func(t *testing.T) { |
|
|
|
p, ok := testProgram("rtmpDisable: yes\n" + |
|
|
|
p, ok := testProgram("rtmpDisable: yes\n" + |
|
|
|
"hlsDisable: yes\n" + |
|
|
|
"hlsDisable: yes\n" + |
|
|
|
"paths:\n" + |
|
|
|
"paths:\n" + |
|
|
|
@ -308,30 +308,14 @@ func TestClientRTSPAuthFail(t *testing.T) { |
|
|
|
require.Equal(t, true, ok) |
|
|
|
require.Equal(t, true, ok) |
|
|
|
defer p.close() |
|
|
|
defer p.close() |
|
|
|
|
|
|
|
|
|
|
|
cnt1, err := newContainer("ffmpeg", "source", []string{ |
|
|
|
track, err := gortsplib.NewTrackH264(68, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}) |
|
|
|
"-re", |
|
|
|
|
|
|
|
"-stream_loop", "-1", |
|
|
|
|
|
|
|
"-i", "emptyvideo.mkv", |
|
|
|
|
|
|
|
"-c", "copy", |
|
|
|
|
|
|
|
"-f", "rtsp", |
|
|
|
|
|
|
|
"-rtsp_transport", "udp", |
|
|
|
|
|
|
|
"rtsp://" + ca.user + ":" + ca.pass + "@" + ownDockerIP + ":8554/test/stream", |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
require.NoError(t, err) |
|
|
|
require.NoError(t, err) |
|
|
|
defer cnt1.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cnt2, err := newContainer("ffmpeg", "dest", []string{ |
|
|
|
_, err = gortsplib.DialPublish( |
|
|
|
"-rtsp_transport", "udp", |
|
|
|
"rtsp://"+ca.user+":"+ca.pass+"@"+ownDockerIP+":8554/test/stream", |
|
|
|
"-i", "rtsp://" + ownDockerIP + ":8554/test/stream", |
|
|
|
gortsplib.Tracks{track}, |
|
|
|
"-vframes", "1", |
|
|
|
) |
|
|
|
"-f", "image2", |
|
|
|
require.Equal(t, "wrong status code: 401 (Unauthorized)", err.Error()) |
|
|
|
"-y", "/dev/null", |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
defer cnt2.close() |
|
|
|
|
|
|
|
require.Equal(t, 1, cnt2.wait()) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -341,22 +325,22 @@ func TestClientRTSPAuthFail(t *testing.T) { |
|
|
|
pass string |
|
|
|
pass string |
|
|
|
}{ |
|
|
|
}{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
"read_wronguser", |
|
|
|
"wronguser", |
|
|
|
"test1user", |
|
|
|
"test1user", |
|
|
|
"testpass", |
|
|
|
"testpass", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
"read_wrongpass", |
|
|
|
"wrongpass", |
|
|
|
"testuser", |
|
|
|
"testuser", |
|
|
|
"test1pass", |
|
|
|
"test1pass", |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
"read_wrongboth", |
|
|
|
"wrongboth", |
|
|
|
"test1user", |
|
|
|
"test1user", |
|
|
|
"test1pass", |
|
|
|
"test1pass", |
|
|
|
}, |
|
|
|
}, |
|
|
|
} { |
|
|
|
} { |
|
|
|
t.Run(ca.name, func(t *testing.T) { |
|
|
|
t.Run("read_"+ca.name, func(t *testing.T) { |
|
|
|
p, ok := testProgram("rtmpDisable: yes\n" + |
|
|
|
p, ok := testProgram("rtmpDisable: yes\n" + |
|
|
|
"hlsDisable: yes\n" + |
|
|
|
"hlsDisable: yes\n" + |
|
|
|
"paths:\n" + |
|
|
|
"paths:\n" + |
|
|
|
@ -366,35 +350,14 @@ func TestClientRTSPAuthFail(t *testing.T) { |
|
|
|
require.Equal(t, true, ok) |
|
|
|
require.Equal(t, true, ok) |
|
|
|
defer p.close() |
|
|
|
defer p.close() |
|
|
|
|
|
|
|
|
|
|
|
cnt1, err := newContainer("ffmpeg", "source", []string{ |
|
|
|
_, err := gortsplib.DialRead( |
|
|
|
"-re", |
|
|
|
"rtsp://" + ca.user + ":" + ca.pass + "@" + ownDockerIP + ":8554/test/stream", |
|
|
|
"-stream_loop", "-1", |
|
|
|
) |
|
|
|
"-i", "emptyvideo.mkv", |
|
|
|
require.Equal(t, "wrong status code: 401 (Unauthorized)", err.Error()) |
|
|
|
"-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()) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func TestClientRTSPAuthIpFail(t *testing.T) { |
|
|
|
t.Run("ip", func(t *testing.T) { |
|
|
|
p, ok := testProgram("rtmpDisable: yes\n" + |
|
|
|
p, ok := testProgram("rtmpDisable: yes\n" + |
|
|
|
"hlsDisable: yes\n" + |
|
|
|
"hlsDisable: yes\n" + |
|
|
|
"paths:\n" + |
|
|
|
"paths:\n" + |
|
|
|
@ -403,18 +366,15 @@ func TestClientRTSPAuthIpFail(t *testing.T) { |
|
|
|
require.Equal(t, true, ok) |
|
|
|
require.Equal(t, true, ok) |
|
|
|
defer p.close() |
|
|
|
defer p.close() |
|
|
|
|
|
|
|
|
|
|
|
cnt1, err := newContainer("ffmpeg", "source", []string{ |
|
|
|
track, err := gortsplib.NewTrackH264(68, []byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}) |
|
|
|
"-re", |
|
|
|
require.NoError(t, err) |
|
|
|
"-stream_loop", "-1", |
|
|
|
|
|
|
|
"-i", "emptyvideo.mkv", |
|
|
|
_, err = gortsplib.DialPublish( |
|
|
|
"-c", "copy", |
|
|
|
|
|
|
|
"-f", "rtsp", |
|
|
|
|
|
|
|
"-rtsp_transport", "udp", |
|
|
|
|
|
|
|
"rtsp://"+ownDockerIP+":8554/test/stream", |
|
|
|
"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) { |
|
|
|
func TestClientRTSPAutomaticProtocol(t *testing.T) { |
|
|
|
|