mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
nixosTests.artalk: add auth test
This commit is contained in:
parent
9bfc63096a
commit
8a7f909947
2 changed files with 49 additions and 21 deletions
|
@ -135,7 +135,7 @@ in {
|
||||||
archi = handleTest ./archi.nix {};
|
archi = handleTest ./archi.nix {};
|
||||||
aria2 = handleTest ./aria2.nix {};
|
aria2 = handleTest ./aria2.nix {};
|
||||||
armagetronad = handleTest ./armagetronad.nix {};
|
armagetronad = handleTest ./armagetronad.nix {};
|
||||||
artalk = handleTest ./artalk.nix {};
|
artalk = runTest ./artalk.nix;
|
||||||
atd = handleTest ./atd.nix {};
|
atd = handleTest ./atd.nix {};
|
||||||
atop = handleTest ./atop.nix {};
|
atop = handleTest ./atop.nix {};
|
||||||
atticd = runTest ./atticd.nix;
|
atticd = runTest ./atticd.nix;
|
||||||
|
|
|
@ -1,28 +1,56 @@
|
||||||
import ./make-test-python.nix (
|
{ lib, pkgs, ... }:
|
||||||
{ lib, pkgs, ... }:
|
{
|
||||||
{
|
|
||||||
|
|
||||||
name = "artalk";
|
name = "artalk";
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
maintainers = with lib.maintainers; [ moraxyc ];
|
maintainers = with lib.maintainers; [ moraxyc ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes.machine =
|
nodes.machine =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = [ pkgs.curl ];
|
environment.systemPackages = [
|
||||||
services.artalk = {
|
pkgs.curl
|
||||||
enable = true;
|
pkgs.artalk
|
||||||
|
pkgs.sudo
|
||||||
|
];
|
||||||
|
services.artalk = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
cache.enabled = true;
|
||||||
|
admin_users = [
|
||||||
|
{
|
||||||
|
name = "admin";
|
||||||
|
email = "admin@example.org";
|
||||||
|
# md5 for 'password'
|
||||||
|
password = "(md5)5F4DCC3B5AA765D61D8327DEB882CF99";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
machine.wait_for_unit("artalk.service")
|
import json
|
||||||
|
machine.wait_for_unit("artalk.service")
|
||||||
|
|
||||||
machine.wait_for_open_port(23366)
|
machine.wait_for_open_port(23366)
|
||||||
|
|
||||||
machine.succeed("curl --fail --max-time 10 http://127.0.0.1:23366/")
|
assert '${pkgs.artalk.version}' in machine.succeed("curl --fail --max-time 10 http://127.0.0.1:23366/api/v2/version")
|
||||||
'';
|
|
||||||
}
|
# Get token
|
||||||
)
|
result = json.loads(machine.succeed("""
|
||||||
|
curl --fail -X POST --json '{
|
||||||
|
"email": "admin@example.org",
|
||||||
|
"password": "password"
|
||||||
|
}' 'http://127.0.0.1:23366/api/v2/auth/email/login'
|
||||||
|
"""))
|
||||||
|
token = result['token']
|
||||||
|
|
||||||
|
# Test admin
|
||||||
|
machine.succeed(f"""
|
||||||
|
curl --fail -X POST --header 'Authorization: {token}' 'http://127.0.0.1:23366/api/v2/cache/flush'
|
||||||
|
""")
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue