1# Miscellaneous small tests that don't warrant their own VM run.
2
3import ./make-test-python.nix ({ pkgs, ...} : rec {
4 name = "privacyidea";
5 meta = with pkgs.lib.maintainers; {
6 maintainers = [ fpletz ];
7 };
8
9 machine = { ... }: {
10 virtualisation.cores = 2;
11 virtualisation.memorySize = 512;
12
13 services.privacyidea = {
14 enable = true;
15 secretKey = "$SECRET_KEY";
16 pepper = "$PEPPER";
17 adminPasswordFile = pkgs.writeText "admin-password" "testing";
18 adminEmail = "root@localhost";
19
20 # Don't try this at home!
21 environmentFile = pkgs.writeText "pi-secrets.env" ''
22 SECRET_KEY=testing
23 PEPPER=testing
24 '';
25 };
26 services.nginx = {
27 enable = true;
28 virtualHosts."_".locations."/".extraConfig = ''
29 uwsgi_pass unix:/run/privacyidea/socket;
30 '';
31 };
32 };
33
34 testScript = ''
35 machine.start()
36 machine.wait_for_unit("multi-user.target")
37 machine.succeed("curl --fail http://localhost | grep privacyIDEA")
38 machine.succeed("grep \"SECRET_KEY = 'testing'\" /var/lib/privacyidea/privacyidea.cfg")
39 machine.succeed("grep \"PI_PEPPER = 'testing'\" /var/lib/privacyidea/privacyidea.cfg")
40 machine.succeed(
41 "curl --fail http://localhost/auth -F username=admin -F password=testing | grep token"
42 )
43 '';
44})