aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-11-14 15:01:28 +0100
committerChocobozzz <me@florianbigard.com>2018-11-14 16:32:27 +0100
commit5c6d985faeef1d6793d3f44ca6374f1a9b722806 (patch)
tree567e31a84e721bf762189582f92ac2ec5c402bcc /server/tests
parentdf66d81583e07ce049daeeef1edc6a87b57b3684 (diff)
downloadPeerTube-5c6d985faeef1d6793d3f44ca6374f1a9b722806.tar.gz
PeerTube-5c6d985faeef1d6793d3f44ca6374f1a9b722806.tar.zst
PeerTube-5c6d985faeef1d6793d3f44ca6374f1a9b722806.zip
Check activities host
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/activitypub/security.ts16
-rw-r--r--server/tests/utils/requests/activitypub.ts6
2 files changed, 11 insertions, 11 deletions
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index c5428abbb..e7899bb14 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4 4
5import { flushAndRunMultipleServers, flushTests, killallServers, makeAPRequest, makeFollowRequest, ServerInfo } from '../../utils' 5import { flushAndRunMultipleServers, flushTests, killallServers, makePOSTAPRequest, makeFollowRequest, ServerInfo } from '../../utils'
6import { HTTP_SIGNATURE } from '../../../initializers' 6import { HTTP_SIGNATURE } from '../../../initializers'
7import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' 7import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
8import * as chai from 'chai' 8import * as chai from 'chai'
@@ -63,7 +63,7 @@ describe('Test ActivityPub security', function () {
63 Digest: buildDigest({ hello: 'coucou' }) 63 Digest: buildDigest({ hello: 'coucou' })
64 } 64 }
65 65
66 const { response } = await makeAPRequest(url, body, baseHttpSignature, headers) 66 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
67 67
68 expect(response.statusCode).to.equal(403) 68 expect(response.statusCode).to.equal(403)
69 }) 69 })
@@ -73,7 +73,7 @@ describe('Test ActivityPub security', function () {
73 const headers = buildGlobalHeaders(body) 73 const headers = buildGlobalHeaders(body)
74 headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT' 74 headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'
75 75
76 const { response } = await makeAPRequest(url, body, baseHttpSignature, headers) 76 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
77 77
78 expect(response.statusCode).to.equal(403) 78 expect(response.statusCode).to.equal(403)
79 }) 79 })
@@ -85,7 +85,7 @@ describe('Test ActivityPub security', function () {
85 const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) 85 const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))
86 const headers = buildGlobalHeaders(body) 86 const headers = buildGlobalHeaders(body)
87 87
88 const { response } = await makeAPRequest(url, body, baseHttpSignature, headers) 88 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
89 89
90 expect(response.statusCode).to.equal(403) 90 expect(response.statusCode).to.equal(403)
91 }) 91 })
@@ -97,7 +97,7 @@ describe('Test ActivityPub security', function () {
97 const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) 97 const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))
98 const headers = buildGlobalHeaders(body) 98 const headers = buildGlobalHeaders(body)
99 99
100 const { response } = await makeAPRequest(url, body, baseHttpSignature, headers) 100 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)
101 101
102 expect(response.statusCode).to.equal(204) 102 expect(response.statusCode).to.equal(204)
103 }) 103 })
@@ -126,7 +126,7 @@ describe('Test ActivityPub security', function () {
126 126
127 const headers = buildGlobalHeaders(signedBody) 127 const headers = buildGlobalHeaders(signedBody)
128 128
129 const { response } = await makeAPRequest(url, signedBody, baseHttpSignature, headers) 129 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)
130 130
131 expect(response.statusCode).to.equal(403) 131 expect(response.statusCode).to.equal(403)
132 }) 132 })
@@ -147,7 +147,7 @@ describe('Test ActivityPub security', function () {
147 147
148 const headers = buildGlobalHeaders(signedBody) 148 const headers = buildGlobalHeaders(signedBody)
149 149
150 const { response } = await makeAPRequest(url, signedBody, baseHttpSignature, headers) 150 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)
151 151
152 expect(response.statusCode).to.equal(403) 152 expect(response.statusCode).to.equal(403)
153 }) 153 })
@@ -163,7 +163,7 @@ describe('Test ActivityPub security', function () {
163 163
164 const headers = buildGlobalHeaders(signedBody) 164 const headers = buildGlobalHeaders(signedBody)
165 165
166 const { response } = await makeAPRequest(url, signedBody, baseHttpSignature, headers) 166 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)
167 167
168 expect(response.statusCode).to.equal(204) 168 expect(response.statusCode).to.equal(204)
169 }) 169 })
diff --git a/server/tests/utils/requests/activitypub.ts b/server/tests/utils/requests/activitypub.ts
index e3e08ce67..96fee60a8 100644
--- a/server/tests/utils/requests/activitypub.ts
+++ b/server/tests/utils/requests/activitypub.ts
@@ -3,7 +3,7 @@ import { HTTP_SIGNATURE } from '../../../initializers'
3import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' 3import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
4import { activityPubContextify } from '../../../helpers/activitypub' 4import { activityPubContextify } from '../../../helpers/activitypub'
5 5
6function makeAPRequest (url: string, body: any, httpSignature: any, headers: any) { 6function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {
7 const options = { 7 const options = {
8 method: 'POST', 8 method: 'POST',
9 uri: url, 9 uri: url,
@@ -34,10 +34,10 @@ async function makeFollowRequest (to: { url: string }, by: { url: string, privat
34 } 34 }
35 const headers = buildGlobalHeaders(body) 35 const headers = buildGlobalHeaders(body)
36 36
37 return makeAPRequest(to.url, body, httpSignature, headers) 37 return makePOSTAPRequest(to.url, body, httpSignature, headers)
38} 38}
39 39
40export { 40export {
41 makeAPRequest, 41 makePOSTAPRequest,
42 makeFollowRequest 42 makeFollowRequest
43} 43}