Fixed e2e-framework to correctly compare headers

refs https://github.com/TryGhost/Toolbox/issues/209
refs https://github.com/TryGhost/Toolbox/issues/210

- Fixed request header processing by the e2e-framework where it failed to lowercase incoming header keys. This bug made it harder to test code paths which involve header checking, e.g. following code: `req.headers['stripe-signature']` would not get a correct value if the header was specified as Stripe-Signature
- Additional output to the status code assertions was added - this allows to have more context when an invalid response code comes back in a test.
This commit is contained in:
Naz 2022-02-15 18:38:45 +07:00
parent f88b6bd02f
commit 09bf5804ad
3 changed files with 11 additions and 5 deletions

View File

@ -182,7 +182,7 @@
},
"devDependencies": {
"@lodder/grunt-postcss": "3.1.1",
"@tryghost/express-test": "0.4.1",
"@tryghost/express-test": "0.4.2",
"@tryghost/jest-snapshot": "0.3.1",
"c8": "7.11.0",
"coffeescript": "2.6.1",

View File

@ -66,6 +66,12 @@ describe('Front-end members behaviour', function () {
.expect(400);
});
it('should fail processing a webhook endpoint with stripe header', async function () {
await request.post('/members/webhooks/stripe')
.set('Stripe-Signature', 'test-invalid-signature')
.expect(401);
});
it('should return no content for invalid token passed in session', async function () {
await request.get('/members/api/session')
.expect(204);

View File

@ -1670,10 +1670,10 @@
resolved "https://registry.yarnpkg.com/@tryghost/express-dynamic-redirects/-/express-dynamic-redirects-0.2.4.tgz#ae11560e16ca9438778a8e9e8034e4c6e7507f6d"
integrity sha512-i1/6SAgfdLRoJX6OCAh7mNm50TzKbWM6hf5W6yGUSAz1M99y+7VypnTkGoy+0XPefS3OgjBTEThYWnz4aimcbQ==
"@tryghost/express-test@0.4.1":
version "0.4.1"
resolved "https://registry.yarnpkg.com/@tryghost/express-test/-/express-test-0.4.1.tgz#b409da2ba3e5fdca28ed25006eec432e1334b9e6"
integrity sha512-Uv8oZ4TbbOWz5LJzfRXiTVnhnUMwlSzNwPOtaRssH7dL0QvwvrZ4AIZg0ejUssyGXcek5jzTVzGt6sKytf2pWg==
"@tryghost/express-test@0.4.2":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@tryghost/express-test/-/express-test-0.4.2.tgz#ca29050423d353631d11c01aeaf38767d0277e76"
integrity sha512-/97blrkjie14U53KQJsbg0SSO/XwmLXjL6c2VN7HmV+Mr2C9NQuvonbwI6BoAifsHjIcAKDpUA7TJ1bURiHxQg==
dependencies:
"@tryghost/jest-snapshot" "^0.3.1"
cookiejar "^2.1.3"