1import ./make-test-python.nix (
2 { lib, pkgs, ... }:
3
4 {
5 name = "zammad";
6
7 meta.maintainers = with lib.maintainers; [ taeer n0emis netali ];
8
9 nodes.machine = { config, ... }: {
10 virtualisation = {
11 memorySize = 2048;
12 };
13
14 services.zammad.enable = true;
15 services.zammad.secretKeyBaseFile = pkgs.writeText "secret" ''
16 52882ef142066e09ab99ce816ba72522e789505caba224a52d750ec7dc872c2c371b2fd19f16b25dfbdd435a4dd46cb3df9f82eb63fafad715056bdfe25740d6
17 '';
18
19 systemd.services.zammad-locale-cheat =
20 let cfg = config.services.zammad; in
21 {
22 serviceConfig = {
23 Type = "simple";
24 Restart = "always";
25
26 User = "zammad";
27 Group = "zammad";
28 PrivateTmp = true;
29 StateDirectory = "zammad";
30 WorkingDirectory = cfg.dataDir;
31 };
32 wantedBy = [ "zammad-web.service" ];
33 description = "Hack in the locale files so zammad doesn't try to access the internet";
34 script = ''
35 mkdir -p ./config/translations
36 VERSION=$(cat ${cfg.package}/VERSION)
37
38 # If these files are not in place, zammad will try to access the internet.
39 # For the test, we only need to supply en-us.
40 echo '[{"locale":"en-us","alias":"en","name":"English (United States)","active":true,"dir":"ltr"}]' \
41 > ./config/locales-$VERSION.yml
42 echo '[{"locale":"en-us","format":"time","source":"date","target":"mm/dd/yyyy","target_initial":"mm/dd/yyyy"},{"locale":"en-us","format":"time","source":"timestamp","target":"mm/dd/yyyy HH:MM","target_initial":"mm/dd/yyyy HH:MM"}]' \
43 > ./config/translations/en-us-$VERSION.yml
44 '';
45 };
46 };
47
48 testScript = ''
49 start_all()
50 machine.wait_for_unit("postgresql.service")
51 machine.wait_for_unit("redis-zammad.service")
52 machine.wait_for_unit("zammad-web.service")
53 machine.wait_for_unit("zammad-websocket.service")
54 machine.wait_for_unit("zammad-worker.service")
55 # wait for zammad to fully come up
56 machine.sleep(120)
57
58 # without the grep the command does not produce valid utf-8 for some reason
59 with subtest("welcome screen loads"):
60 machine.succeed(
61 "curl -sSfL http://localhost:3000/ | grep '<title>Zammad Helpdesk</title>'"
62 )
63 '';
64 }
65)