1{
2 name,
3 pkgs,
4 testBase,
5 system,
6 ...
7}:
8
9with import ../../lib/testing-python.nix { inherit system pkgs; };
10runTest (
11 { config, lib, ... }:
12 {
13 inherit name;
14 meta.maintainers = lib.teams.nextcloud.members;
15
16 imports = [ testBase ];
17
18 nodes = {
19 nextcloud =
20 {
21 config,
22 pkgs,
23 lib,
24 ...
25 }:
26 {
27 environment.systemPackages = [ pkgs.jq ];
28 services.nextcloud = {
29 caching = {
30 apcu = false;
31 redis = true;
32 memcached = false;
33 };
34 config.dbtype = "pgsql";
35 notify_push = {
36 enable = true;
37 bendDomainToLocalhost = true;
38 logLevel = "debug";
39 };
40 extraAppsEnable = true;
41 extraApps = with config.services.nextcloud.package.packages.apps; {
42 inherit notify_push notes;
43 };
44 settings.trusted_proxies = [ "::1" ];
45 };
46
47 services.redis.servers."nextcloud".enable = true;
48 services.redis.servers."nextcloud".port = 6379;
49 };
50 };
51
52 test-helpers.init =
53 let
54 configureRedis = pkgs.writeScript "configure-redis" ''
55 nextcloud-occ config:system:set redis 'host' --value 'localhost' --type string
56 nextcloud-occ config:system:set redis 'port' --value 6379 --type integer
57 nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\Redis' --type string
58 nextcloud-occ config:system:set memcache.locking --value '\OC\Memcache\Redis' --type string
59 '';
60 in
61 ''
62 nextcloud.succeed("${configureRedis}")
63 '';
64
65 test-helpers.extraTests = ''
66 with subtest("notify-push"):
67 client.execute("${lib.getExe pkgs.nextcloud-notify_push.passthru.test_client} http://nextcloud ${config.adminuser} ${config.adminpass} >&2 &")
68 nextcloud.wait_until_succeeds("journalctl -u nextcloud-notify_push | grep -q \"Sending ping to ${config.adminuser}\"")
69
70 with subtest("Redis is used for caching"):
71 # redis cache should not be empty
72 assert nextcloud.succeed('redis-cli --json KEYS "*" | jq length').strip() != "0", """
73 redis-cli for keys * returned 0 entries
74 """
75
76 with subtest("No code is returned when requesting PHP files (regression test)"):
77 nextcloud.fail("curl -f http://nextcloud/nix-apps/notes/lib/AppInfo/Application.php")
78 '';
79 }
80)