adjust test data
This commit is contained in:
1
client/playwright.config.ts
vendored
1
client/playwright.config.ts
vendored
@@ -8,6 +8,7 @@ import path from 'path';
|
||||
export default defineConfig({
|
||||
testDir: './tests/e2e',
|
||||
globalSetup: path.resolve('./tests/e2e/globalSetup.ts'),
|
||||
timeout: 5000,
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { ADMIN_PASSWORD, ADMIN_USERNAME } from '../constants';
|
||||
import { getDHCPConfig } from '../helpers/network';
|
||||
|
||||
const INTERFACE_NAME = 'en0';
|
||||
const RANGE_START = '192.168.1.100';
|
||||
const RANGE_END = '192.168.1.200';
|
||||
const SUBNET_MASK = '255.255.255.0';
|
||||
const dhcpConfig = getDHCPConfig();
|
||||
const INTERFACE_NAME = dhcpConfig.interfaceName;
|
||||
const RANGE_START = dhcpConfig.rangeStart;
|
||||
const RANGE_END = dhcpConfig.rangeEnd;
|
||||
const SUBNET_MASK = dhcpConfig.subnetMask;
|
||||
const LEASE_TIME = '86400';
|
||||
|
||||
test.describe('DHCP Configuration', () => {
|
||||
|
||||
38
client/tests/helpers/network.ts
Normal file
38
client/tests/helpers/network.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { networkInterfaces } from 'os';
|
||||
|
||||
interface DHCPConfig {
|
||||
interfaceName: string;
|
||||
rangeStart: string;
|
||||
rangeEnd: string;
|
||||
subnetMask: string;
|
||||
}
|
||||
|
||||
export function getDHCPConfig(): DHCPConfig {
|
||||
const interfaces = networkInterfaces();
|
||||
for (const [name, addresses] of Object.entries(interfaces)) {
|
||||
const ipv4Address = addresses?.find((addr) => addr.family === 'IPv4' && !addr.internal);
|
||||
if (ipv4Address) {
|
||||
const ip = ipv4Address.address.split('.').map(Number);
|
||||
const mask = ipv4Address.netmask?.split('.').map(Number) || [255, 255, 255, 0];
|
||||
|
||||
// Calculate network address
|
||||
const network = ip.map((octet, i) => octet & mask[i]);
|
||||
|
||||
// Calculate first and last usable addresses (excluding network and broadcast)
|
||||
const rangeStart = [...network];
|
||||
rangeStart[3] = network[3] + 1;
|
||||
|
||||
const broadcast = network.map((octet, i) => octet | (~mask[i] & 255));
|
||||
const rangeEnd = [...broadcast];
|
||||
rangeEnd[3] = broadcast[3] - 1;
|
||||
|
||||
return {
|
||||
interfaceName: name,
|
||||
rangeStart: rangeStart.join('.'),
|
||||
rangeEnd: rangeEnd.join('.'),
|
||||
subnetMask: ipv4Address.netmask || '255.255.255.0',
|
||||
};
|
||||
}
|
||||
}
|
||||
throw new Error('No suitable network interface found');
|
||||
}
|
||||
Reference in New Issue
Block a user