-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.integration.spec.js
48 lines (44 loc) · 1.22 KB
/
index.integration.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const acl = require('acl');
const caller = require('grpc-caller');
const AclServer = require('./index').AclServer;
describe('AclServer', () => {
let server, client;
beforeAll(() => {
// eslint-disable-next-line new-cap
server = new AclServer(new acl.memoryBackend()).start();
client = caller('localhost:50051', './acl.proto', 'AclService');
});
afterAll((done) => {
server.stop().then(done).catch(done.fail);
});
it('should pass the smoke test', (done) => {
Promise.resolve().then(() => {
return client.allow({
'roles': ['guest'],
'resources': ['blogs'],
'permissions': ['view'],
});
}).then(() => {
return client.addUserRoles({
'user': 'joed',
'roles': ['guest'],
});
}).then(() => {
return client.isAllowed({
'user': 'joed',
'resource': 'blogs',
'permissions': ['view'],
});
}).then((data) => {
expect(data.result).toEqual(true);
}).then(() => {
return client.isAllowed({
'user': 'joed',
'resource': 'blogs',
'permissions': ['delete'],
});
}).then((data) => {
expect(data.result).toEqual(false);
}).then(done).catch(done.fail);
});
});