43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
import { Qenv } from '@push.rocks/qenv';
|
|
import * as unifi from '../ts/index.js';
|
|
|
|
// =============================================================================
|
|
// SITE API INTEGRATION TESTS (Local Controller)
|
|
// Tests may use live production keys to test specific features at scale.
|
|
// Make sure to avoid dangerous, destructive or security relevant operations.
|
|
// =============================================================================
|
|
|
|
const testQenv = new Qenv('./', './.nogit/');
|
|
|
|
let testController: unifi.UnifiController;
|
|
|
|
tap.test('setup - create UnifiController with API key', async () => {
|
|
const host = await testQenv.getEnvVarOnDemand('UNIFI_CONSOLE_IP');
|
|
const apiKey = await testQenv.getEnvVarOnDemand('UNIFI_NETWORK_DEV_KEY');
|
|
|
|
testController = new unifi.UnifiController({
|
|
host,
|
|
apiKey,
|
|
controllerType: 'unifi-os',
|
|
verifySsl: false,
|
|
});
|
|
|
|
expect(testController.isAuthenticated()).toBeTrue();
|
|
console.log('UnifiController created with API key authentication');
|
|
});
|
|
|
|
// READ-ONLY: List sites
|
|
tap.test('READ-ONLY - should list sites', async () => {
|
|
const sites = await testController.listSites();
|
|
|
|
console.log(`Found ${sites.length} sites`);
|
|
expect(sites).toBeArray();
|
|
|
|
for (const site of sites) {
|
|
console.log(` - Site: ${site.name} (${site._id})`);
|
|
}
|
|
});
|
|
|
|
export default tap.start();
|