-
Notifications
You must be signed in to change notification settings - Fork 306
Expand file tree
/
Copy pathauth-proxy-test.js
More file actions
139 lines (122 loc) · 3.82 KB
/
auth-proxy-test.js
File metadata and controls
139 lines (122 loc) · 3.82 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
const ldnode = require('../../index')
const path = require('path')
const nock = require('nock')
const request = require('supertest')
const { expect } = require('chai')
const rm = require('../utils').rm
const USER = 'https://ruben.verborgh.org/profile/#me'
describe('Auth Proxy', () => {
describe('A Solid server with the authProxy option', () => {
let server
before(() => {
// Set up test back-end server
nock('http://server-a.org').persist()
.get(/./).reply(200, function () { return this.req.headers })
.options(/./).reply(200)
.post(/./).reply(200)
// Set up Solid server
server = ldnode({
root: path.join(__dirname, '../resources/auth-proxy'),
configPath: path.join(__dirname, '../resources/config'),
authProxy: {
'/server/a': 'http://server-a.org'
},
forceUser: USER
})
})
after(() => {
// Release back-end server
nock.cleanAll()
// Remove created index files
rm('index.html')
rm('index.html.acl')
})
// Skipped tests due to not supported deep acl:accessTo #963
describe.skip('responding to /server/a', () => {
let response
before(() =>
request(server).get('/server/a/')
.then(res => { response = res })
)
it('sets the User header on the proxy request', () => {
expect(response.body).to.have.property('user', USER)
})
})
describe('responding to GET', () => {
describe.skip('for a path with read permissions', () => {
let response
before(() =>
request(server).get('/server/a/r')
.then(res => { response = res })
)
it('returns status code 200', () => {
expect(response.statusCode).to.equal(200)
})
})
describe('for a path without read permissions', () => {
let response
before(() =>
request(server).get('/server/a/wc')
.then(res => { response = res })
)
it('returns status code 403', () => {
expect(response.statusCode).to.equal(403)
})
})
})
describe('responding to OPTIONS', () => {
describe.skip('for a path with read permissions', () => {
let response
before(() =>
request(server).options('/server/a/r')
.then(res => { response = res })
)
it('returns status code 200', () => {
expect(response.statusCode).to.equal(200)
})
})
describe('for a path without read permissions', () => {
let response
before(() =>
request(server).options('/server/a/wc')
.then(res => { response = res })
)
it('returns status code 403', () => {
expect(response.statusCode).to.equal(403)
})
})
})
describe('responding to POST', () => {
describe.skip('for a path with read and write permissions', () => {
let response
before(() =>
request(server).post('/server/a/rw')
.then(res => { response = res })
)
it('returns status code 200', () => {
expect(response.statusCode).to.equal(200)
})
})
describe('for a path without read permissions', () => {
let response
before(() =>
request(server).post('/server/a/w')
.then(res => { response = res })
)
it('returns status code 403', () => {
expect(response.statusCode).to.equal(403)
})
})
describe('for a path without write permissions', () => {
let response
before(() =>
request(server).post('/server/a/r')
.then(res => { response = res })
)
it('returns status code 403', () => {
expect(response.statusCode).to.equal(403)
})
})
})
})
})