docs: record auth hash alignment and validation results

This commit is contained in:
Gabriel20xx committed 2026-10-20 15:26:58 +00:00
1 parent 22887fef03
commit f7819904b9
51 files changed
+1792 -542

No files matched your search

+28 -4
View File
@@ -1,6 +1,13 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { Info, Store, internalSecretMatches } from '../src/coreconfig.js';
import {
EXAMPLE_INTERNAL_SECRETS,
Info,
MIN_INTERNAL_SECRET_LENGTH,
Store,
internalSecretMatches,
internalSecretUsable,
} from '../src/coreconfig.js';
test('store seeds from the fallback Info', () => {
const store = new Store({ authGuardUrl: 'http://auth.example.com', carrierNodeUrl: 'http://carrier.example.com' });
@@ -49,13 +56,30 @@ test('Info.fromJSON/toJSON round-trip the wire shape', () => {
assert.equal(info.toJSON().carrierNodeUrl, 'http://carrier.example.com');
});
const LONG_SECRET = 'shared-secret-value';
test('internal secret check fails closed when the secret is unset or empty', () => {
assert.equal(internalSecretMatches(undefined, undefined), false);
assert.equal(internalSecretMatches(undefined, ''), false);
assert.equal(internalSecretMatches('', ''), false);
assert.equal(internalSecretMatches(undefined, 'shared-secret'), false);
assert.equal(internalSecretMatches('shared-secreT', 'shared-secret'), false);
assert.equal(internalSecretMatches('shared-secret', 'shared-secret'), true);
assert.equal(internalSecretMatches(undefined, LONG_SECRET), false);
assert.equal(internalSecretMatches('shared-secret-valuE', LONG_SECRET), false);
assert.equal(internalSecretMatches(LONG_SECRET, LONG_SECRET), true);
});
test('internal secret check refuses a short or placeholder secret', () => {
const short = 'x'.repeat(MIN_INTERNAL_SECRET_LENGTH - 1);
assert.equal(internalSecretMatches(short, short), false);
for (const placeholder of EXAMPLE_INTERNAL_SECRETS) {
assert.equal(internalSecretMatches(placeholder, placeholder), false, placeholder);
}
});
test('internal secret usability needs the minimum length and no placeholder', () => {
assert.equal(internalSecretUsable('x'.repeat(MIN_INTERNAL_SECRET_LENGTH - 1)), false);
assert.equal(internalSecretUsable('x'.repeat(MIN_INTERNAL_SECRET_LENGTH)), true);
assert.equal(internalSecretUsable('change-me-to-a-long-random-value'), false);
assert.equal(internalSecretUsable(undefined), false);
});
test('set rejects a URL that is not an http or https URL and changes nothing', () => {