Skip to content

Commit 5746766

Browse files
committed
Expose WAC-Allow to browser clients.
1 parent d54f958 commit 5746766

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

lib/create-app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const corsSettings = cors({
2626
methods: [
2727
'OPTIONS', 'HEAD', 'GET', 'PATCH', 'POST', 'PUT', 'DELETE'
2828
],
29-
exposedHeaders: 'Authorization, User, Location, Link, Vary, Last-Modified, ETag, Accept-Patch, Accept-Post, Updates-Via, Allow, Content-Length, WWW-Authenticate',
29+
exposedHeaders: 'Authorization, User, Location, Link, Vary, Last-Modified, ETag, Accept-Patch, Accept-Post, Updates-Via, Allow, WAC-Allow, Content-Length, WWW-Authenticate',
3030
credentials: true,
3131
maxAge: 1728000,
3232
origin: true,

test/integration/header-test.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,26 @@ describe('Header handler', () => {
2323
describe('WAC-Allow', () => {
2424
describeHeaderTest('read/append for the public', {
2525
resource: '/public-ra',
26-
headers: { 'WAC-Allow': 'user="read append",public="read append"' }
26+
headers: {
27+
'WAC-Allow': 'user="read append",public="read append"',
28+
'Access-Control-Expose-Headers': /(^|,\s*)WAC-Allow(,|$)/
29+
}
2730
})
2831

2932
describeHeaderTest('read/write for the user, read for the public', {
3033
resource: '/user-rw-public-r',
31-
headers: { 'WAC-Allow': 'user="read write append",public="read"' }
34+
headers: {
35+
'WAC-Allow': 'user="read write append",public="read"',
36+
'Access-Control-Expose-Headers': /(^|,\s*)WAC-Allow(,|$)/
37+
}
3238
})
3339

3440
describeHeaderTest('read/write/append/control for the user, nothing for the public', {
3541
resource: '/user-rwac-public-0',
36-
headers: { 'WAC-Allow': 'user="read write append control",public=""' }
42+
headers: {
43+
'WAC-Allow': 'user="read write append control",public=""',
44+
'Access-Control-Expose-Headers': /(^|,\s*)WAC-Allow(,|$)/
45+
}
3746
})
3847
})
3948

@@ -44,9 +53,17 @@ describe('Header handler', () => {
4453

4554
for (const header in headers) {
4655
const value = headers[header]
47-
it(`has a ${header} header of ${value}`, () => {
48-
expect(response.headers).to.have.property(header.toLowerCase(), value)
49-
})
56+
const name = header.toLowerCase()
57+
if (value instanceof RegExp) {
58+
it(`has a ${header} header matching ${value}`, () => {
59+
expect(response.headers).to.have.property(name)
60+
expect(response.headers[name]).to.match(value)
61+
})
62+
} else {
63+
it(`has a ${header} header of ${value}`, () => {
64+
expect(response.headers).to.have.property(name, value)
65+
})
66+
}
5067
}
5168
})
5269
}

test/integration/http-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('HTTP APIs', function () {
106106
.expect('Access-Control-Allow-Origin', 'http://example.com')
107107
.expect('Access-Control-Allow-Credentials', 'true')
108108
.expect('Access-Control-Allow-Methods', 'OPTIONS,HEAD,GET,PATCH,POST,PUT,DELETE')
109-
.expect('Access-Control-Expose-Headers', 'Authorization, User, Location, Link, Vary, Last-Modified, ETag, Accept-Patch, Accept-Post, Updates-Via, Allow, Content-Length, WWW-Authenticate')
109+
.expect('Access-Control-Expose-Headers', 'Authorization, User, Location, Link, Vary, Last-Modified, ETag, Accept-Patch, Accept-Post, Updates-Via, Allow, WAC-Allow, Content-Length, WWW-Authenticate')
110110
.expect(204, done)
111111
})
112112

0 commit comments

Comments
 (0)