rename cookieJwtAuth to extractTokenFromCookie

This commit is contained in:
StarAppeal
2025-09-19 22:20:40 +02:00
parent b226308c17
commit f866d2b5ab
3 changed files with 7 additions and 7 deletions
@@ -1,6 +1,6 @@
import { describe, it, expect, vi } from "vitest";
import { Request, Response, NextFunction } from "express";
import {cookieJwtAuth} from "../../../src/rest/middleware/cookieAuth";
import {extractTokenFromCookie} from "../../../src/rest/middleware/extractTokenFromCookie";
describe("cookieJwtAuth Middleware", () => {
it("should do nothing if Authorization header already exists", () => {
@@ -15,7 +15,7 @@ describe("cookieJwtAuth Middleware", () => {
const res = {} as Response;
const next = vi.fn() as NextFunction;
cookieJwtAuth(req, res, next);
extractTokenFromCookie(req, res, next);
expect(req.headers.authorization).toBe("Bearer existing-token");
expect(next).toHaveBeenCalledOnce();
@@ -31,7 +31,7 @@ describe("cookieJwtAuth Middleware", () => {
const res = {} as Response;
const next = vi.fn() as NextFunction;
cookieJwtAuth(req, res, next);
extractTokenFromCookie(req, res, next);
expect(req.headers.authorization).toBe("Bearer my-secret-cookie-token");
expect(next).toHaveBeenCalledOnce();
@@ -45,7 +45,7 @@ describe("cookieJwtAuth Middleware", () => {
const res = {} as Response;
const next = vi.fn() as NextFunction;
cookieJwtAuth(req, res, next);
extractTokenFromCookie(req, res, next);
expect(req.headers.authorization).toBeUndefined();
expect(next).toHaveBeenCalledOnce();