Rust (license_commands.rs)
- LicenseError gains InvalidPrefix, InvalidSignature, Malformed and
UnknownEdition. validate_with_key returns it (ExpiredSignature maps
to LicenseExpired), and store_license, read_license and
validate_license_key reject with the same JSON as the network
commands. store_license_in and read_license_in take a directory, so
the Storage mapping is tested at the source.
- D12: the edition comes from the license key alone.
resolve_license_entitlements no longer takes the activation token,
and current_entitlements reads only license.key
(entitlements_from_dir). A token that had expired (2-year server
lifetime) or came from another machine (restored data) used to drop
a valid key to free, while a key copied without its token kept its
edition. get_activation_status and persist_activation_token keep the
strict token validation, and the key keeps its strict validation
(CWE-613).
Front
- LicenseCard names the load error, and LicenseKeyForm (extracted so a
static render reaches it) names a refused key, through
parseLicenseError: no raw backend string reaches the card.
- D13: a license_revoked answer is recorded in LicenseContext for the
whole session, because the card unmounts when the user leaves
Settings > Users. Only a different key clears it. Card-level
message, alert icon, Activate disabled through selectCanActivate.
- Machine counter n/limit, "Not activated", activating and
deactivating labels, dates in fr-CA/en-CA, and "No expiry date"
beyond 50 years (licenseExpiry.ts, for the 100-year keys of
maximus-api#63).
- license.removeLicense and license.machines.activateError removed;
the price authFailed message points to activating the machine.
Tests: 15 new Rust tests (resolution from a data directory, named
variants, the 100-year key of #363, a key without exp) replace 3
machine-binding tests; vitest covers the card and form renders, the
context revocation, the hook wiring and the locales.
test: reproduces #347 (an expired token of this machine resolved a
valid Base key to free on 5d549d6).
Docs: CHANGELOG FR/EN, guide section 12 and in-app docs,
architecture.md, ADR 0017 amendment for #347, qa-update-cycle.md,
api-contract-prices.md.
Fixes #347
Fixes #360
Refs #363
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { licenseExpiryDisplay, NO_EXPIRY_HORIZON_YEARS } from "./licenseExpiry";
|
|
|
|
const DAY_S = 86400;
|
|
const YEAR_S = 365.25 * DAY_S;
|
|
// Noon UTC: the same calendar day in every time zone the suite runs in (UTC in CI,
|
|
// America/Toronto on a workstation).
|
|
const NOW_S = Date.UTC(2026, 8, 29, 12) / 1000;
|
|
|
|
describe("licenseExpiryDisplay", () => {
|
|
it("shows no date for a 100-year key (maximus-api#63)", () => {
|
|
expect(licenseExpiryDisplay(NOW_S + 36525 * DAY_S, NOW_S, "fr-CA")).toEqual({
|
|
kind: "noExpiry",
|
|
});
|
|
});
|
|
|
|
it("shows the date of a 10-year key, formatted for the given locale", () => {
|
|
const expiresAt = Date.UTC(2036, 8, 26, 12) / 1000;
|
|
expect(licenseExpiryDisplay(expiresAt, NOW_S, "fr-CA")).toEqual({
|
|
kind: "date",
|
|
text: "2036-09-26",
|
|
});
|
|
expect(licenseExpiryDisplay(expiresAt, NOW_S, "en-CA")).toEqual({
|
|
kind: "date",
|
|
text: "2036-09-26",
|
|
});
|
|
});
|
|
|
|
it("keeps a date up to the 50-year horizon and drops it just beyond", () => {
|
|
const horizon = NOW_S + NO_EXPIRY_HORIZON_YEARS * YEAR_S;
|
|
expect(licenseExpiryDisplay(horizon, NOW_S, "fr-CA").kind).toBe("date");
|
|
expect(licenseExpiryDisplay(horizon + DAY_S, NOW_S, "fr-CA").kind).toBe("noExpiry");
|
|
});
|
|
});
|