-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PACT tests between selfservice and connector to test for 3D secure and corporate exemption data
- Loading branch information
1 parent
6aecd01
commit 1c27533
Showing
4 changed files
with
170 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -908,5 +908,5 @@ | |
} | ||
] | ||
}, | ||
"generated_at": "2025-01-20T13:08:00Z" | ||
"generated_at": "2025-02-14T11:33:55Z" | ||
} |
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
75 changes: 75 additions & 0 deletions
75
test/pact/connector-client/connector-get-charge-with-authorisation-summary.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,75 @@ | ||
'use strict' | ||
|
||
const { Pact } = require('@pact-foundation/pact') | ||
const chai = require('chai') | ||
const chaiAsPromised = require('chai-as-promised') | ||
const path = require('path') | ||
|
||
const PactInteractionBuilder = require('../../test-helpers/pact/pact-interaction-builder').PactInteractionBuilder | ||
const Connector = require('../../../src/services/clients/connector.client').ConnectorClient | ||
const chargeFixture = require('../../fixtures/charge.fixtures') | ||
const { pactify } = require('../../test-helpers/pact/pactifier').defaultPactifier | ||
|
||
// Constants | ||
const ACCOUNTS_RESOURCE = '/v1/api/accounts' | ||
let connectorClient | ||
const expect = chai.expect | ||
|
||
// Global setup | ||
chai.use(chaiAsPromised) | ||
|
||
const existingGatewayAccountId = 123456 | ||
const existingChargeExternalId = 'ch_123abc456def' | ||
|
||
describe.only('connector client - get single charge', () => { | ||
const provider = new Pact({ | ||
consumer: 'selfservice', | ||
provider: 'connector', | ||
log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), | ||
dir: path.resolve(process.cwd(), 'pacts'), | ||
spec: 2, | ||
pactfileWriteMode: 'merge' | ||
}) | ||
|
||
before(async () => { | ||
const opts = await provider.setup() | ||
connectorClient = new Connector(`http://127.0.0.1:${opts.port}`) | ||
}) | ||
after(() => provider.finalize()) | ||
|
||
describe('get single charge which has authorisation summary request', () => { | ||
const opts = { | ||
chargeId: existingChargeExternalId, | ||
state: { | ||
status: 'success', | ||
finished: true | ||
}, | ||
exemption: { | ||
requested: false | ||
} | ||
} | ||
const response = chargeFixture.validGetChargeResponseWithAuthSummary(opts) | ||
|
||
before(() => { | ||
return provider.addInteraction( | ||
new PactInteractionBuilder(`${ACCOUNTS_RESOURCE}/${existingGatewayAccountId}/charges/${existingChargeExternalId}`) | ||
.withUponReceiving('a valid get charge which has authorisation summary request') | ||
.withState("a charge exists") | ||
.withMethod('GET') | ||
.withStatusCode(200) | ||
.withResponseBody(pactify(response)) | ||
.build()) | ||
}) | ||
|
||
afterEach(() => provider.verify()) | ||
|
||
it('should get a charge which has authorisation summary successfully', function () { | ||
return connectorClient.getCharge(existingGatewayAccountId, existingChargeExternalId) | ||
.then(charge => { | ||
expect(charge.charge_id).to.equal(existingChargeExternalId) | ||
expect(charge.authorisation_summary.three_d_secure.required).to.equal(true) | ||
expect(charge.authorisation_summary.three_d_secure.version).to.equal('2.1.0') | ||
}) | ||
}) | ||
}) | ||
}) |
74 changes: 74 additions & 0 deletions
74
...pact/connector-client/connector-get-charge-with-corporate-exemption-honoured.pact.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,74 @@ | ||
'use strict' | ||
|
||
const { Pact } = require('@pact-foundation/pact') | ||
const chai = require('chai') | ||
const chaiAsPromised = require('chai-as-promised') | ||
const path = require('path') | ||
|
||
const PactInteractionBuilder = require('../../test-helpers/pact/pact-interaction-builder').PactInteractionBuilder | ||
const Connector = require('../../../src/services/clients/connector.client').ConnectorClient | ||
const chargeFixture = require('../../fixtures/charge.fixtures') | ||
const { pactify } = require('../../test-helpers/pact/pactifier').defaultPactifier | ||
|
||
// Constants | ||
const ACCOUNTS_RESOURCE = '/v1/api/accounts' | ||
let connectorClient | ||
const expect = chai.expect | ||
|
||
// Global setup | ||
chai.use(chaiAsPromised) | ||
|
||
const existingGatewayAccountId = 123456 | ||
const existingChargeExternalId = 'ch_123abc456def' | ||
|
||
describe.only('connector client - get single charge', () => { | ||
const provider = new Pact({ | ||
consumer: 'selfservice', | ||
provider: 'connector', | ||
log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), | ||
dir: path.resolve(process.cwd(), 'pacts'), | ||
spec: 2, | ||
pactfileWriteMode: 'merge' | ||
}) | ||
|
||
before(async () => { | ||
const opts = await provider.setup() | ||
connectorClient = new Connector(`http://127.0.0.1:${opts.port}`) | ||
}) | ||
after(() => provider.finalize()) | ||
|
||
describe('get single charge which has an honoured corporate exemption request', () => { | ||
const opts = { | ||
chargeId: existingChargeExternalId, | ||
state: { | ||
status: 'success', | ||
finished: true | ||
}, | ||
authorisation_summary: {three_d_secure: { required: false}} | ||
} | ||
const response = chargeFixture.validGetChargeResponseWithExemption(opts) | ||
|
||
before(() => { | ||
return provider.addInteraction( | ||
new PactInteractionBuilder(`${ACCOUNTS_RESOURCE}/${existingGatewayAccountId}/charges/${existingChargeExternalId}`) | ||
.withUponReceiving('a valid get charge which has an honoured corporate exemption request') | ||
.withState("a charge with honoured corporate exemption exists") | ||
.withMethod('GET') | ||
.withStatusCode(200) | ||
.withResponseBody(pactify(response)) | ||
.build()) | ||
}) | ||
|
||
afterEach(() => provider.verify()) | ||
|
||
it('should get a charge which has an honoured corporate exemption successfully', function () { | ||
return connectorClient.getCharge(existingGatewayAccountId, existingChargeExternalId) | ||
.then(charge => { | ||
expect(charge.charge_id).to.equal(existingChargeExternalId) | ||
expect(charge.exemption.requested).to.equal(true) | ||
expect(charge.exemption.type).to.equal('corporate') | ||
expect(charge.exemption.outcome.result).to.equal('honoured') | ||
}) | ||
}) | ||
}) | ||
}) |