feat(unifi): implement comprehensive UniFi API client with controllers, protect, access, account, managers, resources, HTTP client, interfaces, logging, plugins, and tests

This commit is contained in:
2026-02-02 15:46:41 +00:00
parent aaa9e67835
commit 740b70cd83
38 changed files with 6275 additions and 15 deletions

42
test/test.site.ts Normal file
View File

@@ -0,0 +1,42 @@
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();