summary refs log blame commit diff
path: root/nixos/tests/radicale.nix
blob: bec86d2cb2841240867a47e5f090dbf935b7c906 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
   








                                                                   

                         
                 



                                                  
 
                 

                                            
                 
                    



                                                                                        

                                                                                 

       

                                                                               
                 


                                                                                        
     
  
let
  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 = ''
        [auth]
        type = htpasswd
        htpasswd_filename = /etc/radicale/htpasswd
        htpasswd_encryption = bcrypt

        [storage]
        filesystem_folder = /tmp/collections

        [logging]
        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 = pkgs.runCommand "htpasswd" {} ''
      ${pkgs.apacheHttpd}/bin/htpasswd -bcB "$out" ${user} ${password}
    '';
  };
  
  # This tests whether the web interface is accessible to an authenticated user
  testScript = ''
    $machine->waitForUnit('radicale.service');
    $machine->waitForOpenPort(${port});
    $machine->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/');
  '';
})