@@ -271,7 +271,13 @@ describe('ACL with WebID+OIDC over HTTP', function () {
271271 ' <http://www.w3.org/ns/auth/acl#accessTo> <./>;\n' +
272272 ' <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;\n' +
273273 ' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
274- ' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .\n'
274+ ' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .\n' +
275+ '<#Somebody> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
276+ ' <http://www.w3.org/ns/auth/acl#accessTo> <./>;\n' +
277+ ' <http://www.w3.org/ns/auth/acl#agent> <' + user2 + '>;\n' +
278+ ' <http://www.w3.org/ns/auth/acl#default> <./>;\n' +
279+ ' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
280+ ' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Write> .\n'
275281 request . put ( options , function ( error , response , body ) {
276282 assert . equal ( error , null )
277283 assert . equal ( response . statusCode , 201 )
@@ -290,6 +296,16 @@ describe('ACL with WebID+OIDC over HTTP', function () {
290296 done ( )
291297 } )
292298 } )
299+ it ( 'user2 should be able to access public test directory with wrong origin' , function ( done ) {
300+ var options = createOptions ( '/origin/test-folder/' , 'user2' )
301+ options . headers . origin = origin2
302+
303+ request . head ( options , function ( error , response , body ) {
304+ assert . equal ( error , null )
305+ assert . equal ( response . statusCode , 200 )
306+ done ( )
307+ } )
308+ } )
293309 it ( 'user1 should be able to access to test directory when origin is valid' ,
294310 function ( done ) {
295311 var options = createOptions ( '/origin/test-folder/' , 'user1' )
@@ -301,15 +317,14 @@ describe('ACL with WebID+OIDC over HTTP', function () {
301317 done ( )
302318 } )
303319 } )
304- it ( 'user1 should not be able to access test directory when origin is invalid' ,
320+ it ( 'user1 should be able to access public test directory even when origin is invalid' ,
305321 function ( done ) {
306322 var options = createOptions ( '/origin/test-folder/' , 'user1' )
307323 options . headers . origin = origin2
308324
309325 request . head ( options , function ( error , response , body ) {
310326 assert . equal ( error , null )
311- assert . equal ( response . statusCode , 403 )
312- assert . equal ( response . statusMessage , 'Forbidden' ) // TODO: Should be Origin Unauthorized
327+ assert . equal ( response . statusCode , 200 )
313328 done ( )
314329 } )
315330 } )
@@ -334,21 +349,43 @@ describe('ACL with WebID+OIDC over HTTP', function () {
334349 done ( )
335350 } )
336351 } )
337- it ( 'agent should not be able to access test directory when origin is invalid' ,
352+ it ( 'agent should be able to access public test directory even when origin is invalid' ,
338353 function ( done ) {
339354 var options = createOptions ( '/origin/test-folder/' )
340355 options . headers . origin = origin2
341356
342357 request . head ( options , function ( error , response , body ) {
343358 assert . equal ( error , null )
344- assert . equal ( response . statusCode , 403 )
345- assert . equal ( response . statusMessage , 'Forbidden' ) // TODO: Should be Origin Unauthorized
359+ assert . equal ( response . statusCode , 200 )
346360 done ( )
347361 } )
348362 } )
363+ it ( 'user2 should be able to write to test directory with correct origin' , function ( done ) {
364+ var options = createOptions ( '/origin/test-folder/test1.txt' , 'user2' , 'text/plain' )
365+ options . headers . origin = origin1
366+ options . body = 'DAAAAAHUUUT'
367+ request . put ( options , function ( error , response , body ) {
368+ assert . equal ( error , null )
369+ assert . equal ( response . statusCode , 201 )
370+ done ( )
371+ } )
372+ } )
373+ it ( 'user2 should not be able to write to test directory with wrong origin' , function ( done ) {
374+ var options = createOptions ( '/origin/test-folder/test2.txt' , 'user2' , 'text/plain' )
375+ options . headers . origin = origin2
376+ options . body = 'ARRRRGH'
377+ request . put ( options , function ( error , response , body ) {
378+ assert . equal ( error , null )
379+ assert . equal ( response . statusCode , 403 )
380+ assert . equal ( response . statusMessage , 'Forbidden' ) // TODO: Should be Origin Unauthorized
381+ done ( )
382+ } )
383+ } )
349384
350385 after ( function ( ) {
351386 rm ( '/accounts-acl/tim.localhost/origin/test-folder/.acl' )
387+ rm ( '/accounts-acl/tim.localhost/origin/test-folder/test1.txt' )
388+ rm ( '/accounts-acl/tim.localhost/origin/test-folder/test2.txt' )
352389 } )
353390 } )
354391
0 commit comments