Add ability to inject stubbed payloads into sampleNotifications
See original GitHub issueI use the sampleNotifications
function in the WebhookTestingGateway https://developers.braintreepayments.com/guides/webhooks/testing-go-live/node, which are great, but I’ve noticed that the subjectXmlForSubscription
contains no data, which makes it difficult to test for specific scenarios.
What would be excellent, is if there was an option to inject stub payloads into the sampleNotification method. They could either be xml, or even go a step further allow injection of a javascript object, which would then need to be converted into xml.
This would mean a developer could easily set up a suite of unit test for specific scenarios and would be a massive help when integrating.
e.g. instead of
const sampleNotification = gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionWentPastDue,
"myId"
);
Something like:
const stubbedPayload = {
kind: 'subscription_created',
timestamp: '2017-03-14T15:47:33Z',
subject: {
subscription: {
billingPeriodEndDate: '2017-03-21',
billingPeriodStartDate: '2017-03-14',
paidThroughDate: '2017-03-21',
price: '19.99',
status: 'Trialing',
trialPeriod: true,
transactions: [
{
currencyIsoCode: 'USD',
customer: { id: 'my-user-id' }
}
]
}
}
};
const sampleNotification = gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionWentActive,
stubbedPayload
);
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Inject Stub Collaborators In Globally Stubbed Class Using ...
I am calling render but specifying a template (not a controller or view), so it is directly rendering the GSP. Even if it...
Read more >Stubbing and Mocking in Java with the Spock Testing ...
Learn how to create true Java unit tests by mocking all external dependencies in your unit tests with the Spock testing framework.
Read more >Returning stubbed HTTP responses to specific requests
A core feature of WireMock is the ability to return canned HTTP responses for requests matching criteria. These are described in detail in...
Read more >9 Testing RIB
The stubbed implementation has been written to insert the payload to a database once inject has been called. Injectors.xml has been configured to...
Read more >Use Mocks and Stub Objects Unit | Salesforce Trailhead
In this unit, we create and use an HttpMock and a custom stub object. ... This ability to inject the return value into...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I initially implemented it that way, but quickly found that using the Braintree production webhook responses would throw errors because of the attributes after the <subject> element. EG:
The accounts information is separated into this second part and it’s not clear without running the webhooks what the true response format will be (as the testing ones are not complete).
Feedback from the Braintree team will help clarify what’s necessary and maybe it’ll change back to the split method. Time will tell.
We’re not going to add this feature at this time. (See https://github.com/braintree/braintree_node/pull/111#issuecomment-356122013)