nixos/tests/vaultwarden: fix UI testing (#408026)

authored by Atemu and committed by GitHub 593fa724 4279efea

+17 -6
+17 -6
nixos/tests/vaultwarden.nix
··· 36 from selenium.webdriver.firefox.options import Options 37 from selenium.webdriver.support.ui import WebDriverWait 38 from selenium.webdriver.support import expected_conditions as EC 39 40 options = Options() 41 options.add_argument('--headless') ··· 74 ) 75 driver.find_element(By.XPATH, "//button[contains(., 'Log in with master password')]").click() 76 77 - wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'button#newItemDropdown'))).click() 78 driver.find_element(By.XPATH, "//button[contains(., 'Item')]").click() 79 80 driver.find_element(By.CSS_SELECTOR, 'input#name').send_keys( ··· 178 testScript 179 else 180 '' 181 start_all() 182 server.wait_for_unit("vaultwarden.service") 183 server.wait_for_open_port(8080) ··· 202 client.succeed(f"bw --nointeraction --raw --session {key} sync -f") 203 204 with subtest("get the password with the cli"): 205 - password = client.wait_until_succeeds( 206 - f"bw --nointeraction --raw --session {key} list items | ${pkgs.jq}/bin/jq -r .[].login.password", 207 - timeout=60 208 - ) 209 - assert password.strip() == "${storedPassword}" 210 211 with subtest("Check systemd unit hardening"): 212 server.log(server.succeed("systemd-analyze security vaultwarden.service | grep -v ✓"))
··· 36 from selenium.webdriver.firefox.options import Options 37 from selenium.webdriver.support.ui import WebDriverWait 38 from selenium.webdriver.support import expected_conditions as EC 39 + from selenium.common.exceptions import ElementClickInterceptedException 40 + 41 + 42 + def click_when_unobstructed(mark): 43 + while True: 44 + try: 45 + wait.until(EC.element_to_be_clickable(mark)).click() 46 + break 47 + except ElementClickInterceptedException: 48 + continue 49 + 50 51 options = Options() 52 options.add_argument('--headless') ··· 85 ) 86 driver.find_element(By.XPATH, "//button[contains(., 'Log in with master password')]").click() 87 88 + click_when_unobstructed((By.CSS_SELECTOR, 'button#newItemDropdown')) 89 driver.find_element(By.XPATH, "//button[contains(., 'Item')]").click() 90 91 driver.find_element(By.CSS_SELECTOR, 'input#name').send_keys( ··· 189 testScript 190 else 191 '' 192 + import json 193 + 194 start_all() 195 server.wait_for_unit("vaultwarden.service") 196 server.wait_for_open_port(8080) ··· 215 client.succeed(f"bw --nointeraction --raw --session {key} sync -f") 216 217 with subtest("get the password with the cli"): 218 + output = json.loads(client.succeed(f"bw --nointeraction --raw --session {key} list items")) 219 + 220 + assert output[0]['login']['password'] == "${storedPassword}" 221 222 with subtest("Check systemd unit hardening"): 223 server.log(server.succeed("systemd-analyze security vaultwarden.service | grep -v ✓"))