Add configurable expiration for Seal and Hose assistance links
This commit is contained in:
1 parent
f6cd2c68b0
commit
932957ea08
9 files changed
+323
-30
No files matched your search
@@ -7,6 +7,8 @@ import {
|
||||
KNOWN_FLAGS,
|
||||
numberOption,
|
||||
parseArgs,
|
||||
parseDelegationExpireHours,
|
||||
parseHoseExpireSeconds,
|
||||
splitOption,
|
||||
stringOption,
|
||||
VALUE_FLAGS
|
||||
@@ -116,6 +118,33 @@ describe("option helpers", () => {
|
||||
expect(splitOption("")).toBeUndefined();
|
||||
expect(splitOption(true)).toBeUndefined();
|
||||
});
|
||||
|
||||
test("parseDelegationExpireHours parses days, hours, and limits to 1..168", () => {
|
||||
expect(parseDelegationExpireHours(undefined)).toBe(24);
|
||||
expect(parseDelegationExpireHours("7d")).toBe(168);
|
||||
expect(parseDelegationExpireHours("1d")).toBe(24);
|
||||
expect(parseDelegationExpireHours("24h")).toBe(24);
|
||||
expect(parseDelegationExpireHours("2h")).toBe(2);
|
||||
expect(parseDelegationExpireHours("168")).toBe(168);
|
||||
expect(parseDelegationExpireHours(168)).toBe(168);
|
||||
expect(parseDelegationExpireHours("86400")).toBe(24);
|
||||
|
||||
expect(() => parseDelegationExpireHours("8d")).toThrow("1 到 168 小时(最大 7 天)");
|
||||
expect(() => parseDelegationExpireHours("0h")).toThrow("1 到 168 小时(最大 7 天)");
|
||||
expect(() => parseDelegationExpireHours("invalid")).toThrow("Must be a valid duration");
|
||||
});
|
||||
|
||||
test("parseHoseExpireSeconds parses days, hours, minutes, and raw seconds", () => {
|
||||
expect(parseHoseExpireSeconds(undefined)).toBe(7200);
|
||||
expect(parseHoseExpireSeconds("7200")).toBe(7200);
|
||||
expect(parseHoseExpireSeconds(7200)).toBe(7200);
|
||||
expect(parseHoseExpireSeconds("2h")).toBe(7200);
|
||||
expect(parseHoseExpireSeconds("7d")).toBe(604800);
|
||||
expect(parseHoseExpireSeconds("30m")).toBe(1800);
|
||||
|
||||
expect(() => parseHoseExpireSeconds("0s")).toThrow("Must be a positive number of seconds");
|
||||
expect(() => parseHoseExpireSeconds("invalid")).toThrow("Must be a valid duration");
|
||||
});
|
||||
});
|
||||
|
||||
describe("flag registry cross-check", () => {
|
||||
|
||||
Reference in new issue
Block a user