diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-05 11:36:03 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-05 11:38:17 +0100 |
commit | df1db951c512a58110171d046ef367789df02733 (patch) | |
tree | a8894b4a4864d9e378923f011b4ca9d206e2ee0b /server/tests | |
parent | 8dd754c76735417305c4b68e2ada6f623e9d7650 (diff) | |
download | PeerTube-df1db951c512a58110171d046ef367789df02733.tar.gz PeerTube-df1db951c512a58110171d046ef367789df02733.tar.zst PeerTube-df1db951c512a58110171d046ef367789df02733.zip |
Support RTMPS
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/live/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/live/live-rtmps.ts | 146 | ||||
-rw-r--r-- | server/tests/fixtures/rtmps.cert | 21 | ||||
-rw-r--r-- | server/tests/fixtures/rtmps.key | 28 |
4 files changed, 196 insertions, 0 deletions
diff --git a/server/tests/api/live/index.ts b/server/tests/api/live/index.ts index e6bcef49f..105416b8d 100644 --- a/server/tests/api/live/index.ts +++ b/server/tests/api/live/index.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import './live-constraints' | 1 | import './live-constraints' |
2 | import './live-socket-messages' | 2 | import './live-socket-messages' |
3 | import './live-permanent' | 3 | import './live-permanent' |
4 | import './live-rtmps' | ||
4 | import './live-save-replay' | 5 | import './live-save-replay' |
5 | import './live-views' | 6 | import './live-views' |
6 | import './live' | 7 | import './live' |
diff --git a/server/tests/api/live/live-rtmps.ts b/server/tests/api/live/live-rtmps.ts new file mode 100644 index 000000000..378e6df3c --- /dev/null +++ b/server/tests/api/live/live-rtmps.ts | |||
@@ -0,0 +1,146 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | import { VideoPrivacy } from '@shared/models' | ||
6 | import { | ||
7 | buildAbsoluteFixturePath, | ||
8 | cleanupTests, | ||
9 | createSingleServer, | ||
10 | PeerTubeServer, | ||
11 | sendRTMPStream, | ||
12 | setAccessTokensToServers, | ||
13 | setDefaultVideoChannel, | ||
14 | stopFfmpeg, | ||
15 | testFfmpegStreamError, | ||
16 | waitUntilLivePublishedOnAllServers | ||
17 | } from '../../../../shared/extra-utils' | ||
18 | |||
19 | const expect = chai.expect | ||
20 | |||
21 | describe('Test live RTMPS', function () { | ||
22 | let server: PeerTubeServer | ||
23 | let rtmpUrl: string | ||
24 | let rtmpsUrl: string | ||
25 | |||
26 | async function createLiveWrapper () { | ||
27 | const liveAttributes = { | ||
28 | name: 'live', | ||
29 | channelId: server.store.channel.id, | ||
30 | privacy: VideoPrivacy.PUBLIC, | ||
31 | saveReplay: false | ||
32 | } | ||
33 | |||
34 | const { uuid } = await server.live.create({ fields: liveAttributes }) | ||
35 | |||
36 | const live = await server.live.get({ videoId: uuid }) | ||
37 | const video = await server.videos.get({ id: uuid }) | ||
38 | |||
39 | return Object.assign(video, live) | ||
40 | } | ||
41 | |||
42 | before(async function () { | ||
43 | this.timeout(120000) | ||
44 | |||
45 | server = await createSingleServer(1) | ||
46 | |||
47 | // Get the access tokens | ||
48 | await setAccessTokensToServers([ server ]) | ||
49 | await setDefaultVideoChannel([ server ]) | ||
50 | |||
51 | await server.config.updateCustomSubConfig({ | ||
52 | newConfig: { | ||
53 | live: { | ||
54 | enabled: true, | ||
55 | allowReplay: true, | ||
56 | transcoding: { | ||
57 | enabled: false | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | }) | ||
62 | |||
63 | rtmpUrl = 'rtmp://' + server.hostname + ':' + server.rtmpPort + '/live' | ||
64 | rtmpsUrl = 'rtmps://' + server.hostname + ':' + server.rtmpsPort + '/live' | ||
65 | }) | ||
66 | |||
67 | it('Should enable RTMPS endpoint only', async function () { | ||
68 | this.timeout(240000) | ||
69 | |||
70 | await server.kill() | ||
71 | await server.run({ | ||
72 | live: { | ||
73 | rtmp: { | ||
74 | enabled: false | ||
75 | }, | ||
76 | rtmps: { | ||
77 | enabled: true, | ||
78 | port: server.rtmpsPort, | ||
79 | key_file: buildAbsoluteFixturePath('rtmps.key'), | ||
80 | cert_file: buildAbsoluteFixturePath('rtmps.cert') | ||
81 | } | ||
82 | } | ||
83 | }) | ||
84 | |||
85 | { | ||
86 | const liveVideo = await createLiveWrapper() | ||
87 | |||
88 | expect(liveVideo.rtmpUrl).to.not.exist | ||
89 | expect(liveVideo.rtmpsUrl).to.equal(rtmpsUrl) | ||
90 | |||
91 | const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl, streamKey: liveVideo.streamKey }) | ||
92 | await testFfmpegStreamError(command, true) | ||
93 | } | ||
94 | |||
95 | { | ||
96 | const liveVideo = await createLiveWrapper() | ||
97 | |||
98 | const command = sendRTMPStream({ rtmpBaseUrl: rtmpsUrl, streamKey: liveVideo.streamKey }) | ||
99 | await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid) | ||
100 | await stopFfmpeg(command) | ||
101 | } | ||
102 | }) | ||
103 | |||
104 | it('Should enable both RTMP and RTMPS', async function () { | ||
105 | this.timeout(240000) | ||
106 | |||
107 | await server.kill() | ||
108 | await server.run({ | ||
109 | live: { | ||
110 | rtmp: { | ||
111 | enabled: true, | ||
112 | port: server.rtmpPort | ||
113 | }, | ||
114 | rtmps: { | ||
115 | enabled: true, | ||
116 | port: server.rtmpsPort, | ||
117 | key_file: buildAbsoluteFixturePath('rtmps.key'), | ||
118 | cert_file: buildAbsoluteFixturePath('rtmps.cert') | ||
119 | } | ||
120 | } | ||
121 | }) | ||
122 | |||
123 | { | ||
124 | const liveVideo = await createLiveWrapper() | ||
125 | |||
126 | expect(liveVideo.rtmpUrl).to.equal(rtmpUrl) | ||
127 | expect(liveVideo.rtmpsUrl).to.equal(rtmpsUrl) | ||
128 | |||
129 | const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl, streamKey: liveVideo.streamKey }) | ||
130 | await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid) | ||
131 | await stopFfmpeg(command) | ||
132 | } | ||
133 | |||
134 | { | ||
135 | const liveVideo = await createLiveWrapper() | ||
136 | |||
137 | const command = sendRTMPStream({ rtmpBaseUrl: rtmpsUrl, streamKey: liveVideo.streamKey }) | ||
138 | await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid) | ||
139 | await stopFfmpeg(command) | ||
140 | } | ||
141 | }) | ||
142 | |||
143 | after(async function () { | ||
144 | await cleanupTests([ server ]) | ||
145 | }) | ||
146 | }) | ||
diff --git a/server/tests/fixtures/rtmps.cert b/server/tests/fixtures/rtmps.cert new file mode 100644 index 000000000..3ef606c52 --- /dev/null +++ b/server/tests/fixtures/rtmps.cert | |||
@@ -0,0 +1,21 @@ | |||
1 | -----BEGIN CERTIFICATE----- | ||
2 | MIIDazCCAlOgAwIBAgIUKNycLAZUs2jFsWUW+zZhBkpLB2wwDQYJKoZIhvcNAQEL | ||
3 | BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM | ||
4 | GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMTExMDUxMDA4MzhaFw0yMTEy | ||
5 | MDUxMDA4MzhaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw | ||
6 | HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB | ||
7 | AQUAA4IBDwAwggEKAoIBAQDak20d81KG/9mVLU6Qw/uRniC935yf9Rlp8FVCDxUd | ||
8 | zLbfHjrnIOv8kqinUI0nuEQC4DnF7Rbafe88WDU33Q8ixU/R0czUGq1AEwIjyN30 | ||
9 | 5NjokCb26xWIly7RCfc/Ot6tjguHwKvcxqJMNC0Lit9Go9MDVnGFLkgHia68P72T | ||
10 | ZDVV44YpzwYDicwQs5C4nZ4yzAeclia07qfUY0VAEZlxJ/9zjwYHCT0AKaEPH35E | ||
11 | dUvjuvJ1OSHSN1S4acR+TPR3FwKQh3H/M/GWIqoiIOpdjFUBLs80QOM2aNrLmlyP | ||
12 | JtyFJLxCP7Ery9fGY/yzHeSxpgOKwZopD6uHZKi5yazNAgMBAAGjUzBRMB0GA1Ud | ||
13 | DgQWBBSSjhRQdWsybNQMLMhkwV+xiP2uoDAfBgNVHSMEGDAWgBSSjhRQdWsybNQM | ||
14 | LMhkwV+xiP2uoDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQC8 | ||
15 | rJu3J5sqVKNQaXOmLPd49RM7KG3Y1KPqbQi1lh+sW6aefZ9daeh3JDYGBZGPG/Fi | ||
16 | IMMP+LhGG0WqDm4ClK00wyNhBuNPEyzvuN/WMRX5djPxO1IZi+KogFwXsn853Ov9 | ||
17 | oV3nxArNNjDu2n92FiB7RTlXRXPIoRo2zEBcLvveGySn9XUazRzlqx6FAxYe2xsw | ||
18 | U3cZ6/wwU1YsEZa5bwIQk+gkFj3zDsTyEkn2ntcE2NlR+AhCHKa/yAxgPFycAVPX | ||
19 | 2o+wNnc6H4syP98mMGj9hEE3RSJyCPgGBlgi7Swl64G3YygFPJzfLX9YTuxwr/eI | ||
20 | oitEjF9ljtmdEnf0RdOj | ||
21 | -----END CERTIFICATE----- | ||
diff --git a/server/tests/fixtures/rtmps.key b/server/tests/fixtures/rtmps.key new file mode 100644 index 000000000..14a85e70a --- /dev/null +++ b/server/tests/fixtures/rtmps.key | |||
@@ -0,0 +1,28 @@ | |||
1 | -----BEGIN PRIVATE KEY----- | ||
2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDak20d81KG/9mV | ||
3 | LU6Qw/uRniC935yf9Rlp8FVCDxUdzLbfHjrnIOv8kqinUI0nuEQC4DnF7Rbafe88 | ||
4 | WDU33Q8ixU/R0czUGq1AEwIjyN305NjokCb26xWIly7RCfc/Ot6tjguHwKvcxqJM | ||
5 | NC0Lit9Go9MDVnGFLkgHia68P72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JFWT49RjYuuWIEauAuVYLMQkEKu+H4Cx7V0syw7Op | ||
21 | +4bEa9jr3op/1zE17PLcUaLQ4JZ6w0Ms4Z0XVyH72thlT4lBD+ehoXhohwKBgEtJ | ||
22 | LAPnY9Sv6Vuup/SAf/aIkSqDarMWa3x85pyO4Tl5zpuha3zgGjcdhYFI/ovIDbBp | ||
23 | JvUdBeuvup1PSwS5MP+8pSUxCfBRvkyD4v8VRRvLlgwWYSHvnm/oTmDLtCqDTtvV | ||
24 | +JRq9X3s7BHPYAjrTahGz8lvEGqWIoE/LHkLGEPVAoGAaF3VHuqDfmD9PJUAlsU1 | ||
25 | qxN7yfOd2ve0+66Ghus24DVqUFqwp5f2AxZXYUtSaNUp8fVbqIi+Yq3YDTU2KfId | ||
26 | 5QNA/AiKi4VUNLElsG5DZlbszsE5KNp9fWQoggdQ5LND7AGEKeFERHOVQ7C5sc/C | ||
27 | omIqK5/PsZmaf4OZLyecxJY= | ||
28 | -----END PRIVATE KEY----- | ||