Skip to content

Commit

Permalink
Fixed failing Stripe webhook test
Browse files Browse the repository at this point in the history
refs acf0baa

Due to the bump in express-test, we now handle string bodies 'properly'. So they now pass all the Express middlewares. In the past this failing test did not really pass by the bodyParser.raw middleware,
so the content-type check on the `bodyParser.raw({type: 'application/json'})` middleware was not executed. Now it is, and the test fails because the content-type header was not set to application/json.
  • Loading branch information
SimonBackx committed Jan 18, 2023
1 parent acf0baa commit 6c2af07
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ghost/core/test/e2e-api/members/webhooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);
});
Expand Down Expand Up @@ -307,6 +308,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);

Expand Down Expand Up @@ -516,6 +518,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);

Expand Down Expand Up @@ -649,6 +652,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature);

const {body} = await adminAgent.get('/members/[email protected]');
Expand Down Expand Up @@ -747,6 +751,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature);

const {body} = await adminAgent.get('/members/[email protected]');
Expand Down Expand Up @@ -795,6 +800,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature);

const {body} = await adminAgent.get('/members/[email protected]');
Expand Down Expand Up @@ -865,6 +871,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);
});
Expand Down Expand Up @@ -993,6 +1000,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);

Expand Down Expand Up @@ -1054,6 +1062,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);

Expand Down Expand Up @@ -1390,6 +1399,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature);

const {body} = await adminAgent.get(`/members/?search=${customer_id}@email.com`);
Expand Down Expand Up @@ -1448,6 +1458,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);

Expand Down Expand Up @@ -1586,6 +1597,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature);

const {body} = await adminAgent.get(`/members/?search=${customer_id}@email.com`);
Expand Down Expand Up @@ -1749,6 +1761,7 @@ describe('Members API', function () {

await membersAgent.post('/webhooks/stripe/')
.body(webhookPayload)
.header('content-type', 'application/json')
.header('stripe-signature', webhookSignature)
.expectStatus(200);

Expand Down

0 comments on commit 6c2af07

Please sign in to comment.