@@ -110,26 +110,32 @@ describe('HTTP APIs', function () {
110
110
. expect ( 'Access-Control-Allow-Origin' , 'http://example.com' )
111
111
. expect ( 'Access-Control-Allow-Credentials' , 'true' )
112
112
. 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' )
114
114
. expect ( 204 , done )
115
115
} )
116
116
117
- describe ( 'Accept-Patch header ' , function ( ) {
117
+ describe ( 'Accept-* headers ' , function ( ) {
118
118
it ( 'should be present for resources' , function ( done ) {
119
119
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' , '*/*' )
121
123
. expect ( 204 , done )
122
124
} )
123
125
124
126
it ( 'should be present for containers' , function ( done ) {
125
127
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' , '*/*' )
127
131
. expect ( 204 , done )
128
132
} )
129
133
130
134
it ( 'should be present for non-rdf resources' , function ( done ) {
131
135
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' , '*/*' )
133
139
. expect ( 204 , done )
134
140
} )
135
141
} )
@@ -329,6 +335,11 @@ describe('HTTP APIs', function () {
329
335
server . get ( '/invalidfile.foo' )
330
336
. expect ( 404 , done )
331
337
} )
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
+ } )
332
343
it ( 'should return basic container link for directories' , function ( done ) {
333
344
server . get ( '/' )
334
345
. 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 () {
411
422
. expect ( 'content-type' , / t e x t \/ t u r t l e / )
412
423
. end ( done )
413
424
} )
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 )
420
446
} )
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
+ } )
421
458
} )
422
459
423
460
describe ( 'HEAD API' , function ( ) {
0 commit comments