1 | var assert = require('assert');
|
2 | var crypto = require('crypto');
|
3 | var tenantFactory = require('..').tenantFactory;
|
4 | var fixtures = require('./fixtures');
|
5 |
|
6 | describe('ac hipchat tenant factory', function () {
|
7 |
|
8 | it('should combine an installable payload and capabilities document into a full tenant profile', function *() {
|
9 | var installable = fixtures.load('tenant-installable.json');
|
10 | var capabilities = fixtures.load('tenant-capabilities.json');
|
11 | var webhookToken = crypto.createHash('sha1')
|
12 | .update(installable.oauthId)
|
13 | .update(installable.oauthSecret)
|
14 | .digest('hex');
|
15 | assert.deepEqual(tenantFactory(installable, capabilities), {
|
16 | id: installable.oauthId,
|
17 | secret: installable.oauthSecret,
|
18 | group: installable.groupId,
|
19 | room: installable.roomId,
|
20 | webhookToken: webhookToken,
|
21 | links: {
|
22 | capabilities: capabilities.links.self,
|
23 | base: capabilities.links.homepage,
|
24 | api: capabilities.links.api,
|
25 | token: capabilities.capabilities.oauth2Provider.tokenUrl
|
26 | }
|
27 | });
|
28 | });
|
29 |
|
30 | });
|