|
@@ -27,19 +27,19 @@ describe 'AuthorizationManager', ->
|
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
|
expect(error).to.be.null
|
|
expect(error).to.be.null
|
|
|
done()
|
|
done()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it "should allow the readAndWrite privilegeLevel", (done) ->
|
|
it "should allow the readAndWrite privilegeLevel", (done) ->
|
|
|
@client.params.privilege_level = "readAndWrite"
|
|
@client.params.privilege_level = "readAndWrite"
|
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
|
expect(error).to.be.null
|
|
expect(error).to.be.null
|
|
|
done()
|
|
done()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it "should allow the owner privilegeLevel", (done) ->
|
|
it "should allow the owner privilegeLevel", (done) ->
|
|
|
@client.params.privilege_level = "owner"
|
|
@client.params.privilege_level = "owner"
|
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
|
expect(error).to.be.null
|
|
expect(error).to.be.null
|
|
|
done()
|
|
done()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it "should return an error with any other privilegeLevel", (done) ->
|
|
it "should return an error with any other privilegeLevel", (done) ->
|
|
|
@client.params.privilege_level = "unknown"
|
|
@client.params.privilege_level = "unknown"
|
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanViewProject @client, (error) ->
|
|
@@ -52,19 +52,19 @@ describe 'AuthorizationManager', ->
|
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
|
error.message.should.equal "not authorized"
|
|
error.message.should.equal "not authorized"
|
|
|
done()
|
|
done()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it "should allow the readAndWrite privilegeLevel", (done) ->
|
|
it "should allow the readAndWrite privilegeLevel", (done) ->
|
|
|
@client.params.privilege_level = "readAndWrite"
|
|
@client.params.privilege_level = "readAndWrite"
|
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
|
expect(error).to.be.null
|
|
expect(error).to.be.null
|
|
|
done()
|
|
done()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it "should allow the owner privilegeLevel", (done) ->
|
|
it "should allow the owner privilegeLevel", (done) ->
|
|
|
@client.params.privilege_level = "owner"
|
|
@client.params.privilege_level = "owner"
|
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
|
expect(error).to.be.null
|
|
expect(error).to.be.null
|
|
|
done()
|
|
done()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it "should return an error with any other privilegeLevel", (done) ->
|
|
it "should return an error with any other privilegeLevel", (done) ->
|
|
|
@client.params.privilege_level = "unknown"
|
|
@client.params.privilege_level = "unknown"
|
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
@AuthorizationManager.assertClientCanEditProject @client, (error) ->
|
|
@@ -84,20 +84,16 @@ describe 'AuthorizationManager', ->
|
|
|
@client.params.privilege_level = "unknown"
|
|
@client.params.privilege_level = "unknown"
|
|
|
|
|
|
|
|
it "should not allow access", () ->
|
|
it "should not allow access", () ->
|
|
|
- @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|
|
|
|
|
|
|
|
describe "even when authorised at the doc level", ->
|
|
describe "even when authorised at the doc level", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@AuthorizationManager.addAccessToDoc @client, @doc_id, done
|
|
@AuthorizationManager.addAccessToDoc @client, @doc_id, done
|
|
|
|
|
|
|
|
it "should not allow access", () ->
|
|
it "should not allow access", () ->
|
|
|
- @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|
|
|
|
|
|
|
|
describe "when authorised at the project level", ->
|
|
describe "when authorised at the project level", ->
|
|
|
beforeEach () ->
|
|
beforeEach () ->
|
|
@@ -105,10 +101,8 @@ describe 'AuthorizationManager', ->
|
|
|
|
|
|
|
|
describe "and not authorised at the document level", ->
|
|
describe "and not authorised at the document level", ->
|
|
|
it "should not allow access", () ->
|
|
it "should not allow access", () ->
|
|
|
- @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|
|
|
|
|
|
|
|
describe "and authorised at the document level", ->
|
|
describe "and authorised at the document level", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
@@ -126,10 +120,8 @@ describe 'AuthorizationManager', ->
|
|
|
@AuthorizationManager.removeAccessToDoc @client, @doc_id, done
|
|
@AuthorizationManager.removeAccessToDoc @client, @doc_id, done
|
|
|
|
|
|
|
|
it "should deny access", () ->
|
|
it "should deny access", () ->
|
|
|
- @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|
|
|
|
|
|
|
|
describe "assertClientCanEditProjectAndDoc", ->
|
|
describe "assertClientCanEditProjectAndDoc", ->
|
|
|
beforeEach () ->
|
|
beforeEach () ->
|
|
@@ -142,20 +134,16 @@ describe 'AuthorizationManager', ->
|
|
|
@client.params.privilege_level = "readOnly"
|
|
@client.params.privilege_level = "readOnly"
|
|
|
|
|
|
|
|
it "should not allow access", () ->
|
|
it "should not allow access", () ->
|
|
|
- @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|
|
|
|
|
|
|
|
describe "even when authorised at the doc level", ->
|
|
describe "even when authorised at the doc level", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@AuthorizationManager.addAccessToDoc @client, @doc_id, done
|
|
@AuthorizationManager.addAccessToDoc @client, @doc_id, done
|
|
|
|
|
|
|
|
it "should not allow access", () ->
|
|
it "should not allow access", () ->
|
|
|
- @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|
|
|
|
|
|
|
|
describe "when authorised at the project level", ->
|
|
describe "when authorised at the project level", ->
|
|
|
beforeEach () ->
|
|
beforeEach () ->
|
|
@@ -163,10 +151,8 @@ describe 'AuthorizationManager', ->
|
|
|
|
|
|
|
|
describe "and not authorised at the document level", ->
|
|
describe "and not authorised at the document level", ->
|
|
|
it "should not allow access", () ->
|
|
it "should not allow access", () ->
|
|
|
- @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|
|
|
|
|
|
|
|
describe "and authorised at the document level", ->
|
|
describe "and authorised at the document level", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
@@ -184,7 +170,5 @@ describe 'AuthorizationManager', ->
|
|
|
@AuthorizationManager.removeAccessToDoc @client, @doc_id, done
|
|
@AuthorizationManager.removeAccessToDoc @client, @doc_id, done
|
|
|
|
|
|
|
|
it "should deny access", () ->
|
|
it "should deny access", () ->
|
|
|
- @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback
|
|
|
|
|
- @callback
|
|
|
|
|
- .calledWith(new Error("not authorised"))
|
|
|
|
|
- .should.equal true
|
|
|
|
|
|
|
+ @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) ->
|
|
|
|
|
+ err.message.should.equal "not authorized"
|