forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapability-discovery.js
More file actions
84 lines (78 loc) · 2.44 KB
/
Copy pathcapability-discovery.js
File metadata and controls
84 lines (78 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const Solid = require('../')
const parallel = require('run-parallel')
const path = require('path')
const supertest = require('supertest')
const expect = require('chai').expect
// In this test we always assume that we are Alice
describe('API', () => {
let aliceServer
let alice
const alicePod = Solid.createServer({
root: path.join(__dirname, '/resources/accounts-scenario/alice'),
sslKey: path.join(__dirname, '/keys/key.pem'),
sslCert: path.join(__dirname, '/keys/cert.pem'),
auth: 'oidc',
dataBrowser: false,
fileBrowser: false,
webid: true
})
before(function (done) {
parallel([
(cb) => {
aliceServer = alicePod.listen(5000, cb)
alice = supertest('https://localhost:5000')
}
], done)
})
after(function () {
if (aliceServer) aliceServer.close()
})
describe('Capability Discovery', function () {
describe('GET Service Capability document', function () {
it('should exist', function (done) {
alice.get('/.well-known/solid')
.expect(200, done)
})
it('should be a json file by default', function (done) {
alice.get('/.well-known/solid')
.expect('content-type', /application\/json/)
.expect(200, done)
})
it('includes a root element', function (done) {
alice.get('/.well-known/solid')
.end(function (err, req) {
expect(req.body.root).to.exist
return done(err)
})
})
it('includes an apps config section', function (done) {
const config = {
apps: {
'signin': '/signin/',
'signup': '/signup/'
}
}
const solid = Solid(config)
let server = supertest(solid)
server.get('/.well-known/solid')
.end(function (err, req) {
expect(req.body.apps).to.exist
return done(err)
})
})
})
describe('OPTIONS API', function () {
it('should set the service Link header', function (done) {
alice.options('/')
.expect('Link', /<.*\.well-known\/solid>; rel="service"/)
.expect(204, done)
})
it('should still have previous link headers', function (done) {
alice.options('/')
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#BasicContainer>; rel="type"/)
.expect('Link', /<http:\/\/www.w3.org\/ns\/ldp#Container>; rel="type"/)
.expect(204, done)
})
})
})
})