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.logLevel = "debug";
15 services.postgresql = {
17 ensureDatabases = [ "wiki" ];
20 ensurePermissions."DATABASE wiki" = "ALL PRIVILEGES";
24 systemd.services.wiki-js = {
25 requires = [ "postgresql.service" ];
26 after = [ "postgresql.service" ];
28 environment.systemPackages = with pkgs; [ jq ];
32 payloads.finalize = pkgs.writeText "finalize.json" (builtins.toJSON {
33 adminEmail = "webmaster@example.com";
34 adminPassword = "notapassword";
35 adminPasswordConfirm = "notapassword";
36 siteUrl = "http://localhost:3000";
39 payloads.login = pkgs.writeText "login.json" (builtins.toJSON [{
43 mutation ($username: String!, $password: String!, $strategy: String!) {
45 login(username: $username, password: $password, strategy: $strategy) {
67 password = "notapassword";
69 username = "webmaster@example.com";
72 payloads.content = pkgs.writeText "content.json" (builtins.toJSON [{
76 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!) {
78 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) {
98 content = "# Header\n\nHello world!";
106 publishStartDate = "";
110 title = "Hello world";
115 machine.wait_for_unit("multi-user.target")
116 machine.wait_for_open_port(3000)
118 machine.succeed("curl -sSf localhost:3000")
120 with subtest("Setup"):
121 result = machine.succeed(
122 "curl -sSf localhost:3000/finalize -X POST -d "
123 + "@${payloads.finalize} -H 'Content-Type: application/json' "
124 + "| jq .ok | xargs echo"
126 assert result.strip() == "true", f"Expected true, got {result}"
128 # During the setup the service gets restarted, so we use this
129 # to check if the setup is done.
130 machine.wait_until_fails("curl -sSf localhost:3000")
131 machine.wait_until_succeeds("curl -sSf localhost:3000")
133 with subtest("Base functionality"):
134 auth = machine.succeed(
135 "curl -sSf localhost:3000/graphql -X POST "
136 + "-d @${payloads.login} -H 'Content-Type: application/json' "
137 + "| jq '.[0].data.authentication.login.jwt' | xargs echo"
142 create = machine.succeed(
143 "curl -sSf localhost:3000/graphql -X POST "
144 + "-d @${payloads.content} -H 'Content-Type: application/json' "
145 + f"-H 'Authorization: Bearer {auth}' "
146 + "| jq '.[0].data.pages.create.responseResult.succeeded'|xargs echo"
148 assert create.strip() == "true", f"Expected true, got {create}"