@@ -92,12 +92,12 @@ describe('ACL with WebID+OIDC over HTTP', function () {
9292 const origin1 = 'http://example.org/'
9393 const origin2 = 'http://example.com/'
9494
95- function createOptions ( path , user ) {
95+ function createOptions ( path , user , contentType = 'text/plain' ) {
9696 const options = {
9797 url : timAccountUri + path ,
9898 headers : {
9999 'accept' : 'text/turtle' ,
100- 'content-type' : 'text/plain'
100+ 'content-type' : contentType
101101 }
102102 }
103103 if ( user ) {
@@ -220,7 +220,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
220220 } )
221221 } )
222222 it ( "should create test file's acl file" , function ( done ) {
223- var options = createOptions ( '/write-acl/test-file.acl' , 'user1' )
223+ var options = createOptions ( '/write-acl/test-file.acl' , 'user1' , 'text/turtle' )
224224 options . body = ''
225225 request . put ( options , function ( error , response , body ) {
226226 assert . equal ( error , null )
@@ -254,7 +254,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
254254 } )
255255
256256 it ( 'should PUT new ACL file' , function ( done ) {
257- var options = createOptions ( '/origin/test-folder/.acl' , 'user1' )
257+ var options = createOptions ( '/origin/test-folder/.acl' , 'user1' , 'text/turtle' )
258258 options . body = '<#Owner> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
259259 ' <http://www.w3.org/ns/auth/acl#accessTo> <https://localhost:3456/origin/test-folder/.acl>;\n' +
260260 ' <http://www.w3.org/ns/auth/acl#agent> <' + user1 + '>;\n' +
@@ -362,7 +362,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
362362 } )
363363 } )
364364 it ( 'user1 should be able to modify ACL file' , function ( done ) {
365- var options = createOptions ( '/read-acl/.acl' , 'user1' )
365+ var options = createOptions ( '/read-acl/.acl' , 'user1' , 'text/turtle' )
366366 options . body = body
367367 request . put ( options , function ( error , response , body ) {
368368 assert . equal ( error , null )
@@ -387,7 +387,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
387387 } )
388388 } )
389389 it ( 'user2 should not be able to modify ACL file' , function ( done ) {
390- var options = createOptions ( '/read-acl/.acl' , 'user2' )
390+ var options = createOptions ( '/read-acl/.acl' , 'user2' , 'text/turtle' )
391391 options . body = '<d> <e> <f> .'
392392 request . put ( options , function ( error , response , body ) {
393393 assert . equal ( error , null )
@@ -404,7 +404,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
404404 } )
405405 } )
406406 it ( 'agent should not be able to modify ACL file' , function ( done ) {
407- var options = createOptions ( '/read-acl/.acl' )
407+ var options = createOptions ( '/read-acl/.acl' , null , 'text/turtle' )
408408 options . body = '<d> <e> <f> .'
409409 request . put ( options , function ( error , response , body ) {
410410 assert . equal ( error , null )
@@ -434,6 +434,16 @@ describe('ACL with WebID+OIDC over HTTP', function () {
434434 done ( )
435435 } )
436436 } )
437+ it ( 'user1 should be able to PATCH an existing resource' , function ( done ) {
438+ var options = createOptions ( '/append-inherited/test.ttl' , 'user1' )
439+ options . body = 'INSERT DATA { :test :hello 789 .}'
440+ options . headers [ 'content-type' ] = 'application/sparql-update'
441+ request . patch ( options , function ( error , response , body ) {
442+ assert . equal ( error , null )
443+ assert . equal ( response . statusCode , 200 )
444+ done ( )
445+ } )
446+ } )
437447 it ( 'user1 should be able to access test file' , function ( done ) {
438448 var options = createOptions ( '/append-acl/abc.ttl' , 'user1' )
439449 request . head ( options , function ( error , response , body ) {
@@ -444,7 +454,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
444454 } )
445455 // TODO POST instead of PUT
446456 it ( 'user1 should be able to modify test file' , function ( done ) {
447- var options = createOptions ( '/append-acl/abc.ttl' , 'user1' )
457+ var options = createOptions ( '/append-acl/abc.ttl' , 'user1' , 'text/turtle' )
448458 options . body = '<a> <b> <c> .\n'
449459 request . put ( options , function ( error , response , body ) {
450460 assert . equal ( error , null )
@@ -453,23 +463,23 @@ describe('ACL with WebID+OIDC over HTTP', function () {
453463 } )
454464 } )
455465 it ( "user2 should not be able to access test file's ACL file" , function ( done ) {
456- var options = createOptions ( '/append-acl/abc.ttl.acl' , 'user2' )
466+ var options = createOptions ( '/append-acl/abc.ttl.acl' , 'user2' , 'text/turtle' )
457467 request . head ( options , function ( error , response , body ) {
458468 assert . equal ( error , null )
459469 assert . equal ( response . statusCode , 403 )
460470 done ( )
461471 } )
462472 } )
463473 it ( 'user2 should not be able to access test file' , function ( done ) {
464- var options = createOptions ( '/append-acl/abc.ttl' , 'user2' )
474+ var options = createOptions ( '/append-acl/abc.ttl' , 'user2' , 'text/turtle' )
465475 request . head ( options , function ( error , response , body ) {
466476 assert . equal ( error , null )
467477 assert . equal ( response . statusCode , 403 )
468478 done ( )
469479 } )
470480 } )
471481 it ( 'user2 (with append permission) cannot use PUT to append' , function ( done ) {
472- var options = createOptions ( '/append-acl/abc.ttl' , 'user2' )
482+ var options = createOptions ( '/append-acl/abc.ttl' , 'user2' , 'text/turtle' )
473483 options . body = '<d> <e> <f> .\n'
474484 request . put ( options , function ( error , response , body ) {
475485 assert . equal ( error , null )
@@ -486,7 +496,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
486496 } )
487497 } )
488498 it ( 'agent (with append permissions) should not PUT' , function ( done ) {
489- var options = createOptions ( '/append-acl/abc.ttl' )
499+ var options = createOptions ( '/append-acl/abc.ttl' , null , 'text/turtle' )
490500 options . body = '<g> <h> <i> .\n'
491501 request . put ( options , function ( error , response , body ) {
492502 assert . equal ( error , null )
@@ -540,7 +550,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
540550 } )
541551 it . skip ( 'user2 should be able to write a file in the test directory' ,
542552 function ( done ) {
543- var options = createOptions ( '/group/test-folder/test.ttl' , 'user2' )
553+ var options = createOptions ( '/group/test-folder/test.ttl' , 'user2' , 'text/turtle' )
544554 options . body = '<#Dahut> a <https://dbpedia.org/resource/Category:French_legendary_creatures>.\n'
545555
546556 request . put ( options , function ( error , response , body ) {
@@ -550,7 +560,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
550560 } )
551561 } )
552562 it . skip ( 'user1 should be able to get the file' , function ( done ) {
553- var options = createOptions ( '/group/test-folder/test.ttl' , 'user1' )
563+ var options = createOptions ( '/group/test-folder/test.ttl' , 'user1' , 'text/turtle' )
554564
555565 request . get ( options , function ( error , response , body ) {
556566 assert . equal ( error , null )
@@ -560,7 +570,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
560570 } )
561571 it . skip ( 'user2 should not be able to write to the ACL' ,
562572 function ( done ) {
563- var options = createOptions ( '/group/test-folder/.acl' , 'user2' )
573+ var options = createOptions ( '/group/test-folder/.acl' , 'user2' , 'text/turtle' )
564574 options . body = '<#Dahut> a <https://dbpedia.org/resource/Category:French_legendary_creatures>.\n'
565575
566576 request . put ( options , function ( error , response , body ) {
@@ -570,7 +580,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
570580 } )
571581 } )
572582 it . skip ( 'user1 should be able to delete the file' , function ( done ) {
573- var options = createOptions ( '/group/test-folder/test.ttl' , 'user1' )
583+ var options = createOptions ( '/group/test-folder/test.ttl' , 'user1' , 'text/turtle' )
574584
575585 request . delete ( options , function ( error , response , body ) {
576586 assert . equal ( error , null )
@@ -610,7 +620,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
610620 ' <http://www.w3.org/ns/auth/acl#agent> <' + user2 + '>;\n' +
611621 ' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>.\n'
612622 it ( "user1 should be able to modify test file's ACL file" , function ( done ) {
613- var options = createOptions ( '/append-acl/abc2.ttl.acl' , 'user1' )
623+ var options = createOptions ( '/append-acl/abc2.ttl.acl' , 'user1' , 'text/turtle' )
614624 options . body = body
615625 request . put ( options , function ( error , response , body ) {
616626 assert . equal ( error , null )
@@ -619,23 +629,23 @@ describe('ACL with WebID+OIDC over HTTP', function () {
619629 } )
620630 } )
621631 it ( "user1 should be able to access test file's ACL file" , function ( done ) {
622- var options = createOptions ( '/append-acl/abc2.ttl.acl' , 'user1' )
632+ var options = createOptions ( '/append-acl/abc2.ttl.acl' , 'user1' , 'text/turtle' )
623633 request . head ( options , function ( error , response , body ) {
624634 assert . equal ( error , null )
625635 assert . equal ( response . statusCode , 200 )
626636 done ( )
627637 } )
628638 } )
629639 it ( 'user1 should be able to access test file' , function ( done ) {
630- var options = createOptions ( '/append-acl/abc2.ttl' , 'user1' )
640+ var options = createOptions ( '/append-acl/abc2.ttl' , 'user1' , 'text/turtle' )
631641 request . head ( options , function ( error , response , body ) {
632642 assert . equal ( error , null )
633643 assert . equal ( response . statusCode , 200 )
634644 done ( )
635645 } )
636646 } )
637647 it ( 'user1 should be able to modify test file' , function ( done ) {
638- var options = createOptions ( '/append-acl/abc2.ttl' , 'user1' )
648+ var options = createOptions ( '/append-acl/abc2.ttl' , 'user1' , 'text/turtle' )
639649 options . body = '<a> <b> <c> .\n'
640650 request . put ( options , function ( error , response , body ) {
641651 assert . equal ( error , null )
@@ -660,7 +670,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
660670 } )
661671 } )
662672 it ( 'user2 should be able to modify test file' , function ( done ) {
663- var options = createOptions ( '/append-acl/abc2.ttl' , 'user2' )
673+ var options = createOptions ( '/append-acl/abc2.ttl' , 'user2' , 'text/turtle' )
664674 options . body = '<d> <e> <f> .\n'
665675 request . put ( options , function ( error , response , body ) {
666676 assert . equal ( error , null )
@@ -677,7 +687,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
677687 } )
678688 } )
679689 it ( 'agent should not be able to modify test file' , function ( done ) {
680- var options = createOptions ( '/append-acl/abc2.ttl' )
690+ var options = createOptions ( '/append-acl/abc2.ttl' , null , 'text/turtle' )
681691 options . body = '<d> <e> <f> .\n'
682692 request . put ( options , function ( error , response , body ) {
683693 assert . equal ( error , null )
@@ -704,7 +714,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
704714 ' <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;\n' +
705715 ' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .\n'
706716 it ( "user1 should be able to modify test directory's ACL file" , function ( done ) {
707- var options = createOptions ( '/write-acl/default-for-new/.acl' , 'user1' )
717+ var options = createOptions ( '/write-acl/default-for-new/.acl' , 'user1' , 'text/turtle' )
708718 options . body = body
709719 request . put ( options , function ( error , response , body ) {
710720 assert . equal ( error , null )
@@ -721,7 +731,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
721731 } )
722732 } )
723733 it ( 'user1 should be able to create new test file' , function ( done ) {
724- var options = createOptions ( '/write-acl/default-for-new/test-file.ttl' , 'user1' )
734+ var options = createOptions ( '/write-acl/default-for-new/test-file.ttl' , 'user1' , 'text/turtle' )
725735 options . body = '<a> <b> <c> .\n'
726736 request . put ( options , function ( error , response , body ) {
727737 assert . equal ( error , null )
@@ -754,7 +764,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
754764 } )
755765 } )
756766 it ( 'user2 should not be able to modify new test file' , function ( done ) {
757- var options = createOptions ( '/write-acl/default-for-new/test-file.ttl' , 'user2' )
767+ var options = createOptions ( '/write-acl/default-for-new/test-file.ttl' , 'user2' , 'text/turtle' )
758768 options . body = '<d> <e> <f> .\n'
759769 request . put ( options , function ( error , response , body ) {
760770 assert . equal ( error , null )
@@ -771,7 +781,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
771781 } )
772782 } )
773783 it ( 'agent should not be able to modify new test file' , function ( done ) {
774- var options = createOptions ( '/write-acl/default-for-new/test-file.ttl' )
784+ var options = createOptions ( '/write-acl/default-for-new/test-file.ttl' , null , 'text/turtle' )
775785 options . body = '<d> <e> <f> .\n'
776786 request . put ( options , function ( error , response , body ) {
777787 assert . equal ( error , null )
0 commit comments