mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
nixos/tests/vaultwarden: fix UI testing
This patch fixes a failure in the Selenium UI testing script by waiting for an element to be clickable. This allows the Angular to render properly.
This commit is contained in:
parent
0b4a58a83d
commit
94e7e3f350
1 changed files with 17 additions and 6 deletions
|
@ -36,6 +36,17 @@ let
|
||||||
from selenium.webdriver.firefox.options import Options
|
from selenium.webdriver.firefox.options import Options
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.common.exceptions import ElementClickInterceptedException
|
||||||
|
|
||||||
|
|
||||||
|
def click_when_unobstructed(mark):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
wait.until(EC.element_to_be_clickable(mark)).click()
|
||||||
|
break
|
||||||
|
except ElementClickInterceptedException:
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
options = Options()
|
options = Options()
|
||||||
options.add_argument('--headless')
|
options.add_argument('--headless')
|
||||||
|
@ -74,7 +85,7 @@ let
|
||||||
)
|
)
|
||||||
driver.find_element(By.XPATH, "//button[contains(., 'Log in with master password')]").click()
|
driver.find_element(By.XPATH, "//button[contains(., 'Log in with master password')]").click()
|
||||||
|
|
||||||
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'button#newItemDropdown'))).click()
|
click_when_unobstructed((By.CSS_SELECTOR, 'button#newItemDropdown'))
|
||||||
driver.find_element(By.XPATH, "//button[contains(., 'Item')]").click()
|
driver.find_element(By.XPATH, "//button[contains(., 'Item')]").click()
|
||||||
|
|
||||||
driver.find_element(By.CSS_SELECTOR, 'input#name').send_keys(
|
driver.find_element(By.CSS_SELECTOR, 'input#name').send_keys(
|
||||||
|
@ -178,6 +189,8 @@ let
|
||||||
testScript
|
testScript
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
|
import json
|
||||||
|
|
||||||
start_all()
|
start_all()
|
||||||
server.wait_for_unit("vaultwarden.service")
|
server.wait_for_unit("vaultwarden.service")
|
||||||
server.wait_for_open_port(8080)
|
server.wait_for_open_port(8080)
|
||||||
|
@ -202,11 +215,9 @@ let
|
||||||
client.succeed(f"bw --nointeraction --raw --session {key} sync -f")
|
client.succeed(f"bw --nointeraction --raw --session {key} sync -f")
|
||||||
|
|
||||||
with subtest("get the password with the cli"):
|
with subtest("get the password with the cli"):
|
||||||
password = client.wait_until_succeeds(
|
output = json.loads(client.succeed(f"bw --nointeraction --raw --session {key} list items"))
|
||||||
f"bw --nointeraction --raw --session {key} list items | ${pkgs.jq}/bin/jq -r .[].login.password",
|
|
||||||
timeout=60
|
assert output[0]['login']['password'] == "${storedPassword}"
|
||||||
)
|
|
||||||
assert password.strip() == "${storedPassword}"
|
|
||||||
|
|
||||||
with subtest("Check systemd unit hardening"):
|
with subtest("Check systemd unit hardening"):
|
||||||
server.log(server.succeed("systemd-analyze security vaultwarden.service | grep -v ✓"))
|
server.log(server.succeed("systemd-analyze security vaultwarden.service | grep -v ✓"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue