2024-06-11 12:37:01 +02:00
|
|
|
{ name, pkgs, testBase, system,... }:
|
2021-10-01 17:03:32 +02:00
|
|
|
|
2024-06-11 12:37:01 +02:00
|
|
|
with import ../../lib/testing-python.nix { inherit system pkgs; };
|
|
|
|
runTest ({ config, ... }: {
|
|
|
|
inherit name;
|
2021-01-10 20:08:30 +01:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2024-06-11 12:37:01 +02:00
|
|
|
maintainers = [ globin eqyiel ma27 ];
|
2018-06-29 19:17:54 +02:00
|
|
|
};
|
|
|
|
|
2024-06-11 12:37:01 +02:00
|
|
|
imports = [ testBase ];
|
|
|
|
|
|
|
|
nodes = {
|
2018-06-29 19:17:54 +02:00
|
|
|
# The only thing the client needs to do is download a file.
|
2020-05-24 00:01:06 +02:00
|
|
|
client = { ... }: {
|
|
|
|
services.davfs2.enable = true;
|
2023-10-29 01:05:47 +02:00
|
|
|
systemd.tmpfiles.settings.nextcloud = {
|
|
|
|
"/tmp/davfs2-secrets"."f+" = {
|
|
|
|
mode = "0600";
|
2024-06-11 12:37:01 +02:00
|
|
|
argument = "http://nextcloud/remote.php/dav/files/${config.adminuser} ${config.adminuser} ${config.adminpass}";
|
2023-10-29 01:05:47 +02:00
|
|
|
};
|
|
|
|
};
|
2021-02-14 12:23:50 +01:00
|
|
|
virtualisation.fileSystems = {
|
2020-05-24 00:01:06 +02:00
|
|
|
"/mnt/dav" = {
|
2024-06-11 12:37:01 +02:00
|
|
|
device = "http://nextcloud/remote.php/dav/files/${config.adminuser}";
|
2020-05-24 00:01:06 +02:00
|
|
|
fsType = "davfs";
|
|
|
|
options = let
|
|
|
|
davfs2Conf = (pkgs.writeText "davfs2.conf" "secrets /tmp/davfs2-secrets");
|
|
|
|
in [ "conf=${davfs2Conf}" "x-systemd.automount" "noauto"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2018-06-29 19:17:54 +02:00
|
|
|
|
2024-06-11 12:37:01 +02:00
|
|
|
nextcloud = { config, pkgs, ... }: {
|
2021-10-09 22:36:35 +02:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /var/lib/nextcloud-data 0750 nextcloud nginx - -"
|
|
|
|
];
|
|
|
|
|
2018-06-29 19:17:54 +02:00
|
|
|
services.nextcloud = {
|
|
|
|
enable = true;
|
2021-10-09 22:36:35 +02:00
|
|
|
datadir = "/var/lib/nextcloud-data";
|
2019-05-19 19:58:19 +02:00
|
|
|
autoUpdateApps = {
|
|
|
|
enable = true;
|
|
|
|
startAt = "20:00";
|
|
|
|
};
|
2021-01-09 17:53:30 +01:00
|
|
|
phpExtraExtensions = all: [ all.bz2 ];
|
2018-06-29 19:17:54 +02:00
|
|
|
};
|
2020-06-20 09:55:02 +02:00
|
|
|
|
2024-06-11 12:37:01 +02:00
|
|
|
specialisation.withoutMagick.configuration = {
|
|
|
|
services.nextcloud.enableImagemagick = false;
|
|
|
|
};
|
2018-06-29 19:17:54 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-06-11 12:37:01 +02:00
|
|
|
test-helpers.extraTests = { nodes, ... }: let
|
2021-03-11 02:56:11 +01:00
|
|
|
findInClosure = what: drv: pkgs.runCommand "find-in-closure" { exportReferencesGraph = [ "graph" drv ]; inherit what; } ''
|
|
|
|
test -e graph
|
|
|
|
grep "$what" graph >$out || true
|
|
|
|
'';
|
2024-06-11 12:37:01 +02:00
|
|
|
nexcloudWithImagick = findInClosure "imagick" nodes.nextcloud.system.build.vm;
|
|
|
|
nextcloudWithoutImagick = findInClosure "imagick" nodes.nextcloud.specialisation.withoutMagick.configuration.system.build.vm;
|
2018-06-29 19:17:54 +02:00
|
|
|
in ''
|
2024-06-11 12:37:01 +02: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-11 02:56:11 +01:00
|
|
|
|
2024-06-11 12:37:01 +02: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")
|
2018-06-29 19:17:54 +02:00
|
|
|
'';
|
2024-06-11 12:37:01 +02:00
|
|
|
})
|