|
| 1 | +const { USER_ROLES: { COUCHDB_ADMIN } } = require('@medic/constants'); |
| 2 | + |
1 | 3 | describe('Auth service', function() { |
2 | 4 |
|
3 | 5 | 'use strict'; |
@@ -58,7 +60,7 @@ describe('Auth service', function() { |
58 | 60 | }); |
59 | 61 |
|
60 | 62 | it('true when user is db admin', async () => { |
61 | | - userCtx.returns({ roles: ['_admin'] }); |
| 63 | + userCtx.returns({ roles: [COUCHDB_ADMIN] }); |
62 | 64 | Settings.resolves({ permissions: { can_edit: [ 'chw' ] } }); |
63 | 65 | const result = await service.has(['can_backup_facilities']); |
64 | 66 | chai.expect(result).to.be.true; |
@@ -176,7 +178,7 @@ describe('Auth service', function() { |
176 | 178 | }); |
177 | 179 |
|
178 | 180 | it('false when admin and !permission', async () => { |
179 | | - userCtx.returns({ roles: ['_admin'] }); |
| 181 | + userCtx.returns({ roles: [COUCHDB_ADMIN] }); |
180 | 182 | Settings.resolves({ permissions: {} }); |
181 | 183 | const result = await service.has(['!can_backup_facilities']); |
182 | 184 | chai.expect(result).to.be.false; |
@@ -246,21 +248,21 @@ describe('Auth service', function() { |
246 | 248 | }); |
247 | 249 |
|
248 | 250 | it('true when admin and no disallowed permissions', async () => { |
249 | | - userCtx.returns({ roles: ['_admin'] }); |
| 251 | + userCtx.returns({ roles: [COUCHDB_ADMIN] }); |
250 | 252 | Settings.resolves({ permissions: { can_edit: [ 'chw' ] } }); |
251 | 253 | const result = await service.any([['can_backup_facilities'], ['can_export_messages'], ['somepermission']]); |
252 | 254 | chai.expect(result).to.be.true; |
253 | 255 | }); |
254 | 256 |
|
255 | 257 | it('true when admin and some disallowed permissions', async () => { |
256 | | - userCtx.returns({ roles: ['_admin'] }); |
| 258 | + userCtx.returns({ roles: [COUCHDB_ADMIN] }); |
257 | 259 | Settings.resolves({ permissions: { can_edit: [ 'chw' ] } }); |
258 | 260 | const result = await service.any([['!can_backup_facilities'], ['!can_export_messages'], ['somepermission']]); |
259 | 261 | chai.expect(result).to.be.true; |
260 | 262 | }); |
261 | 263 |
|
262 | 264 | it('false when admin and all disallowed permissions', async () => { |
263 | | - userCtx.returns({ roles: ['_admin'] }); |
| 265 | + userCtx.returns({ roles: [COUCHDB_ADMIN] }); |
264 | 266 | Settings.resolves({ permissions: {} }); |
265 | 267 | const result = await service.any([['!can_backup_facilities'], ['!can_export_messages'], ['!somepermission']]); |
266 | 268 | chai.expect(result).to.be.false; |
|
0 commit comments