about summary refs log tree commit diff
path: root/nixos/tests/nextcloud/basic.nix
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2018-06-29 19:17:54 +0200
committerRuben Maher <ruben@maher.fyi>2018-10-01 02:07:43 +0930
commitebd38185c8f50535b251b487375a671f3943a6be (patch)
treef41bd427c86e487a209acbc3eab4a3d65fb75e1e /nixos/tests/nextcloud/basic.nix
parentb66d6f404ef73035dfb13acedf360ac796f38ec8 (diff)
downloadnixlib-ebd38185c8f50535b251b487375a671f3943a6be.tar
nixlib-ebd38185c8f50535b251b487375a671f3943a6be.tar.gz
nixlib-ebd38185c8f50535b251b487375a671f3943a6be.tar.bz2
nixlib-ebd38185c8f50535b251b487375a671f3943a6be.tar.lz
nixlib-ebd38185c8f50535b251b487375a671f3943a6be.tar.xz
nixlib-ebd38185c8f50535b251b487375a671f3943a6be.tar.zst
nixlib-ebd38185c8f50535b251b487375a671f3943a6be.zip
nixos/nextcloud: init
Co-authored-by: Franz Pletz <fpletz@fnordicwalking.de>
Co-authored-by: Robin Gloster <mail@glob.in>
Co-authored-by: Janne Heß <janne@hess.ooo>
Co-authored-by: Florian Klink <flokli@flokli.de>
Diffstat (limited to 'nixos/tests/nextcloud/basic.nix')
-rw-r--r--nixos/tests/nextcloud/basic.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/nixos/tests/nextcloud/basic.nix b/nixos/tests/nextcloud/basic.nix
new file mode 100644
index 000000000000..c3b710f0f904
--- /dev/null
+++ b/nixos/tests/nextcloud/basic.nix
@@ -0,0 +1,56 @@
+import ../make-test.nix ({ pkgs, ...}: let
+  adminpass = "notproduction";
+  adminuser = "root";
+in {
+  name = "nextcloud-basic";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ globin eqyiel ];
+  };
+
+  nodes = {
+    # The only thing the client needs to do is download a file.
+    client = { ... }: {};
+
+    nextcloud = { config, pkgs, ... }: {
+      networking.firewall.allowedTCPPorts = [ 80 ];
+
+      services.nextcloud = {
+        enable = true;
+        nginx.enable = true;
+        hostName = "nextcloud";
+        config = {
+          # Don't inherit adminuser since "root" is supposed to be the default
+          inherit adminpass;
+        };
+      };
+    };
+  };
+
+  testScript = let
+    withRcloneEnv = pkgs.writeScript "with-rclone-env" ''
+      #!${pkgs.stdenv.shell}
+      export RCLONE_CONFIG_NEXTCLOUD_TYPE=webdav
+      export RCLONE_CONFIG_NEXTCLOUD_URL="http://nextcloud/remote.php/webdav/"
+      export RCLONE_CONFIG_NEXTCLOUD_VENDOR="nextcloud"
+      export RCLONE_CONFIG_NEXTCLOUD_USER="${adminuser}"
+      export RCLONE_CONFIG_NEXTCLOUD_PASS="$(${pkgs.rclone}/bin/rclone obscure ${adminpass})"
+      "''${@}"
+    '';
+    copySharedFile = pkgs.writeScript "copy-shared-file" ''
+      #!${pkgs.stdenv.shell}
+      echo 'hi' | ${withRcloneEnv} ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file
+    '';
+
+    diffSharedFile = pkgs.writeScript "diff-shared-file" ''
+      #!${pkgs.stdenv.shell}
+      diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
+    '';
+  in ''
+    startAll();
+    $nextcloud->waitForUnit("multi-user.target");
+    $nextcloud->succeed("curl -sSf http://nextcloud/login");
+    $nextcloud->succeed("${withRcloneEnv} ${copySharedFile}");
+    $client->waitForUnit("multi-user.target");
+    $client->succeed("${withRcloneEnv} ${diffSharedFile}");
+  '';
+})