Skip to content

Commit c6662d0

Browse files
kjetilkrubensworks
authored andcommitted
Current work on group listings
1 parent 5bec08e commit c6662d0

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

lib/acl-checker.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,42 @@ class ACLChecker {
136136
let returnAcl = null
137137
while (possibleACLs.length > 0 && !returnAcl) {
138138
const acl = possibleACLs.shift()
139+
let graph
139140
try {
140-
const graph = await this.fetch(acl)
141-
const relative = resource.replace(acl.replace(/[^/]+$/, ''), './')
142-
debug(`Using ACL ${acl} for ${relative}`)
143-
returnAcl = { acl, graph, isContainer }
141+
graph = await this.fetch(acl)
144142
} catch (err) {
145143
if (err && (err.code === 'ENOENT' || err.status === 404)) {
146144
isContainer = true
147145
continue
148-
} else if (err) {
149-
console.error('ERROR IN getNearestACL', err.code, err)
150-
debug(err)
151-
throw err
152146
}
147+
console.error('ERROR IN getNearestACL', err.code, err)
148+
debug(err)
149+
throw err
153150
}
151+
152+
const fetcher = new rdf.Fetcher(graph)
153+
fetcher.load(graph.each(null, ACL('agentGroup'), null))
154+
/*
155+
try {
156+
await Promise.all(groups.map(async group => {
157+
/* const response = await fetch(group)
158+
const body = await response.text()
159+
return new Promise((resolve, reject) => {
160+
rdf.parse(body, graph, group, 'text/turtle', err => {
161+
if (err) {
162+
return reject(err)
163+
}
164+
resolve()
165+
})
166+
})
167+
}))
168+
} catch (error) {
169+
console.log('DAAAAAAAAAAAAAAAAAAHUUUUUUUUUUUUT', error)
170+
}
171+
*/
172+
const relative = resource.replace(acl.replace(/[^/]+$/, ''), './')
173+
debug(`Using ACL ${acl} for ${relative}`)
174+
returnAcl = { acl, graph, isContainer }
154175
}
155176
if (!returnAcl) {
156177
throw new HTTPError(500, `No ACL found for ${resource}, searched in \n- ${acls.join('\n- ')}`)

lib/handlers/allow.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ function allow (mode) {
3838
origin: req.get('origin'),
3939
// host: req.get('host'),
4040
fetch: fetchFromLdp(ldp.resourceMapper, ldp),
41-
// fetchGraph: (uri, options) => {
42-
// // first try loading from local fs
43-
// return ldp.getGraph(uri, options.contentType)
44-
// // failing that, fetch remote graph
45-
// .catch(() => ldp.fetchGraph(uri, options))
46-
// },
41+
fetchGraph: (uri, options) => {
42+
// first try loading from local fs
43+
return ldp.getGraph(uri, options.contentType)
44+
// failing that, fetch remote graph
45+
.catch(() => ldp.fetchGraph(uri, options))
46+
},
4747
suffix: ldp.suffixAcl,
4848
strictOrigin: ldp.strictOrigin,
4949
trustedOrigins: ldp.trustedOrigins

test/integration/acl-oidc-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
560560
})
561561
})
562562

563-
describe('Group', function () {
563+
describe.only('Group', function () {
564564
// before(function () {
565565
// rm('/accounts-acl/tim.localhost/group/test-folder/.acl')
566566
// })
@@ -581,7 +581,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
581581
// done()
582582
// })
583583
// })
584-
it('user1 should be able to access test directory', function (done) {
584+
it.only('user1 should be able to access test directory', function (done) {
585585
var options = createOptions('/group/test-folder/', 'user1')
586586

587587
request.head(options, function (error, response, body) {
@@ -652,7 +652,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
652652
done()
653653
})
654654
})
655-
it.skip('We should have a 404 for non-existent file',
655+
it('We should have a 404 for non-existent file',
656656
function (done) {
657657
var options = createOptions('/group/test-folder/nothere.txt', 'user2')
658658

0 commit comments

Comments
 (0)