skip etag tests if no redis

This commit is contained in:
Michael C 2023-02-20 16:03:46 -05:00
parent c586c9a7e7
commit cdc080b58b
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4

View file

@ -2,6 +2,7 @@ import assert from "assert";
import { client } from "../utils/httpClient";
import redis from "../../src/utils/redis";
import crypto from "crypto";
import { config } from "../../src/config";
const genRandom = (bytes=8) => crypto.pseudoRandomBytes(bytes).toString("hex");
const validateEtag = (expected: string, actual: string): boolean => {
@ -11,6 +12,10 @@ const validateEtag = (expected: string, actual: string): boolean => {
};
describe("eTag", () => {
before(function() {
if (!config.redis?.enabled) this.skip();
});
const endpoint = "/etag";
it("Should reject weak etag", (done) => {
const etagKey = `W/test-etag-${genRandom()}`;
@ -24,6 +29,10 @@ describe("eTag", () => {
});
describe("304 etag validation", () => {
before(function() {
if (!config.redis?.enabled) this.skip();
});
const endpoint = "/api/skipSegments";
for (const hashType of ["skipSegments", "skipSegmentsHash", "videoLabel", "videoLabelHash"]) {
it(`${hashType} etag should return 304`, (done) => {