at master 4.0 kB view raw
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 nginx.enableFastcgiRequestBuffering = true; 66 }; 67 68 specialisation.withoutMagick.configuration = { 69 services.nextcloud.enableImagemagick = false; 70 }; 71 }; 72 }; 73 74 test-helpers.extraTests = 75 { nodes, ... }: 76 let 77 findInClosure = 78 what: drv: 79 pkgs.runCommand "find-in-closure" 80 { 81 exportReferencesGraph = [ 82 "graph" 83 drv 84 ]; 85 inherit what; 86 } 87 '' 88 test -e graph 89 grep "$what" graph >$out || true 90 ''; 91 nexcloudWithImagick = findInClosure "imagick" nodes.nextcloud.system.build.vm; 92 nextcloudWithoutImagick = findInClosure "imagick" nodes.nextcloud.specialisation.withoutMagick.configuration.system.build.vm; 93 in 94 # python 95 '' 96 with subtest("File is in proper nextcloud home"): 97 nextcloud.succeed("test -f ${nodes.nextcloud.services.nextcloud.datadir}/data/root/files/test-shared-file") 98 99 with subtest("Closure checks"): 100 assert open("${nexcloudWithImagick}").read() != "" 101 assert open("${nextcloudWithoutImagick}").read() == "" 102 103 with subtest("Davfs2"): 104 assert "hi" in client.succeed("cat /mnt/dav/test-shared-file") 105 106 with subtest("Ensure SSE is disabled by default"): 107 nextcloud.succeed("grep -vE '^HBEGIN:oc_encryption_module' /var/lib/nextcloud-data/data/root/files/test-shared-file") 108 109 with subtest("Create non-empty files with Transfer-Encoding: chunked"): 110 client.succeed( 111 'dd if=/dev/urandom of=testfile.bin bs=1M count=10', 112 'curl --fail -v -X PUT --header "Transfer-Encoding: chunked" --data-binary @testfile.bin "http://nextcloud/remote.php/webdav/testfile.bin" -u ${config.adminuser}:${config.adminpass}', 113 ) 114 115 # Verify the local and remote copies of the file are identical. 116 client_hash = client.succeed("nix-hash testfile.bin").strip() 117 nextcloud_hash = nextcloud.succeed("nix-hash /var/lib/nextcloud-data/data/root/files/testfile.bin").strip() 118 t.assertEqual(client_hash, nextcloud_hash) 119 ''; 120 } 121)