EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
test-mesh-simple.js
Go to the documentation of this file.
1/**
2 * Simple test to verify MeshCentral login works
3 */
4
5const https = require('https');
6
7// Try login with credentials from .env
8const credentials = {
9 username: '~t:2jt4e92jNss43lyJ',
10 password: '2GimaJ6MJDlq6P2Jrsso'
11};
12
13console.log('🔐 Testing MeshCentral login...');
14console.log('URL: https://209.38.80.86:4430');
15console.log('Username:', credentials.username);
16console.log('');
17
18const postData = JSON.stringify(credentials);
19
20const options = {
21 hostname: '209.38.80.86',
22 port: 4430,
23 path: '/login',
24 method: 'POST',
25 headers: {
26 'Content-Type': 'application/json',
27 'Content-Length': Buffer.byteLength(postData)
28 },
29 rejectUnauthorized: false,
30 timeout: 5000
31};
32
33const req = https.request(options, (res) => {
34 console.log('📊 Status:', res.statusCode);
35
36 let body = '';
37 res.on('data', (chunk) => body += chunk);
38
39 res.on('end', () => {
40 console.log('📄 Response:', body.substring(0, 200));
41 console.log('');
42
43 if (res.headers['set-cookie']) {
44 console.log('✅ Login successful! Cookie received.');
45 console.log('🍪 Cookie:', res.headers['set-cookie'][0].substring(0, 80) + '...');
46 process.exit(0);
47 } else if (res.statusCode === 200) {
48 console.log('✅ Got 200 response but no cookie');
49 console.log('💡 This might mean the account exists but login format is different');
50 process.exit(0);
51 } else {
52 console.log('❌ Login failed - no cookie received');
53 console.log('💡 Account might not exist or credentials are incorrect');
54 process.exit(1);
55 }
56 });
57});
58
59req.on('error', (e) => {
60 console.error('❌ Request error:', e.message);
61 process.exit(1);
62});
63
64req.on('timeout', () => {
65 console.error('❌ Request timeout');
66 req.destroy();
67 process.exit(1);
68});
69
70req.write(postData);
71req.end();