mirror of https://github.com/openclaw/openclaw.git
test: extract fingerprint helper coverage
This commit is contained in:
parent
816ffb9379
commit
2d0b9ee53c
|
|
@ -1,6 +1,5 @@
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { blockedIpv6MulticastLiterals } from "../../shared/net/ip-test-fixtures.js";
|
import { blockedIpv6MulticastLiterals } from "../../shared/net/ip-test-fixtures.js";
|
||||||
import { normalizeFingerprint } from "../tls/fingerprint.js";
|
|
||||||
import { isBlockedHostnameOrIp, isPrivateIpAddress } from "./ssrf.js";
|
import { isBlockedHostnameOrIp, isPrivateIpAddress } from "./ssrf.js";
|
||||||
|
|
||||||
const privateIpCases = [
|
const privateIpCases = [
|
||||||
|
|
@ -102,14 +101,6 @@ describe("ssrf ip classification", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("normalizeFingerprint", () => {
|
|
||||||
it("strips sha256 prefixes and separators", () => {
|
|
||||||
expect(normalizeFingerprint("sha256:AA:BB:cc")).toBe("aabbcc");
|
|
||||||
expect(normalizeFingerprint("SHA-256 11-22-33")).toBe("112233");
|
|
||||||
expect(normalizeFingerprint("aa:bb:cc")).toBe("aabbcc");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("isBlockedHostnameOrIp", () => {
|
describe("isBlockedHostnameOrIp", () => {
|
||||||
it.each([
|
it.each([
|
||||||
"localhost.localdomain",
|
"localhost.localdomain",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { normalizeFingerprint } from "./fingerprint.js";
|
||||||
|
|
||||||
|
describe("normalizeFingerprint", () => {
|
||||||
|
it("strips sha256 prefixes and common separators", () => {
|
||||||
|
expect(normalizeFingerprint("sha256:AA:BB:cc")).toBe("aabbcc");
|
||||||
|
expect(normalizeFingerprint("SHA-256 11-22-33")).toBe("112233");
|
||||||
|
expect(normalizeFingerprint("aa:bb:cc")).toBe("aabbcc");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("handles blank, non-hex, and mixed punctuation input", () => {
|
||||||
|
expect(normalizeFingerprint(" ")).toBe("");
|
||||||
|
expect(normalizeFingerprint("sha256:zz-!!")).toBe("");
|
||||||
|
expect(normalizeFingerprint(" sha256 : AB cd / 12 ")).toBe("abcd12");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("only strips the sha256 prefix at the start of the value", () => {
|
||||||
|
expect(normalizeFingerprint("prefix sha256:AA:BB")).toBe("efa256aabb");
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue