@@ -110,26 +110,32 @@ describe('HTTP APIs', function () {
110110 . expect ( 'Access-Control-Allow-Origin' , 'http://example.com' )
111111 . expect ( 'Access-Control-Allow-Credentials' , 'true' )
112112 . expect ( 'Access-Control-Allow-Methods' , 'OPTIONS,HEAD,GET,PATCH,POST,PUT,DELETE' )
113- . 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, MS-Author-Via, X-Powered-By' )
113+ . expect ( 'Access-Control-Expose-Headers' , 'Authorization, User, Location, Link, Vary, Last-Modified, ETag, Accept-Patch, Accept-Post, Accept-Put, Updates-Via, Allow, WAC-Allow, Content-Length, WWW-Authenticate, MS-Author-Via, X-Powered-By' )
114114 . expect ( 204 , done )
115115 } )
116116
117- describe ( 'Accept-Patch header ' , function ( ) {
117+ describe ( 'Accept-* headers ' , function ( ) {
118118 it ( 'should be present for resources' , function ( done ) {
119119 server . options ( '/sampleContainer/example1.ttl' )
120- . expect ( 'Accept-Patch' , 'application/sparql-update' )
120+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
121+ . expect ( 'Accept-Post' , '*/*' )
122+ . expect ( 'Accept-Put' , '*/*' )
121123 . expect ( 204 , done )
122124 } )
123125
124126 it ( 'should be present for containers' , function ( done ) {
125127 server . options ( '/sampleContainer/' )
126- . expect ( 'Accept-Patch' , 'application/sparql-update' )
128+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
129+ . expect ( 'Accept-Post' , '*/*' )
130+ . expect ( 'Accept-Put' , '*/*' )
127131 . expect ( 204 , done )
128132 } )
129133
130134 it ( 'should be present for non-rdf resources' , function ( done ) {
131135 server . options ( '/sampleContainer/solid.png' )
132- . expect ( 'Accept-Patch' , 'application/sparql-update' )
136+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
137+ . expect ( 'Accept-Post' , '*/*' )
138+ . expect ( 'Accept-Put' , '*/*' )
133139 . expect ( 204 , done )
134140 } )
135141 } )
@@ -314,6 +320,11 @@ describe('HTTP APIs', function () {
314320 server . get ( '/invalidfile.foo' )
315321 . expect ( 404 , done )
316322 } )
323+ it ( 'should return 404 for non-existent container' , function ( done ) { // alain
324+ server . get ( '/inexistant/' )
325+ . expect ( 'Accept-Put' , 'text/turtle' )
326+ . expect ( 404 , done )
327+ } )
317328 it ( 'should return basic container link for directories' , function ( done ) {
318329 server . get ( '/' )
319330 . expect ( 'Link' , / h t t p : \/ \/ w w w .w 3 .o r g \/ n s \/ l d p # B a s i c C o n t a i n e r / )
@@ -396,13 +407,39 @@ describe('HTTP APIs', function () {
396407 . expect ( 'content-type' , / t e x t \/ t u r t l e / )
397408 . end ( done )
398409 } )
399- it ( 'should still redirect to the right container URI if missing / and HTML is requested' ,
400- function ( done ) {
401- server . get ( '/sampleContainer' )
402- . set ( 'accept' , 'text/html' )
403- . expect ( 'location' , / \/ s a m p l e C o n t a i n e r \/ / )
404- . expect ( 301 , done )
410+ it ( 'should still redirect to the right container URI if missing / and HTML is requested' , function ( done ) {
411+ server . get ( '/sampleContainer' )
412+ . set ( 'accept' , 'text/html' )
413+ . expect ( 'location' , / \/ s a m p l e C o n t a i n e r \/ / )
414+ . expect ( 301 , done )
415+ } )
416+
417+ describe ( 'Accept-* headers' , function ( ) {
418+ it ( 'should return 404 for non-existent resource' , function ( done ) {
419+ server . get ( '/invalidfile.foo' )
420+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
421+ . expect ( 'Accept-Post' , '*/*' )
422+ . expect ( 'Accept-put' , '*/*' )
423+ . expect ( 404 , done )
424+ } )
425+ it ( 'Accept-Put=text/turtle for non-existent container' , function ( done ) {
426+ server . get ( '/inexistant/' )
427+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
428+ . expect ( 'Accept-Post' , '*/*' )
429+ . expect ( 'Accept-Put' , 'text/turtle' )
430+ . expect ( 404 , done )
405431 } )
432+ it ( 'Accept-Put header do not exist for existing container' , ( done ) => {
433+ server . get ( '/sampleContainer/' )
434+ . expect ( 200 )
435+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
436+ . expect ( 'Accept-Post' , '*/*' )
437+ . expect ( ( res ) => {
438+ if ( res . headers [ 'Accept-Put' ] ) return done ( new Error ( 'Accept-Put header should not exist' ) )
439+ } )
440+ . end ( done )
441+ } )
442+ } )
406443 } )
407444
408445 describe ( 'HEAD API' , function ( ) {
0 commit comments