#!/usr/bin/env node /** * Test Provider authentication and endpoints */ import { ConfigManager } from './src/config/ConfigManager.js'; import { ToolGenerator } from './src/tools/ToolGenerator.js'; import { PUBLIC_ENDPOINTS, PROVIDER_ENDPOINTS, AUTH_TYPES } from './src/config/endpoints.js'; async function testProviderFeatures() { console.log('๐Ÿงช Provider Authentication Test\n'); try { // Test 1: Environment setup with Provider credentials console.log('1. Testing Provider environment setup...'); process.env.LARAVEL_API_BASE_URL = 'https://example.com'; process.env.PROVIDER_USERNAME = 'test@provider.com'; process.env.PROVIDER_PASSWORD = 'testpass'; console.log('โœ… Provider environment variables set'); // Test 2: Configuration loading console.log('2. Testing configuration with Provider...'); const config = new ConfigManager(); console.log('โœ… Configuration loaded successfully'); console.log(` Provider Username: ${config.get('PROVIDER_USERNAME')}`); console.log(` Provider Endpoint: ${config.get('PROVIDER_LOGIN_ENDPOINT')}`); // Test 3: Endpoint registry console.log('3. Testing endpoint registries...'); console.log(`โœ… ${PUBLIC_ENDPOINTS.length} public endpoints loaded`); console.log(`โœ… ${PROVIDER_ENDPOINTS.length} provider endpoints loaded`); // List provider endpoints console.log(' Provider endpoints:'); PROVIDER_ENDPOINTS.forEach((endpoint, index) => { console.log(` ${index + 1}. ${endpoint.method} ${endpoint.path} - ${endpoint.description}`); }); // Test 4: Tool generation with Provider console.log('4. Testing tool generation with Provider...'); const mockApiClient = { get: () => Promise.resolve({}), post: () => Promise.resolve({}), put: () => Promise.resolve({}), delete: () => Promise.resolve({}), patch: () => Promise.resolve({}) }; const toolGenerator = new ToolGenerator(mockApiClient); const tools = toolGenerator.generateAllTools(); console.log(`โœ… ${tools.length} total MCP tools generated`); // Count tools by auth type const publicTools = tools.filter(tool => { const toolDef = toolGenerator.getTool(tool.name); return toolDef && toolDef.authType === AUTH_TYPES.PUBLIC; }); const providerTools = tools.filter(tool => { const toolDef = toolGenerator.getTool(tool.name); return toolDef && toolDef.authType === AUTH_TYPES.PROVIDER; }); console.log(` โ€ข Public tools: ${publicTools.length}`); console.log(` โ€ข Provider tools: ${providerTools.length}`); // Test 5: Provider tool structure console.log('5. Testing Provider tool structure...'); if (providerTools.length > 0) { const firstProviderTool = providerTools[0]; console.log(`โœ… Sample Provider tool: ${firstProviderTool.name}`); console.log(` Description: ${firstProviderTool.description}`); // List all provider tools console.log(' All Provider tools:'); providerTools.forEach((tool, index) => { console.log(` ${index + 1}. ${tool.name}`); }); } else { throw new Error('No Provider tools generated'); } // Test 6: Authentication types console.log('6. Testing authentication types...'); const summary = config.getSummary(); console.log(`โœ… Total auth types configured: ${summary.authTypesConfigured.length}`); console.log(` Configured types: ${summary.authTypesConfigured.join(', ')}`); console.log('\n๐ŸŽ‰ All Provider tests passed!'); console.log('\n๐Ÿ“‹ Provider Summary:'); console.log(` โ€ข Provider Endpoints: โœ… ${PROVIDER_ENDPOINTS.length} endpoints`); console.log(` โ€ข Provider Tools: โœ… ${providerTools.length} MCP tools`); console.log(` โ€ข Authentication: โœ… Provider auth type supported`); console.log(` โ€ข Total Tools: โœ… ${tools.length} (${publicTools.length} public + ${providerTools.length} provider)`); console.log('\n๐Ÿš€ Provider authentication is ready!'); console.log('\nProvider tools available:'); providerTools.forEach(tool => { console.log(` โ€ข ${tool.name}: ${tool.description}`); }); } catch (error) { console.error('\nโŒ Provider test failed:', error.message); console.error('Stack trace:', error.stack); process.exit(1); } } testProviderFeatures();