-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create add transaction endpoint (#80)
This change creates the POST /v2/{regimeId}/bill-runs/{billRunId}/transactions endpoint, along with a v1 endpoint that passes the request to the 'not supported' controller.
- Loading branch information
Showing
5 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/controllers/presroc/add_bill_run_transaction.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
class PresrocAddBillRunTransactionController { | ||
static async create (_req, _h) { | ||
return 'hello, pre-sroc add bill run transaction' | ||
} | ||
} | ||
|
||
module.exports = PresrocAddBillRunTransactionController |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/controllers/presroc/add_bill_run_transaction.controller.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict' | ||
|
||
// Test framework dependencies | ||
const Lab = require('@hapi/lab') | ||
const Code = require('@hapi/code') | ||
const Sinon = require('sinon') | ||
|
||
const { describe, it, before, after } = exports.lab = Lab.script() | ||
const { expect } = Code | ||
|
||
// For running our service | ||
const { deployment } = require('../../../server') | ||
|
||
// Test helpers | ||
const { AuthorisationHelper } = require('../../support/helpers') | ||
|
||
// Things we need to stub | ||
const JsonWebToken = require('jsonwebtoken') | ||
|
||
describe('Presroc Add Bill Run Transaction controller', () => { | ||
const clientID = '1234546789' | ||
const billRunId = 'b976d8e4-3644-11eb-adc1-0242ac120002' | ||
let server | ||
let authToken | ||
|
||
before(async () => { | ||
server = await deployment() | ||
authToken = AuthorisationHelper.nonAdminToken(clientID) | ||
|
||
Sinon | ||
.stub(JsonWebToken, 'verify') | ||
.returns(AuthorisationHelper.decodeToken(authToken)) | ||
}) | ||
|
||
after(async () => { | ||
Sinon.restore() | ||
}) | ||
|
||
describe('Add a bill run transaction: POST /v2/{regimeId}/bill-runs/{billRunId}/transactions', () => { | ||
const options = (token, payload) => { | ||
return { | ||
method: 'POST', | ||
url: `/v2/wrls/bill-runs/${billRunId}/transactions`, | ||
headers: { authorization: `Bearer ${token}` }, | ||
payload: payload | ||
} | ||
} | ||
|
||
it('responds to POST request', async () => { | ||
const response = await server.inject(options(authToken, {})) | ||
|
||
expect(response.statusCode).to.equal(200) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters