1 import ./make-test-python.nix ({ pkgs, lib, ... }: {
4 maintainers = with lib.maintainers; [ nhnn ];
5 broken = pkgs.stdenv.hostPlatform.isAarch64; # selenium.common.exceptions.WebDriverException: Message: Unsupported platform/architecture combination: linux/aarch64
8 nodes.filesender = { ... }: let
9 format = pkgs.formats.php { };
11 networking.firewall.allowedTCPPorts = [ 80 ];
13 services.filesender.enable = true;
14 services.filesender.localDomain = "filesender";
15 services.filesender.settings = {
16 auth_sp_saml_authentication_source = "default";
17 auth_sp_saml_uid_attribute = "uid";
18 storage_filesystem_path = "/tmp";
19 site_url = "http://filesender";
22 admin_email = "admin@localhost";
23 email_reply_to = "noreply@localhost";
25 services.simplesamlphp.filesender = {
27 baseurlpath = "http://filesender/saml";
28 "module.enable".exampleauth = true;
31 admin = [ "core:AdminPassword" ];
32 default = format.lib.mkMixedArray [ "exampleauth:UserPass" ] {
36 mail = [ "user@nixos.org" ];
49 filesenderIP = (builtins.head (nodes.filesender.networking.interfaces.eth1.ipv4.addresses)).address;
52 networking.hosts.${filesenderIP} = [ "filesender" ];
54 environment.systemPackages =
57 password = "password";
59 pkgs.writers.writePython3Bin "browser-test"
61 libraries = [ pkgs.python3Packages.selenium ];
62 flakeIgnore = [ "E124" "E501" ];
64 from selenium.webdriver.common.by import By
65 from selenium.webdriver import Firefox
66 from selenium.webdriver.firefox.options import Options
67 from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
68 from selenium.webdriver.firefox.service import Service
69 from selenium.webdriver.support.ui import WebDriverWait
70 from selenium.webdriver.support import expected_conditions as EC
71 from subprocess import STDOUT
76 selenium_logger = logging.getLogger("selenium")
77 selenium_logger.setLevel(logging.DEBUG)
78 selenium_logger.addHandler(logging.StreamHandler())
79 profile = FirefoxProfile()
80 profile.set_preference("browser.download.folderList", 2)
81 profile.set_preference("browser.download.manager.showWhenStarting", False)
82 profile.set_preference("browser.download.dir", "/tmp/firefox")
83 profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/plain;text/txt")
85 options.profile = profile
86 options.add_argument('--headless')
87 service = Service(log_output=STDOUT)
88 driver = Firefox(options=options)
89 driver.set_window_size(1024, 768)
90 driver.implicitly_wait(30)
91 driver.get('http://filesender/')
92 wait = WebDriverWait(driver, 20)
93 wait.until(EC.title_contains("FileSender"))
94 driver.find_element(By.ID, "btn_logon").click()
95 wait.until(EC.title_contains("Enter your username and password"))
96 driver.find_element(By.ID, 'username').send_keys(
99 driver.find_element(By.ID, 'password').send_keys(
102 driver.find_element(By.ID, "submit_button").click()
103 wait.until(EC.title_contains("FileSender"))
104 wait.until(EC.presence_of_element_located((By.ID, "topmenu_logoff")))
105 test_string = "".join(random.choices(string.ascii_uppercase + string.digits, k=20))
106 with open("/tmp/test_file.txt", "w") as file:
107 file.write(test_string)
108 driver.find_element(By.ID, "files").send_keys("/tmp/test_file.txt")
110 driver.find_element(By.CSS_SELECTOR, '.start').click()
111 wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".download_link")))
112 download_link = driver.find_element(By.CSS_SELECTOR, '.download_link > textarea').get_attribute('value').strip()
113 driver.get(download_link)
114 wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".download")))
115 driver.find_element(By.CSS_SELECTOR, '.download').click()
116 wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".ui-dialog-buttonset > button:nth-child(2)")))
117 driver.find_element(By.CSS_SELECTOR, ".ui-dialog-buttonset > button:nth-child(2)").click()
123 pkgs.firefox-unwrapped
131 filesender.wait_for_file("/run/phpfpm/filesender.sock")
132 filesender.wait_for_open_port(80)
133 if "If you have received an invitation to access this site as a guest" not in client.wait_until_succeeds("curl -sS -f http://filesender"):
134 raise Exception("filesender returned invalid html")
135 client.succeed("browser-test")