|
6 | 6 |
|
7 | 7 | import 'should'; |
8 | 8 |
|
9 | | -import * as Promise from 'bluebird'; |
10 | | -const co = Promise.coroutine; |
11 | 9 | const BigNumber = require('bignumber.js'); |
12 | 10 |
|
13 | 11 | const TestBitGo = require('../lib/test_bitgo'); |
14 | 12 |
|
15 | 13 | describe('Enterprise', function () { |
16 | 14 | let bitgo; |
17 | 15 |
|
18 | | - before( |
19 | | - co(function* () { |
20 | | - bitgo = new TestBitGo({ env: 'test' }); |
21 | | - bitgo.initializeTestVars(); |
22 | | - yield bitgo.authenticateEnterpriseCreatorTestUser(bitgo.testUserOTP()); |
23 | | - }) |
24 | | - ); |
| 16 | + before(async function () { |
| 17 | + bitgo = new TestBitGo({ env: 'test' }); |
| 18 | + bitgo.initializeTestVars(); |
| 19 | + await bitgo.authenticateEnterpriseCreatorTestUser(bitgo.testUserOTP()); |
| 20 | + }); |
25 | 21 |
|
26 | 22 | describe('Fetch Enterprise', function () { |
27 | | - it( |
28 | | - 'should fetch an enterprise', |
29 | | - co(function* () { |
30 | | - const enterprises = bitgo.coin('tltc').enterprises(); |
31 | | - const entList = yield enterprises.list(); |
32 | | - entList.length.should.be.greaterThan(6); |
33 | | - const enterprise1 = entList[0]; |
34 | | - enterprise1.id.should.equal('5a84db9be4b3cab007c08ab59fb93ec3'); |
35 | | - enterprise1.name.should.equal('Test Enterprise'); |
36 | | - }) |
37 | | - ); |
| 23 | + it('should fetch an enterprise', async function () { |
| 24 | + const enterprises = bitgo.coin('tltc').enterprises(); |
| 25 | + const entList = await enterprises.list(); |
| 26 | + entList.length.should.be.greaterThan(6); |
| 27 | + const enterprise1 = entList[0]; |
| 28 | + enterprise1.id.should.equal('5a84db9be4b3cab007c08ab59fb93ec3'); |
| 29 | + enterprise1.name.should.equal('Test Enterprise'); |
| 30 | + }); |
38 | 31 |
|
39 | | - it( |
40 | | - 'should fetch the users of an enterprise', |
41 | | - co(function* () { |
42 | | - const enterprises = bitgo.coin('tltc').enterprises(); |
43 | | - const enterprise = (yield enterprises.list())[0]; |
44 | | - const users = yield enterprise.users(); |
45 | | - users.should.have.property('adminUsers'); |
46 | | - users.should.have.property('walletUsers'); |
47 | | - const { adminUsers, walletUsers } = users; |
48 | | - adminUsers.length.should.equal(2); |
49 | | - walletUsers.length.should.equal(1); |
50 | | - const walletUser = walletUsers[0]; |
51 | | - walletUser.should.have.property('id'); |
52 | | - walletUser.should.have.property('username'); |
53 | | - walletUser.id.should.equal('5a84db312cd303af07897eebb5a0fba2'); |
54 | | - walletUser.username.should.equal('[email protected]'); |
55 | | - const adminUser = adminUsers[0]; |
56 | | - adminUser.should.have.property('id'); |
57 | | - adminUser.should.have.property('username'); |
58 | | - adminUser.should.have.property('verified'); |
59 | | - adminUser.id.should.equal('5a849b8cb6f7cb5007b77741e632675a'); |
60 | | - adminUser.username.should.equal('[email protected]'); |
61 | | - adminUser.verified.should.equal(true); |
62 | | - }) |
63 | | - ); |
| 32 | + it('should fetch the users of an enterprise', async function () { |
| 33 | + const enterprises = bitgo.coin('tltc').enterprises(); |
| 34 | + const enterprise = (await enterprises.list())[0]; |
| 35 | + const users = await enterprise.users(); |
| 36 | + users.should.have.property('adminUsers'); |
| 37 | + users.should.have.property('walletUsers'); |
| 38 | + const { adminUsers, walletUsers } = users; |
| 39 | + adminUsers.length.should.equal(2); |
| 40 | + walletUsers.length.should.equal(1); |
| 41 | + const walletUser = walletUsers[0]; |
| 42 | + walletUser.should.have.property('id'); |
| 43 | + walletUser.should.have.property('username'); |
| 44 | + walletUser.id.should.equal('5a84db312cd303af07897eebb5a0fba2'); |
| 45 | + walletUser.username.should.equal('[email protected]'); |
| 46 | + const adminUser = adminUsers[0]; |
| 47 | + adminUser.should.have.property('id'); |
| 48 | + adminUser.should.have.property('username'); |
| 49 | + adminUser.should.have.property('verified'); |
| 50 | + adminUser.id.should.equal('5a849b8cb6f7cb5007b77741e632675a'); |
| 51 | + adminUser.username.should.equal('[email protected]'); |
| 52 | + adminUser.verified.should.equal(true); |
| 53 | + }); |
64 | 54 |
|
65 | | - it( |
66 | | - 'should fetch an enterprise eth fee balance', |
67 | | - co(function* () { |
68 | | - const enterprises = bitgo.coin('teth').enterprises(); |
69 | | - const enterprise = (yield enterprises.list())[0]; |
70 | | - const feeBalance = yield enterprise.getFeeAddressBalance(); |
71 | | - feeBalance.should.have.property('balance'); |
72 | | - const balance = new BigNumber(feeBalance.balance); |
73 | | - balance.greaterThan(1000).should.equal(true); |
74 | | - }) |
75 | | - ); |
| 55 | + it('should fetch an enterprise eth fee balance', async function () { |
| 56 | + const enterprises = bitgo.coin('teth').enterprises(); |
| 57 | + const enterprise = (await enterprises.list())[0]; |
| 58 | + const feeBalance = await enterprise.getFeeAddressBalance(); |
| 59 | + feeBalance.should.have.property('balance'); |
| 60 | + const balance = new BigNumber(feeBalance.balance); |
| 61 | + balance.greaterThan(1000).should.equal(true); |
| 62 | + }); |
76 | 63 | }); |
77 | 64 |
|
78 | 65 | // TODO: remove enterprises after creating them once the functionality is available |
79 | 66 | describe('Modify Enterprise', function () { |
80 | 67 | // TODO: figure out how to approve the removal request from another user |
81 | | - it( |
82 | | - 'should add and remove user from enterprise', |
83 | | - co(function* () { |
84 | | - const enterprise = yield bitgo.coin('tltc').enterprises().create({ name: 'Test Enterprise' }); |
85 | | - const refetchedEnterprise = yield bitgo.coin('tltc').enterprises().get({ id: enterprise.id }); |
86 | | - const users0 = yield refetchedEnterprise.users(); |
87 | | - yield enterprise.addUser({ username: '[email protected]' }); |
88 | | - const users1 = yield refetchedEnterprise.users(); |
89 | | - const removalPendingApproval = yield enterprise.removeUser({ username: '[email protected]' }); |
90 | | - enterprise.id.should.equal(refetchedEnterprise.id); |
91 | | - refetchedEnterprise.name.should.equal('Test Enterprise'); |
92 | | - users0.adminUsers.length.should.equal(1); |
93 | | - users1.adminUsers.length.should.equal(2); |
94 | | - users0.walletUsers.length.should.equal(0); |
95 | | - users1.walletUsers.length.should.equal(0); |
96 | | - removalPendingApproval.state.should.equal('pending'); |
97 | | - }) |
98 | | - ); |
| 68 | + it('should add and remove user from enterprise', async function () { |
| 69 | + const enterprise = await bitgo.coin('tltc').enterprises().create({ name: 'Test Enterprise' }); |
| 70 | + const refetchedEnterprise = await bitgo.coin('tltc').enterprises().get({ id: enterprise.id }); |
| 71 | + const users0 = await refetchedEnterprise.users(); |
| 72 | + await enterprise.addUser({ username: '[email protected]' }); |
| 73 | + const users1 = await refetchedEnterprise.users(); |
| 74 | + const removalPendingApproval = await enterprise.removeUser({ username: '[email protected]' }); |
| 75 | + enterprise.id.should.equal(refetchedEnterprise.id); |
| 76 | + refetchedEnterprise.name.should.equal('Test Enterprise'); |
| 77 | + users0.adminUsers.length.should.equal(1); |
| 78 | + users1.adminUsers.length.should.equal(2); |
| 79 | + users0.walletUsers.length.should.equal(0); |
| 80 | + users1.walletUsers.length.should.equal(0); |
| 81 | + removalPendingApproval.state.should.equal('pending'); |
| 82 | + }); |
99 | 83 |
|
100 | | - it( |
101 | | - 'should add wallets and then list them on an enterprise', |
102 | | - co(function* coEnterpriseWalletAdditionTest() { |
103 | | - const enterprise = yield bitgo.coin('tltc').enterprises().create({ name: 'Test Enterprise' }); |
104 | | - const wallet = yield bitgo.coin('tltc').wallets().generateWallet({ |
105 | | - label: 'Enterprise Test Wallet', |
106 | | - enterprise: enterprise.id, |
107 | | - passphrase: TestBitGo.TEST_WALLET1_PASSCODE, |
108 | | - }); |
109 | | - const enterpriseWallets = yield enterprise.coinWallets(); |
110 | | - enterpriseWallets.should.have.property('wallets'); |
111 | | - enterpriseWallets.wallets.length.should.equal(1); |
112 | | - enterpriseWallets.wallets[0].id().should.equal(wallet.wallet.id()); |
113 | | - yield wallet.wallet.remove(); |
114 | | - const updatedEnterpriseWallets = yield enterprise.coinWallets(); |
115 | | - updatedEnterpriseWallets.should.have.property('wallets'); |
116 | | - updatedEnterpriseWallets.wallets.length.should.equal(0); |
117 | | - }) |
118 | | - ); |
| 84 | + it('should add wallets and then list them on an enterprise', async function coEnterpriseWalletAdditionTest() { |
| 85 | + const enterprise = await bitgo.coin('tltc').enterprises().create({ name: 'Test Enterprise' }); |
| 86 | + const wallet = await bitgo.coin('tltc').wallets().generateWallet({ |
| 87 | + label: 'Enterprise Test Wallet', |
| 88 | + enterprise: enterprise.id, |
| 89 | + passphrase: TestBitGo.TEST_WALLET1_PASSCODE, |
| 90 | + }); |
| 91 | + const enterpriseWallets = await enterprise.coinWallets(); |
| 92 | + enterpriseWallets.should.have.property('wallets'); |
| 93 | + enterpriseWallets.wallets.length.should.equal(1); |
| 94 | + enterpriseWallets.wallets[0].id().should.equal(wallet.wallet.id()); |
| 95 | + await wallet.wallet.remove(); |
| 96 | + const updatedEnterpriseWallets = await enterprise.coinWallets(); |
| 97 | + updatedEnterpriseWallets.should.have.property('wallets'); |
| 98 | + updatedEnterpriseWallets.wallets.length.should.equal(0); |
| 99 | + }); |
119 | 100 | }); |
120 | 101 | }); |
0 commit comments