@@ -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 } )
@@ -329,6 +335,11 @@ describe('HTTP APIs', function () {
329335 server . get ( '/invalidfile.foo' )
330336 . expect ( 404 , done )
331337 } )
338+ it ( 'should return 404 for non-existent container' , function ( done ) { // alain
339+ server . get ( '/inexistant/' )
340+ . expect ( 'Accept-Put' , 'text/turtle' )
341+ . expect ( 404 , done )
342+ } )
332343 it ( 'should return basic container link for directories' , function ( done ) {
333344 server . get ( '/' )
334345 . 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 / )
@@ -411,13 +422,39 @@ describe('HTTP APIs', function () {
411422 . expect ( 'content-type' , / t e x t \/ t u r t l e / )
412423 . end ( done )
413424 } )
414- it ( 'should still redirect to the right container URI if missing / and HTML is requested' ,
415- function ( done ) {
416- server . get ( '/sampleContainer' )
417- . set ( 'accept' , 'text/html' )
418- . expect ( 'location' , / \/ s a m p l e C o n t a i n e r \/ / )
419- . expect ( 301 , done )
425+ it ( 'should still redirect to the right container URI if missing / and HTML is requested' , function ( done ) {
426+ server . get ( '/sampleContainer' )
427+ . set ( 'accept' , 'text/html' )
428+ . expect ( 'location' , / \/ s a m p l e C o n t a i n e r \/ / )
429+ . expect ( 301 , done )
430+ } )
431+
432+ describe ( 'Accept-* headers' , function ( ) {
433+ it ( 'should return 404 for non-existent resource' , function ( done ) {
434+ server . get ( '/invalidfile.foo' )
435+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
436+ . expect ( 'Accept-Post' , '*/*' )
437+ . expect ( 'Accept-put' , '*/*' )
438+ . expect ( 404 , done )
439+ } )
440+ it ( 'Accept-Put=text/turtle for non-existent container' , function ( done ) {
441+ server . get ( '/inexistant/' )
442+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
443+ . expect ( 'Accept-Post' , '*/*' )
444+ . expect ( 'Accept-Put' , 'text/turtle' )
445+ . expect ( 404 , done )
420446 } )
447+ it ( 'Accept-Put header do not exist for existing container' , ( done ) => {
448+ server . get ( '/sampleContainer/' )
449+ . expect ( 200 )
450+ . expect ( 'Accept-Patch' , 'text/n3, application/sparql-update, application/sparql-update-single-match' )
451+ . expect ( 'Accept-Post' , '*/*' )
452+ . expect ( ( res ) => {
453+ if ( res . headers [ 'Accept-Put' ] ) return done ( new Error ( 'Accept-Put header should not exist' ) )
454+ } )
455+ . end ( done )
456+ } )
457+ } )
421458 } )
422459
423460 describe ( 'HEAD API' , function ( ) {
0 commit comments