1 import ./make-test-python.nix ({ pkgs, lib, ... }:
4 meta = with lib.maintainers; {
5 maintainers = [ alexoundos misuzu ];
7 nodes.castopod = { nodes, ... }: {
8 networking.firewall.allowedTCPPorts = [ 80 ];
9 networking.extraHosts = ''
10 127.0.0.1 castopod.example.com
14 database.createLocally = true;
15 localDomain = "castopod.example.com";
17 environment.systemPackages =
20 email = "admin@castood.example.com";
21 password = "v82HmEp5";
22 testRunner = pkgs.writers.writePython3Bin "test-runner"
24 libraries = [ pkgs.python3Packages.selenium ];
29 from selenium.webdriver.common.by import By
30 from selenium.webdriver import Firefox
31 from selenium.webdriver.firefox.options import Options
32 from selenium.webdriver.support.ui import WebDriverWait
33 from selenium.webdriver.support import expected_conditions as EC
36 options.add_argument('--headless')
37 driver = Firefox(options=options)
39 driver.implicitly_wait(20)
40 driver.get('http://castopod.example.com/cp-install')
42 wait = WebDriverWait(driver, 10)
44 wait.until(EC.title_contains("installer"))
46 driver.find_element(By.CSS_SELECTOR, '#username').send_keys(
49 driver.find_element(By.CSS_SELECTOR, '#email').send_keys(
52 driver.find_element(By.CSS_SELECTOR, '#password').send_keys(
55 driver.find_element(By.XPATH, "//button[contains(., 'Finish install')]").click()
57 wait.until(EC.title_contains("Auth"))
59 driver.find_element(By.CSS_SELECTOR, '#email').send_keys(
62 driver.find_element(By.CSS_SELECTOR, '#password').send_keys(
65 driver.find_element(By.XPATH, "//button[contains(., 'Login')]").click()
67 wait.until(EC.title_contains("Admin dashboard"))
73 [ pkgs.firefox-unwrapped pkgs.geckodriver testRunner ];
77 castopod.wait_for_unit("castopod-setup.service")
78 castopod.wait_for_file("/run/phpfpm/castopod.sock")
79 castopod.wait_for_unit("nginx.service")
80 castopod.wait_for_open_port(80)
81 castopod.wait_until_succeeds("curl -sS -f http://castopod.example.com")
82 castopod.succeed("curl -s http://localhost/cp-install | grep 'Create your Super Admin account' > /dev/null")
84 with subtest("Create superadmin and log in"):
85 castopod.succeed("PYTHONUNBUFFERED=1 systemd-cat -t test-runner test-runner")