summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2017-08-30 02:17:34 +0200
committerGitHub <noreply@github.com>2017-08-30 02:17:34 +0200
commit7d1d0196502d9a81841334e65fb73e4b5e3c604a (patch)
tree6d7c8b556f4eaf55a5abe17fb51bd6da606bdb5c /nixos/tests
parentb91ed353250990b7efdc956ffd3490b0155392b3 (diff)
parente16a0988bc18be3997f5c475f373a8ac127d3fa0 (diff)
downloadnixpkgs-7d1d0196502d9a81841334e65fb73e4b5e3c604a.tar
nixpkgs-7d1d0196502d9a81841334e65fb73e4b5e3c604a.tar.gz
nixpkgs-7d1d0196502d9a81841334e65fb73e4b5e3c604a.tar.bz2
nixpkgs-7d1d0196502d9a81841334e65fb73e4b5e3c604a.tar.lz
nixpkgs-7d1d0196502d9a81841334e65fb73e4b5e3c604a.tar.xz
nixpkgs-7d1d0196502d9a81841334e65fb73e4b5e3c604a.tar.zst
nixpkgs-7d1d0196502d9a81841334e65fb73e4b5e3c604a.zip
Merge pull request #27826 from Infinisil/radicale
radicale: update to version 2
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/radicale.nix83
1 files changed, 21 insertions, 62 deletions
diff --git a/nixos/tests/radicale.nix b/nixos/tests/radicale.nix
index 4c2ed8456dd..bec86d2cb28 100644
--- a/nixos/tests/radicale.nix
+++ b/nixos/tests/radicale.nix
@@ -1,80 +1,39 @@
 let
-  port = 5232;
-  radicaleOverlay = self: super: {
-    radicale = super.radicale.overrideAttrs (oldAttrs: {
-      propagatedBuildInputs = with self.pythonPackages;
-        (oldAttrs.propagatedBuildInputs or []) ++ [
-          passlib
-        ];
-    });
-  };
-  common = { config, pkgs, ...}: {
+  user = "someuser";
+  password = "some_password";
+  port = builtins.toString 5232;
+in
+  import ./make-test.nix ({ pkgs, lib, ... }: {
+  name = "radicale";
+  meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
+
+  machine = {
     services.radicale = {
       enable = true;
-      config = let home = config.users.extraUsers.radicale.home; in ''
-        [server]
-        hosts = 127.0.0.1:${builtins.toString port}
-        daemon = False
-        [encoding]
-        [well-known]
+      config = ''
         [auth]
         type = htpasswd
         htpasswd_filename = /etc/radicale/htpasswd
         htpasswd_encryption = bcrypt
-        [git]
-        [rights]
+
         [storage]
-        type = filesystem
-        filesystem_folder = ${home}/collections
+        filesystem_folder = /tmp/collections
+
         [logging]
-        [headers]
+        debug = True
       '';
     };
     # WARNING: DON'T DO THIS IN PRODUCTION!
     # This puts secrets (albeit hashed) directly into the Nix store for ease of testing.
-    environment.etc."radicale/htpasswd".source = with pkgs; let
-      py = python.withPackages(ps: with ps; [ passlib ]);
-    in runCommand "htpasswd" {} ''
-        ${py}/bin/python -c "
-from passlib.apache import HtpasswdFile
-ht = HtpasswdFile(
-    '$out',
-    new=True,
-    default_scheme='bcrypt'
-)
-ht.set_password('someuser', 'really_secret_password')
-ht.save()
-"
+    environment.etc."radicale/htpasswd".source = pkgs.runCommand "htpasswd" {} ''
+      ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password}
     '';
   };
-
-in import ./make-test.nix ({ lib, ... }: {
-  name = "radicale";
-  meta.maintainers = with lib.maintainers; [ aneeshusa ];
-
-  # Test radicale with bcrypt-based htpasswd authentication
-  nodes = {
-    py2 = { config, pkgs, ... }@args: (common args) // {
-      nixpkgs.overlays = [
-        radicaleOverlay
-      ];
-    };
-    py3 = { config, pkgs, ... }@args: (common args) // {
-      nixpkgs.overlays = [
-        (self: super: {
-          python = self.python3;
-          pythonPackages = self.python3.pkgs;
-        })
-        radicaleOverlay
-      ];
-    };
-  };
-
+  
+  # This tests whether the web interface is accessible to an authenticated user
   testScript = ''
-    for my $machine ($py2, $py3) {
-      $machine->waitForUnit('radicale.service');
-      $machine->waitForOpenPort(${builtins.toString port});
-      $machine->succeed('curl -s http://someuser:really_secret_password@127.0.0.1:${builtins.toString port}/someuser/calendar.ics/');
-    }
+    $machine->waitForUnit('radicale.service');
+    $machine->waitForOpenPort(${port});
+    $machine->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/');
   '';
 })