forked from iGeeky/wolf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path60.role.test.js
77 lines (65 loc) · 1.8 KB
/
60.role.test.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const mocha = require('./util/mocha')
const util = require('./util/util')
const headers = util.adminHeaders()
function getAddResponseSchema() {
const schema = util.okSchema({
type: 'object',
properties: {
role: {type: 'object'},
},
required: ['role'],
})
return schema
}
function getListResponseSchema() {
const schema = util.okSchema({
type: 'object',
properties: {
roles: {
type: 'array',
items: {
type: 'object',
},
minItems: 1,
},
total: {type: 'integer'},
},
required: ['roles', 'total'],
})
return schema
}
// const role = null;
describe('role', function() {
const appID = 'role-test-app-id'
let name = 'test-role-name'
it('add', async function() {
const schema = getAddResponseSchema();
const id = 'test-role-id'
const description = 'test-role-description'
const body = {id, name, description, appID, permIDs: ['PERM_OK', 'PERM_02']}
const url = '/wolf/role/add';
await mocha.post({url, headers, body, schema})
});
it('update', async function() {
const schema = getAddResponseSchema();
const id = 'test-role-id'
name += ':updated'
const permIds = ['PERM_UPDATE', 'PERM_OK'];
const description = 'test-role-description:updated'
const body = {id, name, description, permIDs: permIds}
const url = '/wolf/role/update';
await mocha.post({url, headers, body, schema})
});
it('list', async function() {
const schema = getListResponseSchema()
const url = '/wolf/role/list'
const args = {appID, key: name}
const res = await mocha.get({url, headers, args, schema})
});
after(async function() {
const url = '/wolf/role/delete';
const id = 'test-role-id'
const body = {id}
await mocha.post({url, headers, body})
});
});