You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
730 B
26 lines
730 B
import { describe, expect, it } from "vitest";
|
|
import {
|
|
generateServiceToken,
|
|
hashServiceToken,
|
|
tokenKeyPrefix,
|
|
} from "@/modules/customer/token-crypto";
|
|
|
|
describe("token-crypto", () => {
|
|
it("生成 chj_ 前缀 token", () => {
|
|
const token = generateServiceToken();
|
|
expect(token.startsWith("chj_")).toBe(true);
|
|
expect(token.length).toBeGreaterThan(20);
|
|
});
|
|
|
|
it("hash 稳定", () => {
|
|
const token = "chj_test_token";
|
|
expect(hashServiceToken(token)).toHaveLength(64);
|
|
expect(hashServiceToken(token)).toBe(hashServiceToken(token));
|
|
});
|
|
|
|
it("key prefix 用于列表展示", () => {
|
|
const token = generateServiceToken();
|
|
expect(tokenKeyPrefix(token).length).toBeGreaterThan(0);
|
|
});
|
|
});
|