28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import type { SmartRegistry } from '../../ts/classes.smartregistry.js';
|
|
|
|
/**
|
|
* Helper to create test authentication tokens.
|
|
*/
|
|
export async function createTestTokens(registry: SmartRegistry) {
|
|
const authManager = registry.getAuthManager();
|
|
|
|
const userId = await authManager.authenticate({
|
|
username: 'testuser',
|
|
password: 'testpass',
|
|
});
|
|
|
|
if (!userId) {
|
|
throw new Error('Failed to authenticate test user');
|
|
}
|
|
|
|
const npmToken = await authManager.createNpmToken(userId, false);
|
|
const ociToken = await authManager.createOciToken(userId, ['oci:repository:*:*'], 3600);
|
|
const mavenToken = await authManager.createMavenToken(userId, false);
|
|
const composerToken = await authManager.createComposerToken(userId, false);
|
|
const cargoToken = await authManager.createCargoToken(userId, false);
|
|
const pypiToken = await authManager.createPypiToken(userId, false);
|
|
const rubygemsToken = await authManager.createRubyGemsToken(userId, false);
|
|
|
|
return { npmToken, ociToken, mavenToken, composerToken, cargoToken, pypiToken, rubygemsToken, userId };
|
|
}
|