@@ -12,10 +12,9 @@ const FOAF = $rdf.Namespace('http://xmlns.com/foaf/0.1/')
1212
1313const prefixes = `@prefix acl: <http://www.w3.org/ns/auth/acl#> .
1414@prefix foaf: <http://xmlns.com/foaf/0.1/>.
15- @prefix alice: <https://alice.example.com/>.
15+ @prefix alice: <https://alice.example.com/# >.
1616@prefix bob: <https://bob.example.com/#>.
1717`
18- const aliceWebId = 'https://alice.example.com/#me'
1918const alice = $rdf . sym ( 'https://alice.example.com/#me' )
2019const bob = $rdf . sym ( 'https://bob.example.com/#me' )
2120const malory = $rdf . sym ( 'https://someone.else.example.com/' )
@@ -26,22 +25,22 @@ test('aclCheck checkAccess() test - Append access implied by Write acecss', t =>
2625 let aclUrl = 'https://alice.example.com/docs/.acl'
2726 let aclDoc = $rdf . sym ( aclUrl )
2827
29- const kb = $rdf . graph ( ) // Quad store
28+ const store = $rdf . graph ( ) // Quad store
3029 const ACLtext = prefixes +
3130 ` <#auth> a acl:Authorization;
32- acl:mode acl:Read ;
31+ acl:mode acl:Write ;
3332 acl:agent alice:me;
3433 acl:accessTo <${ resource . uri } > .
3534 `
36- $rdf . parse ( ACLtext , kb , aclUrl , 'text/turtle' )
35+ $rdf . parse ( ACLtext , store , aclUrl , 'text/turtle' )
3736
3837 const agent = alice
3938 const directory = null
4039 const modesRequired = [ ACL ( 'Append' ) ]
4140 const trustedOrigins = null
4241 const origin = null
4342
44- const result = aclLogic . checkAccess ( kb , resource , directory , aclDoc , agent , modesRequired , origin , trustedOrigins )
43+ const result = aclLogic . checkAccess ( store , resource , directory , aclDoc , agent , modesRequired , origin , trustedOrigins )
4544 if ( result ) {
4645 t . ok ( result , 'Alice should have Append access implied by Write access' )
4746 } else {
@@ -56,30 +55,30 @@ test('acl-check checkAccess() test - accessTo', function (t) {
5655 let containerAclUrl = 'https://alice.example.com/docs/.acl'
5756 let containerAcl = $rdf . sym ( containerAclUrl )
5857
59- const kb = $rdf . graph ( ) // Quad store
58+ const store = $rdf . graph ( ) // Quad store
6059 const ACLtext = prefixes +
6160 ` <#auth> a acl:Authorization;
6261 acl:mode acl:Read, acl:Write;
6362 acl:agent alice:me;
6463 acl:accessTo <${ container . uri } > .
6564 `
66- $rdf . parse ( ACLtext , kb , containerAclUrl , 'text/turtle' )
65+ $rdf . parse ( ACLtext , store , containerAclUrl , 'text/turtle' )
6766
68- var result = aclLogic . checkAccess ( kb , container , null , containerAcl , alice , [ ACL ( 'Read' ) ] )
67+ var result = aclLogic . checkAccess ( store , container , null , containerAcl , alice , [ ACL ( 'Read' ) ] )
6968 if ( result ) {
7069 t . ok ( result , 'Alice should have Read acces' )
7170 } else {
7271 t . fail ( 'Alice s....' )
7372 }
7473
75- result = aclLogic . checkAccess ( kb , container , null , containerAcl , alice , [ ACL ( 'Write' ) ] )
74+ result = aclLogic . checkAccess ( store , container , null , containerAcl , alice , [ ACL ( 'Write' ) ] )
7675 if ( result ) {
7776 t . ok ( result , 'Alice should have Write acces' )
7877 } else {
7978 t . fail ( 'Alice s....' )
8079 }
8180
82- result = aclLogic . checkAccess ( kb , container , null , containerAcl , bob , [ ACL ( 'Write' ) ] )
81+ result = aclLogic . checkAccess ( store , container , null , containerAcl , bob , [ ACL ( 'Write' ) ] )
8382 if ( ! result ) {
8483 t . ok ( result , 'Bob should not have Write acces' )
8584 } else {
@@ -96,36 +95,36 @@ test('acl-check checkAccess() test - default/inherited', function (t) {
9695 let file1 = $rdf . sym ( 'https://alice.example.com/docs/file1' )
9796 let file2 = $rdf . sym ( 'https://alice.example.com/docs/stuff/file2' )
9897 var result
99- const kb = $rdf . graph ( )
98+ const store = $rdf . graph ( )
10099 let ACLtext = prefixes + ` <#auth> a acl:Authorization;
101100 acl:mode acl:Read;
102101 acl:agent bob:me;
103102 acl:accessTo <${ file1 . uri } > .
104103`
105- $rdf . parse ( ACLtext , kb , containerAcl . uri , 'text/turtle' )
104+ $rdf . parse ( ACLtext , store , containerAcl . uri , 'text/turtle' )
106105
107106 let containerAclText = prefixes + ` <#auth> a acl:Authorization;
108107 acl:mode acl:Read;
109108 acl:agent alice:me;
110109 acl:default <${ container . uri } > .
111110`
112- $rdf . parse ( containerAclText , kb , containerAcl . uri , 'text/turtle' )
111+ $rdf . parse ( containerAclText , store , containerAcl . uri , 'text/turtle' )
113112
114- result = aclLogic . checkAccess ( kb , file1 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
113+ result = aclLogic . checkAccess ( store , file1 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
115114 if ( result ) {
116115 t . ok ( result , 'Alice should have Read acces inherited' )
117116 } else {
118117 t . fail ( 'Alice s....' )
119118 }
120119
121- result = aclLogic . checkAccess ( kb , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
120+ result = aclLogic . checkAccess ( store , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
122121 if ( result ) {
123122 t . ok ( result , 'Alice should have Read acces inherited 2' )
124123 } else {
125124 t . fail ( 'Alice s....' )
126125 }
127126
128- result = aclLogic . checkAccess ( kb , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
127+ result = aclLogic . checkAccess ( store , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
129128 if ( result ) {
130129 t . ok ( result , 'Mallory should NOT have Read acces inherited' )
131130 } else {
@@ -142,26 +141,26 @@ test('aclCheck checkAccess() test - Append access implied by Public Write acecss
142141 let aclUrl = 'https://alice.example.com/docs/.acl'
143142 let aclDoc = $rdf . sym ( aclUrl )
144143
145- const kb = $rdf . graph ( ) // Quad store
144+ const store = $rdf . graph ( ) // Quad store
146145 const ACLtext = prefixes +
147146 ` <#auth> a acl:Authorization;
148147 acl:mode acl:Read;
149148 acl:agentClass foaf:Agent;
150149 acl:accessTo <${ resource . uri } > .
151150 `
152- $rdf . parse ( ACLtext , kb , aclUrl , 'text/turtle' )
151+ $rdf . parse ( ACLtext , store , aclUrl , 'text/turtle' )
153152
154153 const agent = alice
155154 const directory = null
156155 const modesRequired = [ ACL ( 'Append' ) ]
157156 const trustedOrigins = null
158157 const origin = null
159158
160- const result = aclLogic . checkAccess ( kb , resource , directory , aclDoc , agent , modesRequired , origin , trustedOrigins )
159+ const result = aclLogic . checkAccess ( store , resource , directory , aclDoc , agent , modesRequired , origin , trustedOrigins )
161160 if ( result ) {
162- t . ok ( result , 'Alice should have Append access implied by Write access' )
161+ t . ok ( result , 'Alice should have Append access implied by Write access - Public ' )
163162 } else {
164- t . fail ( 'Alice should have Append access implied by Write access' )
163+ t . fail ( 'Alice should have Append access implied by Write access - Public ' )
165164 }
166165 t . end ( )
167166} )
@@ -172,32 +171,46 @@ test('acl-check checkAccess() test - accessTo', function (t) {
172171 let containerAclUrl = 'https://alice.example.com/docs/.acl'
173172 let containerAcl = $rdf . sym ( containerAclUrl )
174173
175- const kb = $rdf . graph ( ) // Quad store
174+ const store = $rdf . graph ( ) // Quad store
176175 const ACLtext = prefixes +
177176 ` <#auth> a acl:Authorization;
178177 acl:mode acl:Read, acl:Write;
179178 acl:agentClass foaf:Agent;
180179 acl:accessTo <${ container . uri } > .
181180 `
182- $rdf . parse ( ACLtext , kb , containerAclUrl , 'text/turtle' )
181+ $rdf . parse ( ACLtext , store , containerAclUrl , 'text/turtle' )
183182
184- var result = aclLogic . checkAccess ( kb , container , null , containerAcl , alice , [ ACL ( 'Read' ) ] )
183+ var result = aclLogic . checkAccess ( store , container , null , containerAcl , alice , [ ACL ( 'Read' ) ] )
185184 if ( result ) {
186- t . ok ( result , 'Alice should have Read acces' )
185+ t . ok ( result , 'Alice should have Read acces - Public ' )
187186 } else {
188187 t . fail ( 'Alice s....' )
189188 }
190189
191- result = aclLogic . checkAccess ( kb , container , null , containerAcl , alice , [ ACL ( 'Write' ) ] )
190+ result = aclLogic . checkAccess ( store , container , null , containerAcl , alice , [ ACL ( 'Write' ) ] )
192191 if ( result ) {
193192 t . ok ( result , 'Alice should have Write acces' )
194193 } else {
195194 t . fail ( 'Alice s....' )
196195 }
197196
198- result = aclLogic . checkAccess ( kb , container , null , containerAcl , bob , [ ACL ( 'Write' ) ] )
199- if ( ! result ) {
200- t . ok ( result , 'Bob should not have Write acces' )
197+ var result = aclLogic . checkAccess ( store , container , null , containerAcl , null , [ ACL ( 'Read' ) ] )
198+ if ( result ) {
199+ t . ok ( result , 'Anonymous should have Read acces to public thing - Public' )
200+ } else {
201+ t . fail ( 'Alice s....' )
202+ }
203+
204+ result = aclLogic . checkAccess ( store , container , null , containerAcl , null , [ ACL ( 'Write' ) ] )
205+ if ( result ) {
206+ t . ok ( result , 'Anonymous should have Write acces - Public' )
207+ } else {
208+ t . fail ( 'Alice s....' )
209+ }
210+
211+ result = aclLogic . checkAccess ( store , container , null , containerAcl , bob , [ ACL ( 'Write' ) ] )
212+ if ( result ) {
213+ t . ok ( result , 'Bob should have Write acces to public write - Public' )
201214 } else {
202215 t . fail ( 'Alice s....' )
203216 }
@@ -212,38 +225,38 @@ test('acl-check checkAccess() test - default/inherited', function (t) {
212225 let file1 = $rdf . sym ( 'https://alice.example.com/docs/file1' )
213226 let file2 = $rdf . sym ( 'https://alice.example.com/docs/stuff/file2' )
214227 var result
215- const kb = $rdf . graph ( )
228+ const store = $rdf . graph ( )
216229 let ACLtext = prefixes + ` <#auth> a acl:Authorization;
217230 acl:mode acl:Read;
218231 acl:agent bob:me;
219232 acl:accessTo <${ file1 . uri } > .
220233`
221- $rdf . parse ( ACLtext , kb , containerAcl . uri , 'text/turtle' )
234+ $rdf . parse ( ACLtext , store , containerAcl . uri , 'text/turtle' )
222235
223236 let containerAclText = prefixes + ` <#auth> a acl:Authorization;
224237 acl:mode acl:Read;
225238 acl:agentClass foaf:Agent;
226239 acl:default <${ container . uri } > .
227240`
228- $rdf . parse ( containerAclText , kb , containerAcl . uri , 'text/turtle' )
241+ $rdf . parse ( containerAclText , store , containerAcl . uri , 'text/turtle' )
229242
230- result = aclLogic . checkAccess ( kb , file1 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
243+ result = aclLogic . checkAccess ( store , file1 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
231244 if ( result ) {
232- t . ok ( result , 'Alice should have Read acces inherited' )
245+ t . ok ( result , 'Alice should have Read acces inherited - Public ' )
233246 } else {
234247 t . fail ( 'Alice s....' )
235248 }
236249
237- result = aclLogic . checkAccess ( kb , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
250+ result = aclLogic . checkAccess ( store , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
238251 if ( result ) {
239- t . ok ( result , 'Alice should have Read acces inherited 2' )
252+ t . ok ( result , 'Alice should have Read acces inherited 2 - Public ' )
240253 } else {
241254 t . fail ( 'Alice s....' )
242255 }
243256
244- result = aclLogic . checkAccess ( kb , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
257+ result = aclLogic . checkAccess ( store , file2 , container , containerAcl , alice , [ ACL ( 'Read' ) ] )
245258 if ( result ) {
246- t . ok ( result , 'Mallory should NOT have Read acces inherited' )
259+ t . ok ( result , 'Mallory should NOT have Read acces inherited - Public ' )
247260 } else {
248261 t . fail ( 'Alice s....' )
249262 }
0 commit comments