Skip to content

Commit

Permalink
feat: Set MS-Author-Via header.
Browse files Browse the repository at this point in the history
Closes #539
  • Loading branch information
RubenVerborgh authored and joachimvh committed Jan 26, 2021
1 parent fe3957f commit 8c2f737
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions config/presets/ldp/response-writer.json
Expand Up @@ -5,6 +5,15 @@
"@id": "urn:solid-server:default:MetadataSerializer",
"@type": "SequenceHandler",
"SequenceHandler:_handlers": [
{
"@type": "ConstantMetadataWriter",
"ConstantMetadataWriter:_headers": [
{
"ConstantMetadataWriter:_headers_key": "MS-Author-Via",
"ConstantMetadataWriter:_headers_value": "SPARQL"
}
]
},
{
"@type": "MappedMetadataWriter",
"MappedMetadataWriter:_headerMap": [
Expand Down
1 change: 1 addition & 0 deletions config/presets/middleware.json
Expand Up @@ -19,6 +19,7 @@
"CorsHandler:_options_credentials": true,
"CorsHandler:_options_exposedHeaders": [
"Location",
"MS-Author-Via",
"Updates-Via"
]
},
Expand Down
1 change: 1 addition & 0 deletions test/integration/LdpHandlerWithoutAuth.test.ts
Expand Up @@ -81,6 +81,7 @@ describe.each(stores)('An LDP handler without auth using %s', (name, { storeUrn,
expect(response.statusCode).toBe(200);
expect(response._getBuffer().toString()).toContain('TESTFILE0');
expect(response.getHeaders().link).toBe(`<${LDP.Resource}>; rel="type"`);
expect(response.getHeaders()['ms-author-via']).toBe('SPARQL');

// DELETE
await resourceHelper.deleteResource(id);
Expand Down
12 changes: 12 additions & 0 deletions test/integration/Middleware.test.ts
Expand Up @@ -92,6 +92,18 @@ describe('An Express server with middleware', (): void => {
expect(exposed.split(/\s*,\s*/u)).toContain('Location');
});

it('exposes the MS-Author-Via header via CORS.', async(): Promise<void> => {
const res = await request(server).get('/').expect(200);
const exposed = res.header['access-control-expose-headers'];
expect(exposed.split(/\s*,\s*/u)).toContain('MS-Author-Via');
});

it('exposes the Updates-Via header via CORS.', async(): Promise<void> => {
const res = await request(server).get('/').expect(200);
const exposed = res.header['access-control-expose-headers'];
expect(exposed.split(/\s*,\s*/u)).toContain('Updates-Via');
});

it('sends incoming requests to the handler.', async(): Promise<void> => {
const response = request(server).get('/').set('Host', 'test.com');
expect(response).toBeDefined();
Expand Down

0 comments on commit 8c2f737

Please sign in to comment.