47 lines
2.1 KiB
JavaScript
47 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Test script for Organization Authentication functionality
|
|
* This script tests the new organization authentication features:
|
|
* 1. Get organization login URL
|
|
* 2. Process third-party authentication callback
|
|
* 3. Login with organization reauthentication check
|
|
*/
|
|
|
|
const { container } = require('./dist/Application/Services/DIContainer.js');
|
|
|
|
async function testOrganizationAuth() {
|
|
console.log('🧪 Testing Organization Authentication Functionality\n');
|
|
|
|
try {
|
|
// Test 1: Get Organization Login URL
|
|
console.log('1️⃣ Testing Get Organization Login URL Query Handler');
|
|
const getUrlHandler = container.getOrganizationLoginUrlQueryHandler;
|
|
console.log('✅ Handler instantiated successfully');
|
|
|
|
// Test 2: Process Organization Auth Callback
|
|
console.log('2️⃣ Testing Process Organization Auth Callback Command Handler');
|
|
const callbackHandler = container.processOrgAuthCallbackCommandHandler;
|
|
console.log('✅ Handler instantiated successfully');
|
|
|
|
// Test 3: Enhanced Login Handler with Organization Repository
|
|
console.log('3️⃣ Testing Enhanced Login Handler');
|
|
const loginHandler = container.loginCommandHandler;
|
|
console.log('✅ Enhanced login handler instantiated successfully');
|
|
|
|
console.log('\n🎉 All Organization Authentication components initialized successfully!');
|
|
console.log('\n📋 Summary of new functionality:');
|
|
console.log(' • GET /api/organizations/:orgId/login-url - Get organization third-party login URL');
|
|
console.log(' • POST /api/organizations/auth-callback - Process third-party authentication result');
|
|
console.log(' • Enhanced login response includes organization reauthentication requirements');
|
|
console.log(' • Users must reauthenticate with organization if last login > 1 month ago');
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error testing organization authentication:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Run the test
|
|
testOrganizationAuth();
|