0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Swapped etag matcher to always be anyEtag

- some tests were using anyString, but we have a more specific matcher available
- it's best to use the most specific matcher possible
This commit is contained in:
Hannah Wolfe 2022-05-01 11:34:33 +01:00
parent 5e441d0942
commit 857464c104
No known key found for this signature in database
GPG key ID: AB586C3B5AE5C037
6 changed files with 29 additions and 29 deletions

View file

@ -6,7 +6,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "7", "content-length": "7",
"content-type": "text/plain; charset=utf-8", "content-type": "text/plain; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"set-cookie": Array [ "set-cookie": Array [
StringMatching /\\^ghost-admin-api-session=/, StringMatching /\\^ghost-admin-api-session=/,
], ],
@ -19,7 +19,7 @@ exports[`Sessions API can delete session (log out) 1: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin", "vary": "Origin",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -59,7 +59,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "515", "content-length": "515",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -88,7 +88,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "321", "content-length": "321",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }

View file

@ -20,7 +20,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "167", "content-length": "167",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }

View file

@ -1,5 +1,5 @@
const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework'); const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyString, anyErrorId, stringMatching, anyISODateTime} = matchers; const {anyEtag, anyErrorId, stringMatching, anyISODateTime} = matchers;
describe('Sessions API', function () { describe('Sessions API', function () {
let agent; let agent;
@ -21,7 +21,7 @@ describe('Sessions API', function () {
.expectStatus(201) .expectStatus(201)
.expectEmptyBody() .expectEmptyBody()
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString, etag: anyEtag,
'set-cookie': [ 'set-cookie': [
stringMatching(/^ghost-admin-api-session=/) stringMatching(/^ghost-admin-api-session=/)
] ]
@ -39,7 +39,7 @@ describe('Sessions API', function () {
updated_at: anyISODateTime updated_at: anyISODateTime
}) })
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}); });
}); });
@ -49,7 +49,7 @@ describe('Sessions API', function () {
.expectStatus(204) .expectStatus(204)
.expectEmptyBody() .expectEmptyBody()
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}); });
}); });
@ -63,7 +63,7 @@ describe('Sessions API', function () {
}] }]
}) })
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}); });
}); });
}); });

View file

@ -1,5 +1,5 @@
const {agentProvider, matchers} = require('../../utils/e2e-framework'); const {agentProvider, matchers} = require('../../utils/e2e-framework');
const {anyString, stringMatching} = matchers; const {anyEtag, stringMatching} = matchers;
describe('Site API', function () { describe('Site API', function () {
let agent; let agent;
@ -17,7 +17,7 @@ describe('Site API', function () {
} }
}) })
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}); });
}); });
}); });

View file

@ -56,7 +56,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "224", "content-length": "224",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -83,7 +83,7 @@ Object {
"content-length": "167", "content-length": "167",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -110,7 +110,7 @@ Object {
"content-length": "167", "content-length": "167",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/, "content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -139,7 +139,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "354", "content-length": "354",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -168,7 +168,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "354", "content-length": "354",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -197,7 +197,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "348", "content-length": "348",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -226,7 +226,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "354", "content-length": "354",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }
@ -252,7 +252,7 @@ Object {
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "167", "content-length": "167",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": Any<String>, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
"x-powered-by": "Express", "x-powered-by": "Express",
} }

View file

@ -1,5 +1,5 @@
const {agentProvider, fixtureManager, matchers, mockManager} = require('../../utils/e2e-framework'); const {agentProvider, fixtureManager, matchers, mockManager} = require('../../utils/e2e-framework');
const {anyErrorId, anyString, stringMatching, anyLocationFor} = matchers; const {anyErrorId, stringMatching, anyEtag} = matchers;
describe('API Versioning', function () { describe('API Versioning', function () {
describe('Admin API', function () { describe('Admin API', function () {
@ -29,7 +29,7 @@ describe('API Versioning', function () {
} }
}) })
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}); });
}); });
@ -44,7 +44,7 @@ describe('API Versioning', function () {
} }
}) })
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString, etag: anyEtag,
'content-version': stringMatching(/v\d+\.\d+/) 'content-version': stringMatching(/v\d+\.\d+/)
}); });
}); });
@ -60,7 +60,7 @@ describe('API Versioning', function () {
} }
}) })
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString, etag: anyEtag,
'content-version': stringMatching(/v\d+\.\d+/) 'content-version': stringMatching(/v\d+\.\d+/)
}); });
}); });
@ -72,7 +72,7 @@ describe('API Versioning', function () {
.header('Accept-Version', 'v999.1') .header('Accept-Version', 'v999.1')
.expectStatus(406) .expectStatus(406)
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}) })
.matchBodySnapshot({ .matchBodySnapshot({
errors: [{ errors: [{
@ -90,7 +90,7 @@ describe('API Versioning', function () {
.header('User-Agent', 'Zapier 1.3') .header('User-Agent', 'Zapier 1.3')
.expectStatus(406) .expectStatus(406)
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}) })
.matchBodySnapshot({ .matchBodySnapshot({
errors: [{ errors: [{
@ -114,7 +114,7 @@ describe('API Versioning', function () {
.header('User-Agent', 'Zapier 1.4') .header('User-Agent', 'Zapier 1.4')
.expectStatus(406) .expectStatus(406)
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}) })
.matchBodySnapshot({ .matchBodySnapshot({
errors: [{ errors: [{
@ -136,7 +136,7 @@ describe('API Versioning', function () {
.header('User-Agent', 'Zapier 1.4') .header('User-Agent', 'Zapier 1.4')
.expectStatus(406) .expectStatus(406)
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}) })
.matchBodySnapshot({ .matchBodySnapshot({
errors: [{ errors: [{
@ -155,7 +155,7 @@ describe('API Versioning', function () {
.header('Accept-Version', 'v4.1') .header('Accept-Version', 'v4.1')
.expectStatus(404) .expectStatus(404)
.matchHeaderSnapshot({ .matchHeaderSnapshot({
etag: anyString etag: anyEtag
}) })
.matchBodySnapshot({ .matchBodySnapshot({
errors: [{ errors: [{