require('dotenv').config();
const mikrotik = require('./services/mikrotikService');

async function test() {
    console.log("Testing Mikrotik Connection (node-routeros)...");
    try {
        console.log(`Connecting to ${process.env.MIKROTIK_HOST}...`);

        console.log("1. Get System Resource:");
        const resource = await mikrotik.getSystemResource();
        console.log("Result:", resource);

        // console.log("\n2. Get Active Hotspot Users (Expect [] if none):");
        // const hsUsers = await mikrotik.getActiveHotspot();
        // console.log(`Found ${hsUsers.length} active hotspot users.`);

        console.log("\n3. Get PPPoE Secrets (Expect list):");
        const pppoeSecrets = await mikrotik.getPppoeSecrets();
        console.log(`Found ${pppoeSecrets.length} PPPoE secrets.`);
        if (pppoeSecrets.length > 0) console.log("Example:", pppoeSecrets[0]);

        console.log("\n4. Get Active PPPoE Users:");
        const pppoeActive = await mikrotik.getActivePppoe();
        console.log(`Found ${pppoeActive.length} active PPPoE users.`);
        if (pppoeActive.length > 0) console.log("Example:", pppoeActive[0]);

        console.log("\nTest Successful!");
    } catch (error) {
        console.error("Test Failed:", error);
    }
}

test();
