-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
/
artalk.nix
56 lines (48 loc) · 1.29 KB
/
artalk.nix
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
45
46
47
48
49
50
51
52
53
54
55
56
{ lib, pkgs, ... }:
{
name = "artalk";
meta = {
maintainers = with lib.maintainers; [ moraxyc ];
};
nodes.machine =
{ pkgs, ... }:
{
environment.systemPackages = [
pkgs.curl
pkgs.artalk
pkgs.sudo
];
services.artalk = {
enable = true;
settings = {
cache.enabled = true;
admin_users = [
{
name = "admin";
email = "[email protected]";
# md5 for 'password'
password = "(md5)5F4DCC3B5AA765D61D8327DEB882CF99";
}
];
};
};
};
testScript = ''
import json
machine.wait_for_unit("artalk.service")
machine.wait_for_open_port(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": "[email protected]",
"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'
""")
'';
}