From 6c2af0793c39a3c052d4ba49ce6865dd3dbecbf9 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Wed, 18 Jan 2023 11:59:18 +0100 Subject: [PATCH] Fixed failing Stripe webhook test refs https://github.com/TryGhost/Ghost/commit/acf0baa8c7bf579df83feb31a629a58f568ae1d8 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. --- ghost/core/test/e2e-api/members/webhooks.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ghost/core/test/e2e-api/members/webhooks.test.js b/ghost/core/test/e2e-api/members/webhooks.test.js index ab3b158e65c..5c0f44f04fe 100644 --- a/ghost/core/test/e2e-api/members/webhooks.test.js +++ b/ghost/core/test/e2e-api/members/webhooks.test.js @@ -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); }); @@ -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); @@ -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); @@ -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/?search=checkout-webhook-test@email.com'); @@ -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/?search=checkout-newsletter-default-test@email.com'); @@ -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/?search=checkout-newsletter-test@email.com'); @@ -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); }); @@ -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); @@ -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); @@ -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`); @@ -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); @@ -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`); @@ -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);