1 import ./make-test-python.nix ({ pkgs, lib, ...} : {
3 meta = with pkgs.lib.maintainers; {
4 maintainers = [ ma27 ];
7 nodes.machine = { pkgs, ... }: {
8 virtualisation.memorySize = 2047;
11 settings.db.host = "/run/postgresql";
12 settings.db.user = "wiki-js";
13 settings.db.db = "wiki-js";
14 settings.logLevel = "debug";
16 services.postgresql = {
18 ensureDatabases = [ "wiki-js" ];
21 ensureDBOwnership = true;
25 systemd.services.wiki-js = {
26 requires = [ "postgresql.service" ];
27 after = [ "postgresql.service" ];
29 environment.systemPackages = with pkgs; [ jq ];
33 payloads.finalize = pkgs.writeText "finalize.json" (builtins.toJSON {
34 adminEmail = "webmaster@example.com";
35 adminPassword = "notapassword";
36 adminPasswordConfirm = "notapassword";
37 siteUrl = "http://localhost:3000";
40 payloads.login = pkgs.writeText "login.json" (builtins.toJSON [{
44 mutation ($username: String!, $password: String!, $strategy: String!) {
46 login(username: $username, password: $password, strategy: $strategy) {
68 password = "notapassword";
70 username = "webmaster@example.com";
73 payloads.content = pkgs.writeText "content.json" (builtins.toJSON [{
77 mutation ($content: String!, $description: String!, $editor: String!, $isPrivate: Boolean!, $isPublished: Boolean!, $locale: String!, $path: String!, $publishEndDate: Date, $publishStartDate: Date, $scriptCss: String, $scriptJs: String, $tags: [String]!, $title: String!) {
79 create(content: $content, description: $description, editor: $editor, isPrivate: $isPrivate, isPublished: $isPublished, locale: $locale, path: $path, publishEndDate: $publishEndDate, publishStartDate: $publishStartDate, scriptCss: $scriptCss, scriptJs: $scriptJs, tags: $tags, title: $title) {
99 content = "# Header\n\nHello world!";
107 publishStartDate = "";
111 title = "Hello world";
116 machine.wait_for_unit("multi-user.target")
117 machine.wait_for_open_port(3000)
119 machine.succeed("curl -sSf localhost:3000")
121 with subtest("Setup"):
122 result = machine.succeed(
123 "curl -sSf localhost:3000/finalize -X POST -d "
124 + "@${payloads.finalize} -H 'Content-Type: application/json' "
125 + "| jq .ok | xargs echo"
127 assert result.strip() == "true", f"Expected true, got {result}"
129 # During the setup the service gets restarted, so we use this
130 # to check if the setup is done.
131 machine.wait_until_fails("curl -sSf localhost:3000")
132 machine.wait_until_succeeds("curl -sSf localhost:3000")
134 with subtest("Base functionality"):
135 auth = machine.succeed(
136 "curl -sSf localhost:3000/graphql -X POST "
137 + "-d @${payloads.login} -H 'Content-Type: application/json' "
138 + "| jq '.[0].data.authentication.login.jwt' | xargs echo"
143 create = machine.succeed(
144 "curl -sSf localhost:3000/graphql -X POST "
145 + "-d @${payloads.content} -H 'Content-Type: application/json' "
146 + f"-H 'Authorization: Bearer {auth}' "
147 + "| jq '.[0].data.pages.create.responseResult.succeeded'|xargs echo"
149 assert create.strip() == "true", f"Expected true, got {create}"