Heimdall Gitea / Detect CI scope (push) Successful in 5s
Heimdall Gitea / Build and tests (push) Successful in 17m45s
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / CI policy (push) Successful in 3s
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish versioned installer release (push) Skipped
Co-authored-by: Arnaud Dartois <admin@tordais.cc>
37 lines
1.6 KiB
JavaScript
37 lines
1.6 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { checkGiteaAccess, validateEndpoint } from './renovate-preflight.mjs';
|
|
|
|
test('accepts an HTTPS Forgejo API endpoint and trims its trailing slash', () => {
|
|
assert.equal(validateEndpoint('https://forge.example/api/v1/'), 'https://forge.example/api/v1');
|
|
});
|
|
|
|
test('rejects non-HTTPS, malformed, and non-API endpoints', () => {
|
|
for (const value of ['http://forge.example/api/v1', 'https://forge.example/', 'not a URL']) {
|
|
assert.throws(() => validateEndpoint(value), /FORGEJO_API_ENDPOINT.*HTTPS URL ending in \/api\/v1/);
|
|
}
|
|
});
|
|
|
|
test('checks identity and repository reads without exposing the token', async () => {
|
|
const calls = [];
|
|
await checkGiteaAccess('https://forge.example/api/v1', 'secret-token', async (url, options) => {
|
|
calls.push({ url: url.href, authorization: options.headers.Authorization });
|
|
return { ok: true, status: 200 };
|
|
});
|
|
assert.deepEqual(calls.map(call => new URL(call.url).pathname), [
|
|
'/api/v1/user', '/api/v1/repos/arnaud.dartois/Heimdall',
|
|
]);
|
|
assert.ok(calls.every(call => call.authorization === 'token secret-token'));
|
|
});
|
|
|
|
test('reports authentication status without printing response details or credentials', async () => {
|
|
await assert.rejects(
|
|
checkGiteaAccess('https://forge.example/api/v1', 'secret-token', async () => ({
|
|
ok: false, status: 403,
|
|
})),
|
|
error => error.message.includes('HTTP 403') &&
|
|
error.message.includes('repository read and write access') &&
|
|
!error.message.includes('secret-token'),
|
|
);
|
|
});
|