From 326183dede11abeb467bcace0ba39dc5c30a4d30 Mon Sep 17 00:00:00 2001 From: Travis Webb Date: Fri, 25 Sep 2015 02:52:38 -0400 Subject: [PATCH] update tests --- config/fixtures/permission.js | 7 +++- package.json | 4 +-- test/unit/controllers/UserController.test.js | 35 -------------------- 3 files changed, 8 insertions(+), 38 deletions(-) diff --git a/config/fixtures/permission.js b/config/fixtures/permission.js index f8161b9..54a8371 100644 --- a/config/fixtures/permission.js +++ b/config/fixtures/permission.js @@ -20,7 +20,7 @@ var modelRestrictions = { registered: [ 'Role', 'Permission', - //'User', + 'User', 'Passport' ], public: [ @@ -79,6 +79,11 @@ function grantRegisteredPermissions (roles, models, admin) { action: 'read', role: registeredRole.id }, + { + model: _.find(models, { name: 'User' }).id, + action: 'read', + role: registeredRole.id + }, { model: _.find(models, { name: 'User' }).id, action: 'update', diff --git a/package.json b/package.json index b8feb48..6e2f49f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Comprehensive user permissions and entitlements system for sails.js and Waterline. Supports user authentication with passport.js, role-based permissioning, object ownership, and row-level security.", "main": "dist/api/hooks/permissions/index.js", "scripts": { - "test": "mocha --reporter spec --compilers js:babel/register", + "test": "gulp && mocha --reporter spec --compilers js:babel/register", "prepublish": "gulp" }, "repository": { @@ -44,7 +44,7 @@ "mocha": "^2.x.x", "request": "^2.58.0", "sails": "balderdashy/sails", - "sails-auth": "latest", + "sails-auth": "^2.0", "sails-memory": "^0.10.5", "supertest": "^0.15.0", "waterline-postgresql": "^0.12.0" diff --git a/test/unit/controllers/UserController.test.js b/test/unit/controllers/UserController.test.js index 69be46b..611ec32 100644 --- a/test/unit/controllers/UserController.test.js +++ b/test/unit/controllers/UserController.test.js @@ -477,41 +477,6 @@ describe('User Controller', function() { }); - it('should not be able to read another user', function(done) { - - request(sails.hooks.http.app) - .get('/user/' + adminUserId) - .set('Authorization', registeredAuth.Authorization) - .expect(403) - .end(function(err, res) { - var user = res.body; - - assert.ifError(err); - assert(_.isString(user.error), JSON.stringify(user)); - - done(err); - - }); - - }); - - it('should not be able to read all users', function(done) { - - request(sails.hooks.http.app) - .get('/user/') - .set('Authorization', registeredAuth.Authorization) - .expect(200) - .end(function(err, res) { - var users = res.body; - - assert.ifError(err); - assert(users.length == 1); - - done(err); - - }); - - }); });