forked from democratize-technology/vikunja-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-auth-errors.js
More file actions
104 lines (85 loc) · 3.22 KB
/
Copy pathtest-auth-errors.js
File metadata and controls
104 lines (85 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env node
/**
* Final DX Evaluation - Test Enhanced Authentication Errors
* Tests if authentication errors provide step-by-step guidance
*/
const { spawn } = require('child_process');
const path = require('path');
async function testAuthenticationErrors() {
console.log('\n🔐 TESTING ENHANCED AUTHENTICATION ERRORS');
console.log('=' .repeat(60));
const serverProcess = spawn('node', ['dist/index.js'], {
cwd: process.cwd(),
env: {
...process.env,
VIKUNJA_URL: 'https://vikunja.erinjeremy.com/api/v1',
VIKUNJA_API_TOKEN: 'invalid-token-format' // Force auth error
},
stdio: ['pipe', 'pipe', 'pipe']
});
let serverOutput = '';
let serverReady = false;
serverProcess.stdout.on('data', (data) => {
const output = data.toString();
serverOutput += output;
console.log('Server:', output.trim());
if (output.includes('MCP server running') || output.includes('successfully')) {
serverReady = true;
}
});
serverProcess.stderr.on('data', (data) => {
console.log('Server Error:', data.toString().trim());
});
// Wait for server to be ready
await new Promise(resolve => setTimeout(resolve, 3000));
if (serverReady) {
console.log('\n✅ Server ready with invalid token - Testing enhanced error messages...\n');
// Simulate MCP tool call to trigger authentication error
const testRequest = {
jsonrpc: "2.0",
id: 1,
method: "tools/call",
params: {
name: "vikunja_tasks",
arguments: {
subcommand: "list",
project_id: 1
}
}
};
serverProcess.stdin.write(JSON.stringify(testRequest) + '\n');
// Wait for error response
await new Promise(resolve => setTimeout(resolve, 2000));
}
// Analyze error output for enhanced guidance
const hasStepByStepGuidance = serverOutput.includes('step') ||
serverOutput.includes('follow') ||
serverOutput.includes('1.') ||
serverOutput.includes('2.') ||
serverOutput.includes('check');
const hasClearInstructions = serverOutput.includes('token') &&
serverOutput.includes('format') &&
serverOutput.includes('URL');
console.log('\n📊 AUTHENTICATION ERROR ANALYSIS:');
console.log(`- Step-by-step guidance: ${hasStepByStepGuidance ? '✅ YES' : '❌ NO'}`);
console.log(`- Clear instructions: ${hasClearInstructions ? '✅ YES' : '❌ NO'}`);
console.log(`- Error detail quality: ${serverOutput.length > 100 ? '✅ DETAILED' : '❌ MINIMAL'}`);
serverProcess.kill();
return {
stepByStepGuidance: hasStepByStepGuidance,
clearInstructions: hasClearInstructions,
errorQuality: serverOutput.length > 100,
outputLength: serverOutput.length
};
}
// Execute test
testAuthenticationErrors()
.then(results => {
console.log('\n🎯 AUTHENTICATION ERROR SCORE:',
Object.values(results).filter(Boolean).length / Object.keys(results).length * 100, '%');
process.exit(results.stepByStepGuidance && results.clearInstructions ? 0 : 1);
})
.catch(error => {
console.error('❌ Test failed:', error);
process.exit(1);
});