47 lines
1.3 KiB
TypeScript
Executable File
47 lines
1.3 KiB
TypeScript
Executable File
#!/usr/bin/env ts-node
|
|
/**
|
|
* Test script to verify Omada authentication
|
|
* Usage: npx ts-node scripts/test-auth.ts
|
|
*/
|
|
|
|
import { login } from '../src/services/authService';
|
|
import { listSites } from '../src/services/siteService';
|
|
|
|
async function testAuthentication() {
|
|
try {
|
|
console.log('Testing Omada Cloud authentication...\n');
|
|
|
|
// Test login
|
|
console.log('1. Testing login...');
|
|
const token = await login();
|
|
console.log('✅ Login successful!');
|
|
console.log(` Token: ${token.substring(0, 20)}...\n`);
|
|
|
|
// Test API call
|
|
console.log('2. Testing API call (fetching sites)...');
|
|
const sites = await listSites();
|
|
console.log(`✅ API call successful!`);
|
|
console.log(` Found ${sites.length} site(s):`);
|
|
sites.forEach((site, index) => {
|
|
console.log(` ${index + 1}. ${site.name} (ID: ${site.id || site.siteId})`);
|
|
});
|
|
|
|
console.log('\n✅ All tests passed!');
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('\n❌ Test failed:');
|
|
if (error instanceof Error) {
|
|
console.error(` ${error.message}`);
|
|
if (error.stack) {
|
|
console.error(`\n Stack trace:\n ${error.stack.split('\n').slice(1).join('\n ')}`);
|
|
}
|
|
} else {
|
|
console.error(' Unknown error:', error);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
testAuthentication();
|
|
|