Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
import { describe, expect, test } from "vitest";
import {
buildSessionLogObjectName,
chunkIdTimeMs,
parseSessionLogObjectKey,
toRev
} from "./agent-vault-session-log-fns";
describe("session log object names", () => {
const orgId = "c4a1e0d2-5b7f-4c1e-9a3d-2f6b8e0c7a11";
const sessionId = "5d2e9b41-0c3a-4f8e-b7d2-91a4c6e8f035";
const proxyId = "e91f3c20-7d4b-4a8e-9f1c-3b5d7e2a6c48";
const chunkId = "01a11226-9990-7a3f-8c21-4e6f9b2d1a07";
const folder = `agent-vault-1/orgs/${orgId}/agent-vault/sessions/${sessionId}/logs/`;
test("names a chunk by rev, chunk and proxy", () => {
expect(buildSessionLogObjectName({ proxyId, chunkId })).toBe(`8208694117999_${chunkId}.${proxyId}.json.enc`);
});
test("reads the time out of the chunk id", () => {
expect(chunkIdTimeMs(chunkId)).toBe(1791305882000);
});
test("a newer chunk sorts first, which is the only order S3 lists in", () => {
expect(toRev(2_000) < toRev(1_000)).toBe(true);
expect(toRev(1_000)).toHaveLength(13);
});
test("clamps a time outside what 13 digits can hold", () => {
expect(toRev(-5)).toBe("9999999999999");
expect(toRev(1e14)).toBe("0000000000000");
});
test("parses a name it built", () => {
expect(parseSessionLogObjectKey(folder, `${folder}${buildSessionLogObjectName({ proxyId, chunkId })}`)).toEqual({
chunkId,
proxyId,
lastRecordAt: new Date(1791305882000)
});
});
test.each([
{
why: "another session's folder",
key: `agent-vault-1/orgs/${orgId}/agent-vault/sessions/other/logs/8208694117999_${chunkId}.${proxyId}.json.enc`
},
{ why: "a nested folder", key: `${folder}${proxyId}/2026-09-16/${chunkId}.json.enc` },
{ why: "a rev that disagrees with the chunk id", key: `${folder}8208694117998_${chunkId}.${proxyId}.json.enc` },
{ why: "a proxy that is not a uuid", key: `${folder}8208694117999_${chunkId}.proxy-1.json.enc` },
{ why: "a file someone else put there", key: `${folder}notes.txt` }
])("skips $why", ({ key }) => {
expect(parseSessionLogObjectKey(folder, key)).toBeNull();
});
});