-
Notifications
You must be signed in to change notification settings - Fork 50
/
add-app.test.js
37 lines (29 loc) · 1.21 KB
/
add-app.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
const { init: initClients } = require('../../utils/clients');
describe('authoring api - add app', () => {
let clients;
before(async () => {
clients = await initClients();
});
it('allow creating new app with keys-read permission', async () => {
const response = await clients.authoring
.post('/api/apps?author.name=test&author.email=test@soluto.com')
.send({ name: 'my-app', permissions: ['keys-read'] })
.expect(200);
let { appId, appSecret } = response.body;
let appClient = await clients.authoring.with(client =>
client.set({ 'x-client-id': appId, 'x-client-secret': appSecret }).unset('Authorization'),
);
await appClient.get('/api/keys/integration_tests/some_key').expect(200);
await appClient.get('/api/keys').expect(403);
});
it('allow creating new app with invalid permission', async () => {
await clients.authoring
.post('/api/apps?author.name=test&author.email=test@soluto.com')
.send({ name: 'my-app', permissions: ['admin'] })
.expect(400);
await clients.authoring
.post('/api/apps?author.name=test&author.email=test@soluto.com')
.send({ name: 'my-app', permissions: ['my-permission'] })
.expect(400);
});
});