Exercise selector validation in a fresh OPNsense VM
This commit is contained in:
parent
707b060501
commit
b6a8e185d8
3 changed files with 42 additions and 18 deletions
|
|
@ -18,6 +18,27 @@ local_user_set_password($root, $password);
|
|||
local_user_set($root, true);
|
||||
write_config('Set disposable WebGUI test password');
|
||||
|
||||
$aliases = new Alias();
|
||||
$existing = [];
|
||||
foreach ($aliases->aliases->alias->iterateItems() as $alias) {
|
||||
$existing[(string)$alias->name] = true;
|
||||
}
|
||||
foreach (['UI_TEST_NETWORK', 'UI_TEST_NETWORK_TWO'] as $name) {
|
||||
if (isset($existing[$name])) {
|
||||
continue;
|
||||
}
|
||||
$alias = $aliases->aliases->alias->add();
|
||||
$alias->setNodes([
|
||||
'enabled' => '1',
|
||||
'name' => $name,
|
||||
'type' => 'network',
|
||||
'proto' => 'IPv4',
|
||||
'content' => $name === 'UI_TEST_NETWORK' ? '192.0.2.0/24' : '198.51.100.0/24',
|
||||
]);
|
||||
}
|
||||
$aliases->serializeToConfig();
|
||||
Config::getInstance()->save(['description' => 'Add synthetic UI test aliases']);
|
||||
|
||||
$users = Config::getInstance()->object()->system->user;
|
||||
foreach ($users as $user) {
|
||||
if ((string)$user->name === 'root' && password_verify($password, (string)$user->password)) {
|
||||
|
|
@ -31,20 +52,3 @@ exec('/usr/local/sbin/configctl webgui restart', $output, $status);
|
|||
if ($status !== 0) {
|
||||
throw new RuntimeException('The WebGUI did not restart.');
|
||||
}
|
||||
|
||||
$aliases = new Alias();
|
||||
foreach ($aliases->aliases->alias->iterateItems() as $alias) {
|
||||
if ((string)$alias->name === 'UI_TEST_NETWORK') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$alias = $aliases->aliases->alias->add();
|
||||
$alias->setNodes([
|
||||
'enabled' => '1',
|
||||
'name' => 'UI_TEST_NETWORK',
|
||||
'type' => 'network',
|
||||
'proto' => 'IPv4',
|
||||
'content' => '192.0.2.0/24',
|
||||
]);
|
||||
$aliases->serializeToConfig();
|
||||
Config::getInstance()->save(['description' => 'Add synthetic UI test alias']);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ cleanup()
|
|||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
rm -f "$runtime_dir/ready" "$runtime_dir/launcher.log"
|
||||
"$script_dir/start-opnsense.sh" > "$runtime_dir/launcher.log" 2>&1 &
|
||||
launcher_pid=$!
|
||||
|
||||
|
|
@ -70,6 +71,7 @@ while ! curl --fail --insecure --silent --connect-timeout 2 "$OPNSENSE_UI_BASE_U
|
|||
}
|
||||
sleep 1
|
||||
done
|
||||
sleep 10
|
||||
|
||||
pnpm --dir "$script_dir" install --frozen-lockfile
|
||||
pnpm --dir "$script_dir" test
|
||||
|
|
|
|||
|
|
@ -68,7 +68,10 @@ test("renders and preserves NordVPN enrollment controls", async ({ page }) => {
|
|||
await page.goto("/");
|
||||
await page.locator("#usernamefld").fill(username);
|
||||
await page.locator("#passwordfld").fill(password);
|
||||
await page.getByRole("button", { name: "Login" }).click();
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: "domcontentloaded" }),
|
||||
page.getByRole("button", { name: "Login" }).click(),
|
||||
]);
|
||||
await expect(page.locator("#usernamefld")).toBeHidden();
|
||||
await page.goto("/ui/nordvpn");
|
||||
await expect(
|
||||
|
|
@ -116,6 +119,9 @@ test("renders and preserves NordVPN enrollment controls", async ({ page }) => {
|
|||
await expect(source.locator('option[value="UI_TEST_NETWORK"]')).toHaveText(
|
||||
"UI_TEST_NETWORK",
|
||||
);
|
||||
await expect(
|
||||
destination.locator('option[value="UI_TEST_NETWORK_TWO"]'),
|
||||
).toHaveText("UI_TEST_NETWORK_TWO");
|
||||
|
||||
const destinationPicker = destination.locator("xpath=..");
|
||||
const destinationToggle = destinationPicker.locator("button.dropdown-toggle");
|
||||
|
|
@ -130,6 +136,18 @@ test("renders and preserves NordVPN enrollment controls", async ({ page }) => {
|
|||
await destinationToggle.click();
|
||||
|
||||
await source.selectOption("UI_TEST_NETWORK");
|
||||
await destination.selectOption([
|
||||
"UI_TEST_NETWORK",
|
||||
"UI_TEST_NETWORK_TWO",
|
||||
]);
|
||||
await dialog.locator('[id="enrollment.destination_not"]').check();
|
||||
await dialog.getByRole("button", { name: "Save", exact: true }).click();
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(dialog).toContainText(
|
||||
"Inverting destinations is only allowed for single targets to avoid mis-interpretations",
|
||||
);
|
||||
|
||||
await dialog.locator('[id="enrollment.destination_not"]').uncheck();
|
||||
await destination.selectOption("any");
|
||||
await dialog.getByRole("button", { name: "Save", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
|
|
|
|||
Loading…
Reference in a new issue