Skip to content

Commit f1daa8b

Browse files
author
Ryan X. Charles
committed
Fix resharing and webhooks tests and API
Summary: Fixed two issues: 1) The webhooks removeWebhook API call returns the number removed, not the walletId or other properties. 2) The API has been updated recently to support "resharing", which is when you need to share the same wallet with someone again because they have lost or reset their password. To do this, you must set "reshare=true" when sharing the wallet with them. Older API calls that implicitly relied on resharing now must be updated to set reshare=true, or they will fail. This commit fixes some tests that are actually resharing, and thus need to set reshare=true. Also, a check on the type of the reshare property is added to the shareWallet method. Reviewers: benchan Reviewed By: benchan Subscribers: ben Differential Revision: https://phabricator.bitgo.com/D801
1 parent 8e96eb9 commit f1daa8b

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/wallet.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,10 @@ Wallet.prototype.shareWallet = function(params, callback) {
661661
params = params || {};
662662
common.validateParams(params, ['email', 'permissions'], ['walletPassphrase', 'message'], callback);
663663

664+
if (params.reshare !== undefined && typeof(params.reshare) != 'boolean') {
665+
throw new Error('Expected reshare to be a boolean.');
666+
}
667+
664668
if (params.skipKeychain !== undefined && typeof(params.skipKeychain) != 'boolean') {
665669
throw new Error('Expected skipKeychain to be a boolean. ');
666670
}
@@ -706,6 +710,7 @@ Wallet.prototype.shareWallet = function(params, callback) {
706710
var options = {
707711
user: sharing.userId,
708712
permissions: params.permissions,
713+
reshare: params.reshare,
709714
message: params.message
710715
};
711716
if (sharedKeychain) {

test/wallet.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ describe('Wallet', function() {
158158
return wallet1.shareWallet({
159159
email: TestBitGo.TEST_SHARED_KEY_USER,
160160
walletPassphrase: TestBitGo.TEST_WALLET1_PASSCODE,
161+
reshare: true, // for tests, we have actually already shared the wallet, and thus must set reshare
161162
permissions: 'view'
162163
});
163164
})
@@ -184,6 +185,7 @@ describe('Wallet', function() {
184185
return wallet2.shareWallet({
185186
email: TestBitGo.TEST_SHARED_KEY_USER,
186187
walletPassphrase: TestBitGo.TEST_WALLET2_PASSCODE,
188+
reshare: true, // for tests, we have actually already shared the wallet, and thus must set reshare
187189
permissions: 'view,spend'
188190
});
189191
})
@@ -329,6 +331,7 @@ describe('Wallet', function() {
329331
return wallet2.shareWallet({
330332
email: TestBitGo.TEST_SHARED_KEY_USER,
331333
skipKeychain: true,
334+
reshare: true, // for tests, we have actually already shared the wallet, and thus must set reshare
332335
permissions: 'view,spend'
333336
});
334337
})

test/webhooks.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,8 @@ describe('Webhooks', function() {
148148
var type = 'transaction';
149149
wallet.removeWebhook({url: url, type: type})
150150
.then(function (result) {
151-
result.should.have.property('walletId');
152-
result.should.have.property('url');
153-
result.should.have.property('type');
154-
result.walletId.should.eql(wallet.id());
155-
result.url.should.eql(url);
156-
result.type.should.eql(type);
151+
result.should.have.property('removed');
152+
result.removed.should.equal(1);
157153

158154
return wallet.listWebhooks();
159155
})

0 commit comments

Comments
 (0)