aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-01 17:26:51 +0200
committerChocobozzz <me@florianbigard.com>2018-10-01 17:29:11 +0200
commitc2ad546df93717833cba15aa7283863c80c07a66 (patch)
tree89599de2962f2a10e8710e685324f3a21ea26560
parentc5d04b4f3543bd1e5b07773b191f58c520edf205 (diff)
downloadPeerTube-c2ad546df93717833cba15aa7283863c80c07a66.tar.gz
PeerTube-c2ad546df93717833cba15aa7283863c80c07a66.tar.zst
PeerTube-c2ad546df93717833cba15aa7283863c80c07a66.zip
Add tests regarding well known/static text endpoints
-rwxr-xr-xscripts/travis.sh2
-rw-r--r--server/tests/misc-endpoints.ts99
2 files changed, 100 insertions, 1 deletions
diff --git a/scripts/travis.sh b/scripts/travis.sh
index f9fd19512..5d195f902 100755
--- a/scripts/travis.sh
+++ b/scripts/travis.sh
@@ -12,7 +12,7 @@ killall -q peertube || true
12if [ "$1" = "misc" ]; then 12if [ "$1" = "misc" ]; then
13 npm run build -- --light-fr 13 npm run build -- --light-fr
14 mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/client.ts server/tests/activitypub.ts \ 14 mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/client.ts server/tests/activitypub.ts \
15 server/tests/feeds/index.ts 15 server/tests/feeds/index.ts server/tests/misc-endpoints.ts
16elif [ "$1" = "api" ]; then 16elif [ "$1" = "api" ]; then
17 npm run build:server 17 npm run build:server
18 mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index.ts 18 mocha --timeout 5000 --exit --require ts-node/register/type-check --bail server/tests/api/index.ts
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
new file mode 100644
index 000000000..8fab20971
--- /dev/null
+++ b/server/tests/misc-endpoints.ts
@@ -0,0 +1,99 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5import { flushTests, killallServers, makeGetRequest, runServer, ServerInfo } from './utils'
6
7const expect = chai.expect
8
9describe('Test misc endpoints', function () {
10 let server: ServerInfo
11
12 before(async function () {
13 this.timeout(120000)
14
15 await flushTests()
16
17 server = await runServer(1)
18 })
19
20 describe('Test a well known endpoints', function () {
21
22 it('Should get security.txt', async function () {
23 const res = await makeGetRequest({
24 url: server.url,
25 path: '/.well-known/security.txt',
26 statusCodeExpected: 200
27 })
28
29 expect(res.text).to.contain('security issue')
30 })
31
32 it('Should get nodeinfo', async function () {
33 const res = await makeGetRequest({
34 url: server.url,
35 path: '/.well-known/nodeinfo',
36 statusCodeExpected: 200
37 })
38
39 expect(res.body.links).to.be.an('array')
40 expect(res.body.links).to.have.lengthOf(1)
41 expect(res.body.links[0].rel).to.equal('http://nodeinfo.diaspora.software/ns/schema/2.0')
42 })
43
44 it('Should get dnt policy text', async function () {
45 const res = await makeGetRequest({
46 url: server.url,
47 path: '/.well-known/dnt-policy.txt',
48 statusCodeExpected: 200
49 })
50
51 expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt')
52 })
53
54 it('Should get dnt policy', async function () {
55 const res = await makeGetRequest({
56 url: server.url,
57 path: '/.well-known/dnt',
58 statusCodeExpected: 200
59 })
60
61 expect(res.body.tracking).to.equal('N')
62 })
63 })
64
65 describe('Test classic static endpoints', function () {
66
67 it('Should get robots.txt', async function () {
68 const res = await makeGetRequest({
69 url: server.url,
70 path: '/robots.txt',
71 statusCodeExpected: 200
72 })
73
74 expect(res.text).to.contain('User-agent')
75 })
76
77 it('Should get security.txt', async function () {
78 await makeGetRequest({
79 url: server.url,
80 path: '/security.txt',
81 statusCodeExpected: 301
82 })
83 })
84
85 it('Should get nodeinfo', async function () {
86 const res = await makeGetRequest({
87 url: server.url,
88 path: '/nodeinfo/2.0.json',
89 statusCodeExpected: 200
90 })
91
92 expect(res.body.software.name).to.equal('peertube')
93 })
94 })
95
96 after(async function () {
97 killallServers([ server ])
98 })
99})