import { describe, expect, it } from "@suaveplan/testing/runner"; import { detect } from "./aws.js"; describe("aws pattern", () => { it("detects a standalone AWS access key", { timeout: 5000 }, () => { const matches = detect("AKIAIOSFODNN7EXAMPLE"); expect(matches).toHaveLength(1); expect(matches[0].type).toBe("aws-access-key"); expect(matches[0].value).toBe("AKIAIOSFODNN7EXAMPLE"); expect(matches[0].confidence).toBe(0.95); }); it("detects an AWS access key embedded in a config line", { timeout: 5000, }, () => { const matches = detect("aws_access_key_id=AKIAJSIE27AGENPACT7Z"); expect(matches).toHaveLength(1); expect(matches[0].type).toBe("aws-access-key"); }); it("returns empty array for a non-AWS string", { timeout: 5000 }, () => { expect(detect("hello world")).toHaveLength(0); }); it("does not match a key shorter than the required format", { timeout: 5000, }, () => { // AKIA + 15 chars (one short) expect(detect("AKIAIOSFODNN7EXAMPL")).toHaveLength(0); }); it("returns correct start/end indices", { timeout: 5000 }, () => { const input = "key: AKIAIOSFODNN7EXAMPLE end"; const matches = detect(input); expect(matches[0].start).toBe(5); expect(matches[0].end).toBe(25); }); });