mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-14 15:37:07 +03:00
Fix etag tests
This commit is contained in:
@@ -31,7 +31,7 @@ describe("304 etag validation", () => {
|
|||||||
const endpoint = "/etag";
|
const endpoint = "/etag";
|
||||||
for (const hashType of ["skipSegments", "skipSegmentsHash", "videoLabel", "videoLabelHash"]) {
|
for (const hashType of ["skipSegments", "skipSegmentsHash", "videoLabel", "videoLabelHash"]) {
|
||||||
it(`${hashType} etag should return 304`, () => {
|
it(`${hashType} etag should return 304`, () => {
|
||||||
const etagKey = `${hashType};${genRandom};YouTube;${Date.now()}`;
|
const etagKey = `"${hashType};${genRandom};YouTube;${Date.now()}"`;
|
||||||
return redis.setEx(etagKey, 8400, "test").then(() =>
|
return redis.setEx(etagKey, 8400, "test").then(() =>
|
||||||
client.get(endpoint, { headers: { "If-None-Match": etagKey } }).then(res => {
|
client.get(endpoint, { headers: { "If-None-Match": etagKey } }).then(res => {
|
||||||
assert.strictEqual(res.status, 304);
|
assert.strictEqual(res.status, 304);
|
||||||
@@ -43,14 +43,14 @@ describe("304 etag validation", () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it(`other etag type should not return 304`, () => {
|
it(`other etag type should not return 304`, () => {
|
||||||
const etagKey = `invalidHashType;${genRandom};YouTube;${Date.now()}`;
|
const etagKey = `"invalidHashType;${genRandom};YouTube;${Date.now()}"`;
|
||||||
return client.get(endpoint, { headers: { "If-None-Match": etagKey } }).then(res => {
|
return client.get(endpoint, { headers: { "If-None-Match": etagKey } }).then(res => {
|
||||||
assert.strictEqual(res.status, 404);
|
assert.strictEqual(res.status, 404);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`outdated etag type should not return 304`, () => {
|
it(`outdated etag type should not return 304`, () => {
|
||||||
const etagKey = `skipSegments;${genRandom};YouTube;5000`;
|
const etagKey = `"skipSegments;${genRandom};YouTube;5000"`;
|
||||||
return client.get(endpoint, { headers: { "If-None-Match": etagKey } }).then(res => {
|
return client.get(endpoint, { headers: { "If-None-Match": etagKey } }).then(res => {
|
||||||
assert.strictEqual(res.status, 404);
|
assert.strictEqual(res.status, 404);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user