Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management.
- Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods.
- Added tests for the Session model, focusing on session creation, validation, and invalidation.
- Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly.
- Implemented AuthService tests, validating login, token refresh, and session management.
- Added TokenService tests, covering token creation, validation, and revocation processes.
2025-11-28 15:27:04 +00:00
|
|
|
/**
|
|
|
|
|
* Test configuration for Stack.Gallery Registry tests
|
2026-03-20 13:56:43 +00:00
|
|
|
* Uses @push.rocks/qenv to read from .nogit/env.json
|
Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management.
- Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods.
- Added tests for the Session model, focusing on session creation, validation, and invalidation.
- Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly.
- Implemented AuthService tests, validating login, token refresh, and session management.
- Added TokenService tests, covering token creation, validation, and revocation processes.
2025-11-28 15:27:04 +00:00
|
|
|
*/
|
|
|
|
|
|
2026-03-20 13:56:43 +00:00
|
|
|
import { Qenv } from '@push.rocks/qenv';
|
|
|
|
|
|
|
|
|
|
const testQenv = new Qenv('./', '.nogit/', false);
|
|
|
|
|
|
2026-03-20 16:43:44 +00:00
|
|
|
const mongoUrl = await testQenv.getEnvVarOnDemand('MONGODB_URL') ||
|
|
|
|
|
'mongodb://testadmin:testpass@localhost:27117/test-registry?authSource=admin';
|
|
|
|
|
const mongoName = await testQenv.getEnvVarOnDemand('MONGODB_NAME') ||
|
|
|
|
|
'test-registry';
|
2026-03-20 13:56:43 +00:00
|
|
|
|
|
|
|
|
const s3Endpoint = await testQenv.getEnvVarOnDemand('S3_ENDPOINT') || 'localhost';
|
|
|
|
|
const s3Port = await testQenv.getEnvVarOnDemand('S3_PORT') || '9100';
|
|
|
|
|
const s3AccessKey = await testQenv.getEnvVarOnDemand('S3_ACCESSKEY') || 'testadmin';
|
|
|
|
|
const s3SecretKey = await testQenv.getEnvVarOnDemand('S3_SECRETKEY') || 'testpassword';
|
|
|
|
|
const s3Bucket = await testQenv.getEnvVarOnDemand('S3_BUCKET') || 'test-registry';
|
|
|
|
|
const s3UseSsl = await testQenv.getEnvVarOnDemand('S3_USESSL');
|
|
|
|
|
|
|
|
|
|
const s3Protocol = s3UseSsl === 'true' ? 'https' : 'http';
|
|
|
|
|
const s3EndpointUrl = `${s3Protocol}://${s3Endpoint}:${s3Port}`;
|
|
|
|
|
|
Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management.
- Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods.
- Added tests for the Session model, focusing on session creation, validation, and invalidation.
- Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly.
- Implemented AuthService tests, validating login, token refresh, and session management.
- Added TokenService tests, covering token creation, validation, and revocation processes.
2025-11-28 15:27:04 +00:00
|
|
|
export const testConfig = {
|
|
|
|
|
mongodb: {
|
2026-03-20 13:56:43 +00:00
|
|
|
url: mongoUrl,
|
|
|
|
|
name: mongoName,
|
Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management.
- Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods.
- Added tests for the Session model, focusing on session creation, validation, and invalidation.
- Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly.
- Implemented AuthService tests, validating login, token refresh, and session management.
- Added TokenService tests, covering token creation, validation, and revocation processes.
2025-11-28 15:27:04 +00:00
|
|
|
},
|
|
|
|
|
s3: {
|
2026-03-20 13:56:43 +00:00
|
|
|
endpoint: s3EndpointUrl,
|
|
|
|
|
accessKey: s3AccessKey,
|
|
|
|
|
secretKey: s3SecretKey,
|
|
|
|
|
bucket: s3Bucket,
|
Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management.
- Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods.
- Added tests for the Session model, focusing on session creation, validation, and invalidation.
- Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly.
- Implemented AuthService tests, validating login, token refresh, and session management.
- Added TokenService tests, covering token creation, validation, and revocation processes.
2025-11-28 15:27:04 +00:00
|
|
|
region: 'us-east-1',
|
|
|
|
|
},
|
|
|
|
|
jwt: {
|
|
|
|
|
secret: 'test-jwt-secret-for-testing-only',
|
|
|
|
|
refreshSecret: 'test-refresh-secret-for-testing-only',
|
|
|
|
|
},
|
|
|
|
|
registry: {
|
|
|
|
|
url: 'http://localhost:3000',
|
|
|
|
|
port: 3000,
|
|
|
|
|
},
|
|
|
|
|
testUser: {
|
|
|
|
|
email: 'test@stack.gallery',
|
|
|
|
|
password: 'TestPassword123!',
|
|
|
|
|
username: 'testuser',
|
|
|
|
|
},
|
|
|
|
|
adminUser: {
|
|
|
|
|
email: 'admin@stack.gallery',
|
|
|
|
|
password: 'admin',
|
|
|
|
|
username: 'admin',
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2026-03-20 13:56:43 +00:00
|
|
|
* Get test config (kept for backward compatibility)
|
Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management.
- Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods.
- Added tests for the Session model, focusing on session creation, validation, and invalidation.
- Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly.
- Implemented AuthService tests, validating login, token refresh, and session management.
- Added TokenService tests, covering token creation, validation, and revocation processes.
2025-11-28 15:27:04 +00:00
|
|
|
*/
|
|
|
|
|
export function getTestConfig() {
|
2026-03-20 13:56:43 +00:00
|
|
|
return testConfig;
|
Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management.
- Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods.
- Added tests for the Session model, focusing on session creation, validation, and invalidation.
- Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly.
- Implemented AuthService tests, validating login, token refresh, and session management.
- Added TokenService tests, covering token creation, validation, and revocation processes.
2025-11-28 15:27:04 +00:00
|
|
|
}
|