Skip to content

Commit f4e05cd

Browse files
committed
Returns a list if any param in getTrustedModesForOrigin is falsy
And fixed some typos
1 parent 3c3f87e commit f4e05cd

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/acl-check.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ function accessDenied (kb, doc, directory, aclDoc, agent, modesRequired, origin,
4545
}
4646

4747
async function getTrustedModesForOrigin (kb, agent, origin) {
48-
if (!kb || !origin) {
49-
return Promise.resolve({})
48+
if (!kb || !agent || !origin) {
49+
return Promise.resolve([])
5050
}
51-
const queryString = `
51+
const result = await query(`
5252
SELECT ?mode WHERE {
5353
${agent} ${ACL('trustedApp')} ?trustedOrigin.
5454
?trustedOrigin ${ACL('origin')} ${origin};
5555
${ACL('mode')} ?mode .
56-
}`
57-
const results = await query(queryString, kb)
58-
return results.map(result => result['?mode'])
56+
}`, kb)
57+
const trustedModes = result.map(result => result['?mode'])
58+
return Promise.resolve(trustedModes)
5959
}
6060

6161
async function query (queryString, store) {

test/unit/access-denied-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ test('aclCheck accessDenied() test - With trustedOrigins', t => {
404404
t.end()
405405
})
406406

407-
test('aclCheck accessDenied() test - with use of acl:trustedApp', t => {
407+
test('aclCheck accessDenied() test - with use of originTrustedModes', t => {
408408
const resource = ALICE('docs/file1')
409409
const aclDoc = ALICE('docs/.acl')
410410
const aclUrl = aclDoc.uri

test/unit/get-trusted-modes-for-origin-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const prefixes = `
1313
@prefix alice: ${ALICE('#')} .
1414
`
1515

16-
test('aclCheck getTrustedModesForOirign() test', t => {
16+
test('aclCheck getTrustedModesForOrigin() getting trusted modes from agentStore', t => {
1717
const origin = $rdf.sym('https://apps.example.com')
1818
const agent = alice
1919
const agentStore = $rdf.graph()

0 commit comments

Comments
 (0)