mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
parent
79a8a723b9
commit
6a31e09833
2 changed files with 65 additions and 67 deletions
|
@ -551,7 +551,7 @@ in
|
||||||
grav = runTest ./web-apps/grav.nix;
|
grav = runTest ./web-apps/grav.nix;
|
||||||
graylog = handleTest ./graylog.nix { };
|
graylog = handleTest ./graylog.nix { };
|
||||||
greetd-no-shadow = handleTest ./greetd-no-shadow.nix { };
|
greetd-no-shadow = handleTest ./greetd-no-shadow.nix { };
|
||||||
grocy = handleTest ./grocy.nix { };
|
grocy = runTest ./grocy.nix;
|
||||||
grow-partition = runTest ./grow-partition.nix;
|
grow-partition = runTest ./grow-partition.nix;
|
||||||
grub = handleTest ./grub.nix { };
|
grub = handleTest ./grub.nix { };
|
||||||
guacamole-server = handleTest ./guacamole-server.nix { };
|
guacamole-server = handleTest ./guacamole-server.nix { };
|
||||||
|
|
|
@ -1,81 +1,79 @@
|
||||||
import ./make-test-python.nix (
|
{ pkgs, ... }:
|
||||||
{ pkgs, ... }:
|
{
|
||||||
{
|
name = "grocy";
|
||||||
name = "grocy";
|
meta = with pkgs.lib.maintainers; {
|
||||||
meta = with pkgs.lib.maintainers; {
|
maintainers = [ ma27 ];
|
||||||
maintainers = [ ma27 ];
|
};
|
||||||
|
|
||||||
|
nodes.machine =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
services.grocy = {
|
||||||
|
enable = true;
|
||||||
|
hostName = "localhost";
|
||||||
|
nginx.enableSSL = false;
|
||||||
|
};
|
||||||
|
environment.systemPackages = [ pkgs.jq ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes.machine =
|
testScript = ''
|
||||||
{ pkgs, ... }:
|
from base64 import b64encode
|
||||||
{
|
from urllib.parse import quote
|
||||||
services.grocy = {
|
|
||||||
enable = true;
|
|
||||||
hostName = "localhost";
|
|
||||||
nginx.enableSSL = false;
|
|
||||||
};
|
|
||||||
environment.systemPackages = [ pkgs.jq ];
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
machine.start()
|
||||||
from base64 import b64encode
|
machine.wait_for_open_port(80)
|
||||||
from urllib.parse import quote
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
machine.start()
|
# This establishes _something_
|
||||||
machine.wait_for_open_port(80)
|
machine.succeed("curl -sSf http://localhost")
|
||||||
machine.wait_for_unit("multi-user.target")
|
# The second request creates the database, unsure why both are required
|
||||||
|
machine.succeed("curl -sSf http://localhost/")
|
||||||
|
|
||||||
# This establishes _something_
|
machine.succeed(
|
||||||
machine.succeed("curl -sSf http://localhost")
|
"curl -c cookies -sSf -X POST http://localhost/login -d 'username=admin&password=admin'"
|
||||||
# The second request creates the database, unsure why both are required
|
)
|
||||||
machine.succeed("curl -sSf http://localhost/")
|
|
||||||
|
|
||||||
machine.succeed(
|
cookie = machine.succeed(
|
||||||
"curl -c cookies -sSf -X POST http://localhost/login -d 'username=admin&password=admin'"
|
"grep -v '^#' cookies | awk '{ print $7 }' | sed -e '/^$/d' | perl -pe 'chomp'"
|
||||||
)
|
)
|
||||||
|
|
||||||
cookie = machine.succeed(
|
machine.succeed(
|
||||||
"grep -v '^#' cookies | awk '{ print $7 }' | sed -e '/^$/d' | perl -pe 'chomp'"
|
f"curl -sSf -X POST http://localhost/api/objects/tasks -b 'grocy_session={cookie}' "
|
||||||
)
|
+ '-d \'{"assigned_to_user_id":1,"name":"Test Task","due_date":"1970-01-01"}\'''
|
||||||
|
+ " --header 'Content-Type: application/json'"
|
||||||
|
)
|
||||||
|
|
||||||
machine.succeed(
|
task_name = machine.succeed(
|
||||||
f"curl -sSf -X POST http://localhost/api/objects/tasks -b 'grocy_session={cookie}' "
|
f"curl -sSf http://localhost/api/tasks -b 'grocy_session={cookie}' --header 'Accept: application/json' | jq '.[].name' | xargs echo | perl -pe 'chomp'"
|
||||||
+ '-d \'{"assigned_to_user_id":1,"name":"Test Task","due_date":"1970-01-01"}\'''
|
)
|
||||||
+ " --header 'Content-Type: application/json'"
|
|
||||||
)
|
|
||||||
|
|
||||||
task_name = machine.succeed(
|
assert task_name == "Test Task"
|
||||||
f"curl -sSf http://localhost/api/tasks -b 'grocy_session={cookie}' --header 'Accept: application/json' | jq '.[].name' | xargs echo | perl -pe 'chomp'"
|
|
||||||
)
|
|
||||||
|
|
||||||
assert task_name == "Test Task"
|
machine.succeed("curl -sSI http://localhost/api/tasks 2>&1 | grep '401 Unauthorized'")
|
||||||
|
|
||||||
machine.succeed("curl -sSI http://localhost/api/tasks 2>&1 | grep '401 Unauthorized'")
|
file_name = "test.txt"
|
||||||
|
file_name_base64 = b64encode(file_name.encode('ascii')).decode('ascii')
|
||||||
|
file_name_base64_urlencode = quote(file_name_base64)
|
||||||
|
|
||||||
file_name = "test.txt"
|
machine.succeed(
|
||||||
file_name_base64 = b64encode(file_name.encode('ascii')).decode('ascii')
|
f"echo Sample equipment manual > /tmp/{file_name}"
|
||||||
file_name_base64_urlencode = quote(file_name_base64)
|
)
|
||||||
|
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
f"echo Sample equipment manual > /tmp/{file_name}"
|
f"curl -sSf -X 'PUT' -b 'grocy_session={cookie}' "
|
||||||
)
|
+ f" 'http://localhost/api/files/equipmentmanuals/{file_name_base64_urlencode}' "
|
||||||
|
+ " --header 'Accept: */*' "
|
||||||
|
+ " --header 'Content-Type: application/octet-stream' "
|
||||||
|
+ f" --data-binary '@/tmp/{file_name}' "
|
||||||
|
)
|
||||||
|
|
||||||
machine.succeed(
|
machine.succeed(
|
||||||
f"curl -sSf -X 'PUT' -b 'grocy_session={cookie}' "
|
f"curl -sSf -X 'GET' -b 'grocy_session={cookie}' "
|
||||||
+ f" 'http://localhost/api/files/equipmentmanuals/{file_name_base64_urlencode}' "
|
+ f" 'http://localhost/api/files/equipmentmanuals/{file_name_base64_urlencode}' "
|
||||||
+ " --header 'Accept: */*' "
|
+ " --header 'Accept: application/octet-stream' "
|
||||||
+ " --header 'Content-Type: application/octet-stream' "
|
+ f" | cmp /tmp/{file_name}"
|
||||||
+ f" --data-binary '@/tmp/{file_name}' "
|
)
|
||||||
)
|
|
||||||
|
|
||||||
machine.succeed(
|
machine.shutdown()
|
||||||
f"curl -sSf -X 'GET' -b 'grocy_session={cookie}' "
|
'';
|
||||||
+ f" 'http://localhost/api/files/equipmentmanuals/{file_name_base64_urlencode}' "
|
}
|
||||||
+ " --header 'Accept: application/octet-stream' "
|
|
||||||
+ f" | cmp /tmp/{file_name}"
|
|
||||||
)
|
|
||||||
|
|
||||||
machine.shutdown()
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue