about summary refs log tree commit diff
path: root/nixos/tests/nextcloud/with-postgresql-and-redis.nix
blob: 24c17f70932d3683e6426f55acaba49e0054e7e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ name, pkgs, testBase, system, ... }:

with import ../../lib/testing-python.nix { inherit system pkgs; };
runTest ({ config, ... }: {
  inherit name;
  meta = with pkgs.lib.maintainers; {
    maintainers = [ eqyiel ma27 ];
  };

  imports = [ testBase ];

  nodes = {
    nextcloud = { config, pkgs, lib, ... }: {
      services.nextcloud = {
        caching = {
          apcu = false;
          redis = true;
          memcached = false;
        };
        config.dbtype = "pgsql";
        notify_push = {
          enable = true;
          logLevel = "debug";
        };
        extraAppsEnable = true;
        extraApps = with config.services.nextcloud.package.packages.apps; {
          inherit notify_push notes;
        };
        settings.trusted_proxies = [ "::1" ];
      };

      services.redis.servers."nextcloud".enable = true;
      services.redis.servers."nextcloud".port = 6379;
    };
  };

  test-helpers.init = let
    configureRedis = pkgs.writeScript "configure-redis" ''
      nextcloud-occ config:system:set redis 'host' --value 'localhost' --type string
      nextcloud-occ config:system:set redis 'port' --value 6379 --type integer
      nextcloud-occ config:system:set memcache.local --value '\OC\Memcache\Redis' --type string
      nextcloud-occ config:system:set memcache.locking --value '\OC\Memcache\Redis' --type string
    '';
  in ''
    nextcloud.succeed("${configureRedis}")
  '';

  test-helpers.extraTests = ''
    with subtest("notify-push"):
        client.execute("${pkgs.lib.getExe pkgs.nextcloud-notify_push.passthru.test_client} http://nextcloud ${config.adminuser} ${config.adminpass} >&2 &")
        nextcloud.wait_until_succeeds("journalctl -u nextcloud-notify_push | grep -q \"Sending ping to ${config.adminuser}\"")

    with subtest("Redis is used for caching"):
        # redis cache should not be empty
        nextcloud.fail('test "[]" = "$(redis-cli --json KEYS "*")"')

    with subtest("No code is returned when requesting PHP files (regression test)"):
        nextcloud.fail("curl -f http://nextcloud/nix-apps/notes/lib/AppInfo/Application.php")
  '';
})