4 It covers the following scenario:
8 Scenarios NOT covered by this test (but perhaps in the future):
9 - Sending and receiving emails
12 siteName = "NixOS Snipe-IT Test Instance";
16 meta.maintainers = with pkgs.lib.maintainers; [ yayayayaka ];
22 appKeyFile = toString (pkgs.writeText "snipe-it-app-key" "uTqGUN5GUmUrh/zSAYmhyzRk62pnpXICyXv9eeITI8k=");
23 hostName = "localhost";
24 database.createLocally = true;
30 from.name = "Snipe-IT NixOS test";
31 from.address = "snipe-it@localhost";
32 replyTo.address = "snipe-it@localhost";
33 user = "snipe-it@localhost";
34 passwordFile = toString (pkgs.writeText "snipe-it-mail-pass" "a-secure-mail-password");
40 testScript = { nodes }: let
41 backupPath = "${nodes.snipeit.services.snipe-it.dataDir}/storage/app/backups";
43 # Snipe-IT has been installed successfully if the site name shows up on the login page
44 checkLoginPage = { shouldSucceed ? true }: ''
45 snipeit.${if shouldSucceed then "succeed" else "fail"}("""curl http://localhost/login | grep '${siteName}'""")
50 snipeit.wait_for_unit("nginx.service")
51 snipeit.wait_for_unit("snipe-it-setup.service")
53 # Create an admin user
56 snipe-it snipeit:create-admin \
58 --email="janedoe@localhost" \
59 --password="extremesecurepassword" \
65 with subtest("Circumvent the pre-flight setup by just writing some settings into the database ourself"):
68 mysql -D ${nodes.snipeit.services.snipe-it.database.name} -e "
69 INSERT INTO settings (id, site_name, login_remote_user_custom_logout_url, login_remote_user_header_name)
70 VALUES ('1', '${siteName}', 'https://whatever.invalid', 'whatever');"
74 # Usually these are generated during the pre-flight setup
75 snipeit.succeed("snipe-it passport:keys")
78 # Login page should now contain the configured site name
81 with subtest("Test Backup and restore"):
82 snipeit.succeed("snipe-it snipeit:backup")
84 # One zip file should have been created
85 snipeit.succeed("""[ "$(ls -1 "${backupPath}" | wc -l)" -eq 1 ]""")
88 snipeit.succeed("snipe-it migrate:fresh --force")
90 # Login page should disappear
91 ${checkLoginPage { shouldSucceed = false; }}
96 snipe-it snipeit:restore --force $(find "${backupPath}/" -type f -name "*.zip")
100 # Login page should be back again