diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/misc-endpoints.ts | 99 |
1 files changed, 99 insertions, 0 deletions
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 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | import { flushTests, killallServers, makeGetRequest, runServer, ServerInfo } from './utils' | ||
6 | |||
7 | const expect = chai.expect | ||
8 | |||
9 | describe('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 | }) | ||