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 = {
15 maintainers = lib.teams.nextcloud.members;
16 };
17
18 imports = [ testBase ];
19
20 nodes = {
21 # The only thing the client needs to do is download a file.
22 client =
23 { ... }:
24 {
25 services.davfs2.enable = true;
26 systemd.tmpfiles.settings.nextcloud = {
27 "/tmp/davfs2-secrets"."f+" = {
28 mode = "0600";
29 argument = "http://nextcloud/remote.php/dav/files/${config.adminuser} ${config.adminuser} ${config.adminpass}";
30 };
31 };
32 virtualisation.fileSystems = {
33 "/mnt/dav" = {
34 device = "http://nextcloud/remote.php/dav/files/${config.adminuser}";
35 fsType = "davfs";
36 options =
37 let
38 davfs2Conf = (pkgs.writeText "davfs2.conf" "secrets /tmp/davfs2-secrets");
39 in
40 [
41 "conf=${davfs2Conf}"
42 "x-systemd.automount"
43 "noauto"
44 ];
45 };
46 };
47 };
48
49 nextcloud =
50 { config, pkgs, ... }:
51 {
52 systemd.tmpfiles.rules = [
53 "d /var/lib/nextcloud-data 0750 nextcloud nginx - -"
54 ];
55
56 services.nextcloud = {
57 enable = true;
58 config.dbtype = "sqlite";
59 datadir = "/var/lib/nextcloud-data";
60 autoUpdateApps = {
61 enable = true;
62 startAt = "20:00";
63 };
64 phpExtraExtensions = all: [ all.bz2 ];
65 };
66
67 specialisation.withoutMagick.configuration = {
68 services.nextcloud.enableImagemagick = false;
69 };
70 };
71 };
72
73 test-helpers.extraTests =
74 { nodes, ... }:
75 let
76 findInClosure =
77 what: drv:
78 pkgs.runCommand "find-in-closure"
79 {
80 exportReferencesGraph = [
81 "graph"
82 drv
83 ];
84 inherit what;
85 }
86 ''
87 test -e graph
88 grep "$what" graph >$out || true
89 '';
90 nexcloudWithImagick = findInClosure "imagick" nodes.nextcloud.system.build.vm;
91 nextcloudWithoutImagick = findInClosure "imagick" nodes.nextcloud.specialisation.withoutMagick.configuration.system.build.vm;
92 in
93 ''
94 with subtest("File is in proper nextcloud home"):
95 nextcloud.succeed("test -f ${nodes.nextcloud.services.nextcloud.datadir}/data/root/files/test-shared-file")
96
97 with subtest("Closure checks"):
98 assert open("${nexcloudWithImagick}").read() != ""
99 assert open("${nextcloudWithoutImagick}").read() == ""
100
101 with subtest("Davfs2"):
102 assert "hi" in client.succeed("cat /mnt/dav/test-shared-file")
103
104 with subtest("Ensure SSE is disabled by default"):
105 nextcloud.succeed("grep -vE '^HBEGIN:oc_encryption_module' /var/lib/nextcloud-data/data/root/files/test-shared-file")
106 '';
107 }
108)