2019-11-27 09:50:26 +00:00
|
|
|
import ../make-test-python.nix ({ pkgs, ...}: let
|
2018-06-29 17:17:54 +00:00
|
|
|
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;
|
|
|
|
};
|
2019-05-19 17:58:19 +00:00
|
|
|
autoUpdateApps = {
|
|
|
|
enable = true;
|
|
|
|
startAt = "20:00";
|
|
|
|
};
|
2018-06-29 17:17:54 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = let
|
|
|
|
withRcloneEnv = pkgs.writeScript "with-rclone-env" ''
|
2020-04-07 06:25:48 +00:00
|
|
|
#!${pkgs.runtimeShell}
|
2018-06-29 17:17:54 +00:00
|
|
|
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" ''
|
2020-04-07 06:25:48 +00:00
|
|
|
#!${pkgs.runtimeShell}
|
2018-06-29 17:17:54 +00:00
|
|
|
echo 'hi' | ${withRcloneEnv} ${pkgs.rclone}/bin/rclone rcat nextcloud:test-shared-file
|
|
|
|
'';
|
|
|
|
|
|
|
|
diffSharedFile = pkgs.writeScript "diff-shared-file" ''
|
2020-04-07 06:25:48 +00:00
|
|
|
#!${pkgs.runtimeShell}
|
2018-06-29 17:17:54 +00:00
|
|
|
diff <(echo 'hi') <(${pkgs.rclone}/bin/rclone cat nextcloud:test-shared-file)
|
|
|
|
'';
|
|
|
|
in ''
|
2019-11-27 09:50:26 +00:00
|
|
|
start_all()
|
|
|
|
nextcloud.wait_for_unit("multi-user.target")
|
|
|
|
nextcloud.succeed("curl -sSf http://nextcloud/login")
|
|
|
|
nextcloud.succeed(
|
|
|
|
"${withRcloneEnv} ${copySharedFile}"
|
|
|
|
)
|
|
|
|
client.wait_for_unit("multi-user.target")
|
|
|
|
client.succeed(
|
|
|
|
"${withRcloneEnv} ${diffSharedFile}"
|
|
|
|
)
|
2018-06-29 17:17:54 +00:00
|
|
|
'';
|
|
|
|
})
|