1 import ./make-test-python.nix ({ pkgs, ... }: {
3 meta = with pkgs.lib.maintainers; {
4 maintainers = [ ma27 ];
7 nodes.machine = { pkgs, ... }: {
10 hostName = "localhost";
11 nginx.enableSSL = false;
13 environment.systemPackages = [ pkgs.jq ];
18 machine.wait_for_open_port(80)
19 machine.wait_for_unit("multi-user.target")
21 machine.succeed("curl -sSf http://localhost")
24 "curl -c cookies -sSf -X POST http://localhost/login -d 'username=admin&password=admin'"
27 cookie = machine.succeed(
28 "grep -v '^#' cookies | awk '{ print $7 }' | sed -e '/^$/d' | perl -pe 'chomp'"
32 f"curl -sSf -X POST http://localhost/api/objects/tasks -b 'grocy_session={cookie}' "
33 + '-d \'{"assigned_to_user_id":1,"name":"Test Task","due_date":"1970-01-01"}\'''
34 + " --header 'Content-Type: application/json'"
37 task_name = machine.succeed(
38 f"curl -sSf http://localhost/api/tasks -b 'grocy_session={cookie}' --header 'Accept: application/json' | jq '.[].name' | xargs echo | perl -pe 'chomp'"
41 assert task_name == "Test Task"
43 machine.succeed("curl -sSI http://localhost/api/tasks 2>&1 | grep '401 Unauthorized'")