UNPKG

725 Btext/coffeescriptView Raw
1{ACL} = require '../lib/ACL'
2
3describe "ACL spec",->
4
5 beforeEach ->
6 console.log "==========running new test( #{@suite.description} - #{@description} )=========="
7
8 it "allows access by model and crud op for public group" ,(done)->
9 checkedOptional = false
10 rules = {
11 "TestModel" : { "read" : ["public"] }
12 }
13 userGroupsResolver = (userID)->
14 throw "should not check for public"
15 optionalCheck = (userID, modelName, modelID, crudOp, cb)->
16 checkedOptional = true
17 cb(null, true)
18
19 acl = new ACL(rules, userGroupsResolver, optionalCheck)
20 acl.verify "test-user", "TestModel", 1, "read", (err,result)->
21 expect(err).toBeNull()
22 expect(result).toBeTruthy()
23 expect(checkedOptional).toBeTruthy()
24 done()
\No newline at end of file