summaryrefslogtreecommitdiffstats
path: root/nixos/tests/web-apps/froide-govplan.nix
blob: 05f42a52863ebcf2c36051d8cb43e61b3e968652 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{
  lib,
  pkgs,
  ...
}:

{
  name = "froide-govplan";
  meta.maintainers = with lib.maintainers; [ onny ];

  nodes = {
    machine = {
      virtualisation.memorySize = 2048;
      services.froide-govplan.enable = true;
    };
  };

  testScript =
    let
      changePassword = pkgs.writeText "change-password.py" ''
        from django.contrib.auth.models import User
        u = User.objects.get(username='govplan')
        u.set_password('govplan')
        u.save()
      '';
    in
    ''
      start_all()
      machine.wait_for_unit("froide-govplan.service")
      machine.wait_for_file("/run/froide-govplan/froide-govplan.socket")

      with subtest("Home screen loads"):
          machine.succeed(
              "curl -sSfL http://[::1]:80 | grep '<title>django CMS</title>'"
          )

      with subtest("Superuser can be created"):
          machine.succeed(
              "froide-govplan createsuperuser --noinput --username govplan --email govplan@example.com"
          )
          # Django doesn't have a "clean" way of inputting the password from the command line
          machine.succeed("cat '${changePassword}' | froide-govplan shell")
    '';
}