2024-06-20 14:57:18 +00:00
|
|
|
{ name, pkgs, testBase, system,... }:
|
2021-10-04 12:37:57 +00:00
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
with import ../../lib/testing-python.nix { inherit system pkgs; };
|
|
|
|
runTest ({ config, ... }: {
|
|
|
|
inherit name;
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2024-06-20 14:57:18 +00:00
|
|
|
maintainers = [ globin eqyiel ma27 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
imports = [ testBase ];
|
|
|
|
|
|
|
|
nodes = {
|
2020-04-24 23:36:52 +00:00
|
|
|
# The only thing the client needs to do is download a file.
|
2020-05-29 06:06:01 +00:00
|
|
|
client = { ... }: {
|
|
|
|
services.davfs2.enable = true;
|
2024-01-02 11:29:13 +00:00
|
|
|
systemd.tmpfiles.settings.nextcloud = {
|
|
|
|
"/tmp/davfs2-secrets"."f+" = {
|
|
|
|
mode = "0600";
|
2024-06-20 14:57:18 +00:00
|
|
|
argument = "http://nextcloud/remote.php/dav/files/${config.adminuser} ${config.adminuser} ${config.adminpass}";
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
};
|
2021-02-16 17:04:54 +00:00
|
|
|
virtualisation.fileSystems = {
|
2020-05-29 06:06:01 +00:00
|
|
|
"/mnt/dav" = {
|
2024-06-20 14:57:18 +00:00
|
|
|
device = "http://nextcloud/remote.php/dav/files/${config.adminuser}";
|
2020-05-29 06:06:01 +00:00
|
|
|
fsType = "davfs";
|
|
|
|
options = let
|
|
|
|
davfs2Conf = (pkgs.writeText "davfs2.conf" "secrets /tmp/davfs2-secrets");
|
|
|
|
in [ "conf=${davfs2Conf}" "x-systemd.automount" "noauto"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
nextcloud = { config, pkgs, ... }: {
|
2021-10-14 00:43:12 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /var/lib/nextcloud-data 0750 nextcloud nginx - -"
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
2021-10-14 00:43:12 +00:00
|
|
|
datadir = "/var/lib/nextcloud-data";
|
2024-06-20 14:57:18 +00:00
|
|
|
config.dbtableprefix = "nixos_";
|
2020-04-24 23:36:52 +00:00
|
|
|
autoUpdateApps = {
|
|
|
|
enable = true;
|
|
|
|
startAt = "20:00";
|
|
|
|
};
|
2021-02-05 17:12:51 +00:00
|
|
|
phpExtraExtensions = all: [ all.bz2 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-06-15 15:56:04 +00:00
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
specialisation.withoutMagick.configuration = {
|
|
|
|
services.nextcloud.enableImagemagick = false;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
test-helpers.extraTests = { nodes, ... }: let
|
2021-03-12 07:09:13 +00:00
|
|
|
findInClosure = what: drv: pkgs.runCommand "find-in-closure" { exportReferencesGraph = [ "graph" drv ]; inherit what; } ''
|
|
|
|
test -e graph
|
|
|
|
grep "$what" graph >$out || true
|
|
|
|
'';
|
2024-06-20 14:57:18 +00:00
|
|
|
nexcloudWithImagick = findInClosure "imagick" nodes.nextcloud.system.build.vm;
|
|
|
|
nextcloudWithoutImagick = findInClosure "imagick" nodes.nextcloud.specialisation.withoutMagick.configuration.system.build.vm;
|
2020-04-24 23:36:52 +00:00
|
|
|
in ''
|
2024-06-20 14:57:18 +00:00
|
|
|
with subtest("File is in proper nextcloud home"):
|
|
|
|
nextcloud.succeed("test -f ${nodes.nextcloud.services.nextcloud.datadir}/data/root/files/test-shared-file")
|
|
|
|
|
|
|
|
with subtest("Closure checks"):
|
|
|
|
assert open("${nexcloudWithImagick}").read() != ""
|
|
|
|
assert open("${nextcloudWithoutImagick}").read() == ""
|
|
|
|
|
|
|
|
with subtest("Davfs2"):
|
|
|
|
assert "hi" in client.succeed("cat /mnt/dav/test-shared-file")
|
2021-03-12 07:09:13 +00:00
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
with subtest("Ensure SSE is disabled by default"):
|
|
|
|
nextcloud.succeed("grep -vE '^HBEGIN:oc_encryption_module' /var/lib/nextcloud-data/data/root/files/test-shared-file")
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2024-06-20 14:57:18 +00:00
|
|
|
})
|