@@ -6,8 +6,9 @@ var request = require('request');
66var S = require ( 'string' ) ;
77var supertest = require ( 'supertest' ) ;
88var ldnode = require ( '../index' ) ;
9+ var ACL = require ( '../acl' ) . ACL ;
910
10- describe ( 'ACL' , function ( ) {
11+ describe ( 'ACL HTTP ' , function ( ) {
1112 this . timeout ( 10000 ) ;
1213 process . env . NODE_TLS_REJECT_UNAUTHORIZED = '0' ;
1314
@@ -67,7 +68,7 @@ describe('ACL', function() {
6768 }
6869
6970
70- describe ( 'Basic HTTPS Test ' , function ( ) {
71+ describe ( 'Basic' , function ( ) {
7172 it ( 'Should return "Hello, World!"' , function ( done ) {
7273 var options = createOptions ( 'hello.html' , 'user1' ) ;
7374 request ( options , function ( error , response , body ) {
@@ -86,7 +87,7 @@ describe('ACL', function() {
8687 } ) ;
8788 } ) ;
8889
89- describe ( "Empty ACL Test " , function ( ) {
90+ describe ( "Empty .acl " , function ( ) {
9091 it ( "Should create test folder" , function ( done ) {
9192 var options = createOptions ( testDirMetaFile , 'user1' ) ;
9293 options . body = "" ;
@@ -146,7 +147,7 @@ describe('ACL', function() {
146147 } ) ;
147148 } ) ;
148149
149- describe ( "ACL Origin Test " , function ( ) {
150+ describe ( "Origin" , function ( ) {
150151 it ( "Should PUT new ACL file" , function ( done ) {
151152 var options = createOptions ( testDirAclFile , 'user1' ) ;
152153 options . headers = {
@@ -236,7 +237,7 @@ describe('ACL', function() {
236237 } ) ;
237238 } ) ;
238239
239- describe ( "ACL owner -only test " , function ( ) {
240+ describe ( "Owner -only" , function ( ) {
240241 var body = "<#Owner>\n" +
241242 " <http://www.w3.org/ns/auth/acl#accessTo> <" + address + testDir + "/" +
242243 ">, <" + address + testDirAclFile + ">;\n" +
@@ -340,7 +341,7 @@ describe('ACL', function() {
340341 } ) ;
341342 } ) ;
342343
343- describe ( "ACL read -only test " , function ( ) {
344+ describe ( "Read -only" , function ( ) {
344345 var body = "<#Owner>\n" +
345346 " a <http://www.w3.org/ns/auth/acl#Authorization> ;\n" +
346347 " <http://www.w3.org/ns/auth/acl#accessTo> <" + address + testDir + "/" +
@@ -444,7 +445,7 @@ describe('ACL', function() {
444445 } ) ;
445446 } ) ;
446447
447- describe ( "ACL glob test " , function ( ) {
448+ describe ( "Glob " , function ( ) {
448449 it ( "user2 should be able to send glob request" , function ( done ) {
449450 var options = createOptions ( globFile , 'user2' ) ;
450451 request . get ( options , function ( error , response , body ) {
@@ -479,7 +480,7 @@ describe('ACL', function() {
479480 } ) ;
480481 } ) ;
481482
482- describe ( "ACL append -only test " , function ( ) {
483+ describe ( "Append -only" , function ( ) {
483484 var body = "<#Owner>\n" +
484485 " <http://www.w3.org/ns/auth/acl#accessTo> <" + address + abcFile +
485486 ">, <" + address + abcAclFile + ">;\n" +
@@ -588,7 +589,7 @@ describe('ACL', function() {
588589 } ) ;
589590 } ) ;
590591
591- describe ( "ACL restricted test " , function ( ) {
592+ describe ( "Restricted " , function ( ) {
592593 var body = "<#Owner>\n" +
593594 " <http://www.w3.org/ns/auth/acl#accessTo> <" + address + abcFile + ">, <" +
594595 address + abcAclFile + ">;\n" +
@@ -696,7 +697,7 @@ describe('ACL', function() {
696697 } ) ;
697698 } ) ;
698699
699- describe ( "ACL group test " , function ( ) {
700+ describe ( "Group " , function ( ) {
700701 var groupTriples = "<#> a <http://xmlns.com/foaf/0.1/Group>;\n" +
701702 " <http://xmlns.com/foaf/0.1/member> <a>, <b>, <" + user2 + "> .\n" ;
702703 var body = "<#Owner>\n" +
@@ -828,7 +829,7 @@ describe('ACL', function() {
828829 } ) ;
829830 } ) ;
830831
831- describe ( "ACL defaultForNew test " , function ( ) {
832+ describe ( "defaultForNew" , function ( ) {
832833 var body = "<#Owner>\n" +
833834 " <http://www.w3.org/ns/auth/acl#accessTo> <" + address + testDir + "/" + ">, <" +
834835 address + testDirAclFile + ">;\n" +
@@ -964,7 +965,7 @@ describe('ACL', function() {
964965 // });
965966 } ) ;
966967
967- describe ( "ACL cleaup " , function ( ) {
968+ describe ( "Cleaup " , function ( ) {
968969 it ( "should remove all files and dirs created" , function ( done ) {
969970 try {
970971 // must remove the ACLs in sync
@@ -983,3 +984,48 @@ describe('ACL', function() {
983984 } ) ;
984985 } ) ;
985986} ) ;
987+
988+ describe ( 'ACL Class' , function ( ) {
989+ var ldpConfig = {
990+ mount : '/test' ,
991+ root : __dirname + '/resources' ,
992+ key : __dirname + '/keys/key.pem' ,
993+ cert : __dirname + '/keys/cert.pem' ,
994+ webid : true
995+ } ;
996+ var ldpServer = ldnode ( ldpConfig ) ;
997+ var ldp = ldpServer . locals . ldp ;
998+
999+ describe ( 'getUserId' , function ( ) {
1000+ it ( 'should return userId in session if On-Behalf-Of is not specified' , function ( ) {
1001+ var acl = new ACL ( {
1002+ ldp : ldp ,
1003+ origin : 'https://example.com' ,
1004+ session : {
1005+ userId : 'https://user1.databox.me/profile/card#me' ,
1006+ identified : true
1007+ }
1008+ } ) ;
1009+
1010+ acl . getUserId ( function ( err , userId ) {
1011+ assert . equal ( userId , 'https://user1.databox.me/profile/card#me' ) ;
1012+ } ) ;
1013+ } ) ;
1014+
1015+ it ( 'should return userId in session if On-Behalf-Of is not valid' , function ( ) {
1016+ var acl = new ACL ( {
1017+ ldp : ldp ,
1018+ origin : 'https://example.com' ,
1019+ session : {
1020+ userId : 'https://user1.databox.me/profile/card#me' ,
1021+ identified : true
1022+ } ,
1023+ onBehalfOf : ''
1024+ } ) ;
1025+
1026+ acl . getUserId ( function ( err , userId ) {
1027+ assert . equal ( userId , 'https://user1.databox.me/profile/card#me' ) ;
1028+ } ) ;
1029+ } ) ;
1030+ } ) ;
1031+ } ) ;
0 commit comments