import dotenv from 'dotenv';
dotenv.config();
export interface TestCredentials {
username: string;
password: string;
}
export function getCredentialsFromEnv(): TestCredentials | null {
const username = process.env.UMBRELLA_USERNAME;
const password = process.env.UMBRELLA_PASSWORD;
if (!username || !password) {
console.error('❌ Missing credentials: Please set UMBRELLA_USERNAME and UMBRELLA_PASSWORD environment variables');
console.error(' Example: UMBRELLA_USERNAME=your-email@domain.com UMBRELLA_PASSWORD=your-password');
console.error(' Or create a .env file with these values');
return null;
}
return { username, password };
}
export function getTestCredentialSets(): TestCredentials[] | null {
// Check if specific test credentials are provided
const mspUsername = process.env.UMBRELLA_TEST_MSP_USERNAME;
const mspPassword = process.env.UMBRELLA_TEST_MSP_PASSWORD;
const directUsername = process.env.UMBRELLA_TEST_DIRECT_USERNAME;
const directPassword = process.env.UMBRELLA_TEST_DIRECT_PASSWORD;
const credentials: TestCredentials[] = [];
if (mspUsername && mspPassword) {
credentials.push({ username: mspUsername, password: mspPassword });
}
if (directUsername && directPassword) {
credentials.push({ username: directUsername, password: directPassword });
}
// If no specific test credentials, use the main credentials
if (credentials.length === 0) {
const mainCreds = getCredentialsFromEnv();
if (mainCreds) {
credentials.push(mainCreds);
}
}
if (credentials.length === 0) {
console.error('❌ No test credentials found. Please set environment variables:');
console.error(' - UMBRELLA_USERNAME and UMBRELLA_PASSWORD (for single account)');
console.error(' - OR UMBRELLA_TEST_MSP_USERNAME and UMBRELLA_TEST_MSP_PASSWORD');
console.error(' - AND/OR UMBRELLA_TEST_DIRECT_USERNAME and UMBRELLA_TEST_DIRECT_PASSWORD');
return null;
}
return credentials;
}