1 { name, pkgs, testBase, system, ... }:
3 with import ../../lib/testing-python.nix { inherit system pkgs; };
4 runTest ({ config, ... }: let inherit (config) adminuser; in {
6 meta = with pkgs.lib.maintainers; {
7 maintainers = [ eqyiel ma27 ];
10 imports = [ testBase ];
13 nextcloud = { config, pkgs, ... }: {
14 environment.systemPackages = [ pkgs.jq ];
15 services.nextcloud = {
21 # This test also validates that we can use an "external" database
22 database.createLocally = false;
27 dbpassFile = config.services.nextcloud.config.adminpassFile;
30 secretFile = "/etc/nextcloud-secrets.json";
33 allow_local_remote_servers = true;
37 # password handled via secretfile below
40 configureRedis = true;
43 services.redis.servers."nextcloud" = {
46 requirePass = "secret";
49 systemd.services.nextcloud-setup= {
50 requires = ["postgresql.service"];
51 after = [ "postgresql.service" ];
54 services.postgresql = {
56 package = pkgs.postgresql_14;
58 systemd.services.postgresql.postStart = pkgs.lib.mkAfter ''
59 password=$(cat ${config.services.nextcloud.config.dbpassFile})
60 ${config.services.postgresql.package}/bin/psql <<EOF
61 CREATE ROLE ${adminuser} WITH LOGIN PASSWORD '$password' CREATEDB;
62 CREATE DATABASE nextcloud;
63 GRANT ALL PRIVILEGES ON DATABASE nextcloud TO ${adminuser};
67 # This file is meant to contain secret options which should
68 # not go into the nix store. Here it is just used to set the
70 environment.etc."nextcloud-secrets.json".text = ''
80 test-helpers.extraTests = ''
81 with subtest("non-empty redis cache"):
82 # redis cache should not be empty
83 nextcloud.fail('test 0 -lt "$(redis-cli --pass secret --json KEYS "*" | jq "len")"')