2024-09-26 11:04:55 +00:00
|
|
|
import ../make-test-python.nix (
|
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
name = "immich-nixos";
|
|
|
|
|
|
|
|
nodes.machine =
|
|
|
|
{ pkgs, ... }:
|
|
|
|
{
|
|
|
|
# These tests need a little more juice
|
|
|
|
virtualisation = {
|
|
|
|
cores = 2;
|
|
|
|
memorySize = 2048;
|
|
|
|
diskSize = 4096;
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [ immich-cli ];
|
|
|
|
|
|
|
|
services.immich = {
|
|
|
|
enable = true;
|
|
|
|
environment.IMMICH_LOG_LEVEL = "verbose";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
import json
|
|
|
|
|
|
|
|
machine.wait_for_unit("immich-server.service")
|
|
|
|
|
2024-10-11 05:15:48 +00:00
|
|
|
machine.wait_for_open_port(2283) # Server
|
2024-09-26 11:04:55 +00:00
|
|
|
machine.wait_for_open_port(3003) # Machine learning
|
2024-10-11 05:15:48 +00:00
|
|
|
machine.succeed("curl --fail http://localhost:2283/")
|
2024-09-26 11:04:55 +00:00
|
|
|
|
|
|
|
machine.succeed("""
|
2024-10-11 05:15:48 +00:00
|
|
|
curl -H 'Content-Type: application/json' --data '{ "email": "test@example.com", "name": "Admin", "password": "admin" }' -X POST http://localhost:2283/api/auth/admin-sign-up
|
2024-09-26 11:04:55 +00:00
|
|
|
""")
|
|
|
|
res = machine.succeed("""
|
2024-10-11 05:15:48 +00:00
|
|
|
curl -H 'Content-Type: application/json' --data '{ "email": "test@example.com", "password": "admin" }' -X POST http://localhost:2283/api/auth/login
|
2024-09-26 11:04:55 +00:00
|
|
|
""")
|
|
|
|
token = json.loads(res)['accessToken']
|
|
|
|
|
|
|
|
res = machine.succeed("""
|
2024-10-11 05:15:48 +00:00
|
|
|
curl -H 'Content-Type: application/json' -H 'Cookie: immich_access_token=%s' --data '{ "name": "API Key", "permissions": ["all"] }' -X POST http://localhost:2283/api/api-keys
|
2024-09-26 11:04:55 +00:00
|
|
|
""" % token)
|
|
|
|
key = json.loads(res)['secret']
|
|
|
|
|
2024-10-11 05:15:48 +00:00
|
|
|
machine.succeed(f"immich login http://localhost:2283/api {key}")
|
2024-09-26 11:04:55 +00:00
|
|
|
res = machine.succeed("immich server-info")
|
|
|
|
print(res)
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
)
|