Skip to content

Commit

Permalink
Reject when manifests are not self-descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Oct 19, 2018
1 parent 1c17e83 commit bbb8ba3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ManifestLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class ManifestLoader {

// Import all sub-manifests
const manifest = objectLoader.resources[url];
if (!manifest) {
throw new Error(`Could not find a resource ${url} in the document at ${url}`);
}
const includeJobs: Promise<void>[] = [];
for (const includeList of manifest.properties.include) {
for (const include of includeList.list) {
Expand Down
16 changes: 16 additions & 0 deletions test/ManifestLoader-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ const streamifyString = require('streamify-string');
<> a mf:Manifest ;
rdfs:label "SPARQL 1.1 tests";
mf:include (<http://valid1>).
`);
break;
case 'http://invalidroot':
body = streamifyString(`
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
@prefix qt: <http://www.w3.org/2001/sw/DataAccess/tests/test-query#> .
<http://ex.org/abc> a mf:Manifest ;
rdfs:label "SPARQL 1.1 tests";
mf:include ("http://invalid1").
`);
break;
case 'http://invalidsub1':
Expand Down Expand Up @@ -81,6 +93,10 @@ describe('ManifestLoader', () => {
});
});

it('should error on non-self describing documents', () => {
return expect(loader.from('http://invalidroot')).rejects.toBeTruthy();
});

it('should return on valid submanifests', () => {
return expect(loader.from('http://validsub1')).resolves.toEqual({
comment: null,
Expand Down

0 comments on commit bbb8ba3

Please sign in to comment.