diff --git a/__tests__/get-tokens.spec.js b/__tests__/get-tokens.spec.js index 8bd3a714..545171a4 100644 --- a/__tests__/get-tokens.spec.js +++ b/__tests__/get-tokens.spec.js @@ -62,7 +62,7 @@ describe('GET tokens', () => { .get(`/tokens/${seed.tokenB.id}`) .set('treetracker-api-key', seed.apiKey) .set('Authorization', `Bearer ${bearerToken}`); - expect(res).to.have.property('statusCode', 401); + expect(res).to.have.property('statusCode', 403); }); it(`walletA, GET /tokens Should be able to get a token `, async () => { diff --git a/server/models/Transfer.spec.js b/server/models/Transfer.spec.js index fca98009..c441672f 100644 --- a/server/models/Transfer.spec.js +++ b/server/models/Transfer.spec.js @@ -586,7 +586,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql(`Do not have enough tokens to send`); expect(isDeductStub).not.called; expect(hasTrustStub).not.called; @@ -829,7 +829,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql('The transfer state is not pending'); expect(transferRepositoryStub.getById).calledOnceWithExactly(transferId); expect(hasControlOverStub).not.called; @@ -905,7 +905,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql('Do not have enough tokens'); expect(transferRepositoryStub.getById).calledOnceWithExactly(transferId); expect(hasControlOverStub).calledOnceWithExactly( @@ -1048,7 +1048,7 @@ describe('Transfer Model', () => { } catch (e) { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'The transfer state is neither pending nor requested', ); @@ -1193,7 +1193,7 @@ describe('Transfer Model', () => { } catch (e) { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'The transfer state is neither pending nor requested', ); @@ -1373,7 +1373,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'Operation forbidden, the transfer state is wrong', ); @@ -1523,7 +1523,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'Operation forbidden, the transfer state is wrong', ); @@ -1558,7 +1558,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql('No need to specify tokens'); expect(transferRepositoryStub.getById).calledOnceWithExactly(transferId); expect(hasControlStub).calledOnceWithExactly(walletLoginId, senderId); @@ -1596,7 +1596,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'Too many tokens to transfer, please provider 1 tokens for this transfer', ); @@ -1636,7 +1636,7 @@ describe('Transfer Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'Too few tokens to transfer, please provider 3 tokens for this transfer', ); diff --git a/server/models/Trust.spec.js b/server/models/Trust.spec.js index 482a49c1..00b92b67 100644 --- a/server/models/Trust.spec.js +++ b/server/models/Trust.spec.js @@ -310,7 +310,7 @@ describe('Trust Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'The trust relationship has been requested or trusted', ); @@ -344,7 +344,7 @@ describe('Trust Model', () => { } catch (e) { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql( 'The trust relationship has been requested or trusted', ); diff --git a/server/models/Wallet.spec.js b/server/models/Wallet.spec.js index 3ae1696c..ef62ed1c 100644 --- a/server/models/Wallet.spec.js +++ b/server/models/Wallet.spec.js @@ -44,7 +44,7 @@ describe('Wallet Model', () => { error = e; } - expect(error.code).eql(403); + expect(error.code).eql(409); expect(error.message).eql(`The wallet 'wallet' already exists`); expect(walletRepositoryStub.getByName).calledOnceWithExactly('wallet'); expect(trustRepositoryStub.create).not.called; diff --git a/server/services/TokenService.spec.js b/server/services/TokenService.spec.js index 98cea47a..c391cb03 100644 --- a/server/services/TokenService.spec.js +++ b/server/services/TokenService.spec.js @@ -196,7 +196,7 @@ describe('Token', () => { } catch (e) { error = e; } - expect(error.code).eql(401); + expect(error.code).eql(403); expect(error.message).eql('Have no permission to visit this token'); expect(getByIdStub.calledOnceWithExactly('tokenId')).eql(true); expect( diff --git a/server/utils/utils.spec.js b/server/utils/utils.spec.js index 498f775a..ab0e5e44 100644 --- a/server/utils/utils.spec.js +++ b/server/utils/utils.spec.js @@ -159,7 +159,7 @@ describe('routers/utils', () => { const res = await request(app) .get('/test') .set('Authorization', `Bearer ${token.slice(1)}`); // NOTE corupt here - expect(res.statusCode).eq(403); + expect(res.statusCode).eq(401); ApiKeyService.prototype.check.restore(); }); });