1 import ../../make-test-python.nix ({ lib, pkgs, ... }:
5 domain = "movim.local";
6 info = "No ToS in tests";
7 description = "NixOS testing server";
10 domain = "xmpp.local";
12 JID = "${username}@${xmpp.domain}";
19 name = "movim-standard";
22 maintainers = with pkgs.lib.maintainers; [ toastal ];
26 server = { pkgs, ... }: {
28 inherit (movim) domain;
32 inherit (movim) description info;
33 xmppdomain = xmpp.domain;
40 xmppComplianceSuite = false;
42 { url = "upload.${xmpp.domain}"; description = "File Uploads"; }
44 virtualHosts."${xmpp.domain}" = {
45 inherit (xmpp) domain;
48 Component "pubsub.${xmpp.domain}" "pubsub"
49 pubsub_max_items = 10000
50 expose_publisher = true
52 Component "upload.${xmpp.domain}" "http_file_share"
53 http_external_url = "http://upload.${xmpp.domain}"
54 http_file_share_expires_after = 300 * 24 * 60 * 60
55 http_file_share_size_limit = 1024 * 1024 * 1024
56 http_file_share_daily_quota = 4 * 1024 * 1024 * 1024
68 networking.extraHosts = ''
69 127.0.0.1 ${movim.domain}
70 127.0.0.1 ${xmpp.domain}
75 testScript = /* python */ ''
76 server.wait_for_unit("phpfpm-movim.service")
77 server.wait_for_unit("nginx.service")
78 server.wait_for_open_port(80)
80 server.wait_for_unit("prosody.service")
81 server.succeed('prosodyctl status | grep "Prosody is running"')
82 server.succeed("prosodyctl register ${xmpp.admin.username} ${xmpp.domain} ${xmpp.admin.password}")
84 server.wait_for_unit("movim.service")
86 # Test unauthenticated
87 server.fail("curl -L --fail-with-body --max-redirs 0 http://${movim.domain}/chat")
89 # Test basic Websocket
90 server.succeed("echo \"\" | ${lib.getExe pkgs.websocat} 'ws://${movim.domain}/ws/?path=login&offset=0' --origin 'http://${movim.domain}'")
92 # Test login + create cookiejar
93 login_html = server.succeed("curl --fail-with-body -c /tmp/cookies http://${movim.domain}/login")
94 assert "${movim.description}" in login_html
95 assert "${movim.info}" in login_html
97 # Test authentication POST
98 server.succeed("curl --fail-with-body -b /tmp/cookies -X POST --data-urlencode 'username=${xmpp.admin.JID}' --data-urlencode 'password=${xmpp.admin.password}' http://${movim.domain}/login")
100 server.succeed("curl -L --fail-with-body --max-redirs 1 -b /tmp/cookies http://${movim.domain}/chat")