Skip to content

Commit 42010f6

Browse files
committed
Fix bug issue 36 and add test for that condition
1 parent bfc780f commit 42010f6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/acl-check.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ function modesAllowed (kb, doc, directory, aclDoc, agent, origin, trustedOrigins
188188
modeURIorReasons.add(agentAndAppStatus)
189189
} else {
190190
let modes = kb.each(auth, ACL('mode'), null, aclDoc)
191-
if (originTrustedModes && originTrustedModes.length > 0) {
191+
// If there IS an origin, check that those modes are allowed to it too
192+
if (origin && originTrustedModes && originTrustedModes.length > 0) {
192193
modes = modes.filter(mode => nodesIncludeNode(originTrustedModes, mode))
193194
}
194195
modes.forEach(mode => {

test/unit/access-denied-test.js

+5
Original file line numberDiff line numberDiff line change
@@ -427,5 +427,10 @@ test('aclCheck accessDenied() test - with use of originTrustedModes', t => {
427427
const controlModeResult = aclLogic.accessDenied(aclStore, resource, directory, aclDoc, agent, controlModeRequired, origin, trustedOrigins, originTrustedModes)
428428
t.ok(controlModeResult, 'All Required Access Modes Not Granted', 'Correct reason')
429429

430+
// See https://github.com/solid/acl-check/issues/36
431+
const controlModeRequired2 = [ACL('Control')]
432+
const controlModeResult2 = aclLogic.accessDenied(aclStore, resource, directory, aclDoc, agent, controlModeRequired2, null, trustedOrigins, originTrustedModes)
433+
t.ok(!controlModeResult2, 'Should get access irrespective of origin modes modes when No origin', 'Correct reason 2')
434+
430435
t.end()
431436
})

0 commit comments

Comments
 (0)