forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment-pointer-test.js
More file actions
149 lines (132 loc) · 3.97 KB
/
payment-pointer-test.js
File metadata and controls
149 lines (132 loc) · 3.97 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* eslint-disable no-unused-expressions */
const Solid = require('../../index')
const path = require('path')
const { cleanDir } = require('../utils')
const supertest = require('supertest')
const expect = require('chai').expect
describe('API', () => {
const configPath = path.join(__dirname, '../resources/config')
const serverConfig = {
sslKey: path.join(__dirname, '../keys/key.pem'),
sslCert: path.join(__dirname, '../keys/cert.pem'),
auth: 'oidc',
dataBrowser: false,
webid: true,
multiuser: false,
configPath
}
function startServer (pod, port) {
return new Promise((resolve) => {
pod.listen(port, () => { resolve() })
})
}
describe('Payment Pointer Alice', () => {
let alice
const aliceServerUri = 'https://localhost:5000'
const aliceDbPath = path.join(__dirname,
'../resources/accounts-scenario/alice/db')
const aliceRootPath = path.join(__dirname, '../resources/accounts-scenario/alice')
const alicePod = Solid.createServer(
Object.assign({
root: aliceRootPath,
serverUri: aliceServerUri,
dbPath: aliceDbPath
}, serverConfig)
)
before(() => {
return Promise.all([
startServer(alicePod, 5000)
]).then(() => {
alice = supertest(aliceServerUri)
})
})
after(() => {
alicePod.close()
cleanDir(aliceRootPath)
})
describe('GET Payment Pointer document', () => {
it('should show instructions to add a triple', (done) => {
alice.get('/.well-known/pay')
.expect(200)
.expect('content-type', /application\/json/)
.end(function (err, req) {
if (err) {
done(err)
} else {
expect(req.body).deep.equal({
fail: 'Add triple',
subject: '<https://localhost:5000/profile/card#me>',
predicate: '<http://paymentpointers.org/ns#PaymentPointer>',
object: '$alice.example'
})
done()
}
})
})
})
})
describe('Payment Pointer Bob', () => {
let bob
const bobServerUri = 'https://localhost:5001'
const bobDbPath = path.join(__dirname,
'../resources/accounts-scenario/bob/db')
const bobRootPath = path.join(__dirname, '../resources/accounts-scenario/bob')
const bobPod = Solid.createServer(
Object.assign({
root: bobRootPath,
serverUri: bobServerUri,
dbPath: bobDbPath
}, serverConfig)
)
before(() => {
return Promise.all([
startServer(bobPod, 5001)
]).then(() => {
bob = supertest(bobServerUri)
})
})
after(() => {
bobPod.close()
cleanDir(bobRootPath)
})
describe('GET Payment Pointer document', () => {
it.skip('should redirect to example.com', (done) => {
bob.get('/.well-known/pay')
.expect('location', 'https://bob.com/.well-known/pay')
.expect(302, done)
})
})
})
describe('Payment Pointer Charlie', () => {
let charlie
const charlieServerUri = 'https://localhost:5002'
const charlieDbPath = path.join(__dirname,
'../resources/accounts-scenario/charlie/db')
const charlieRootPath = path.join(__dirname, '../resources/accounts-scenario/charlie')
const charliePod = Solid.createServer(
Object.assign({
root: charlieRootPath,
serverUri: charlieServerUri,
dbPath: charlieDbPath
}, serverConfig)
)
before(() => {
return Promise.all([
startServer(charliePod, 5002)
]).then(() => {
charlie = supertest(charlieServerUri)
})
})
after(() => {
charliePod.close()
cleanDir(charlieRootPath)
})
describe('GET Payment Pointer document', () => {
it('should redirect to example.com/charlie', (done) => {
charlie.get('/.well-known/pay')
.expect('location', 'https://service.com/charlie')
.expect(302, done)
})
})
})
})