···
1
-
import ./make-test-python.nix (
5
-
meta = with pkgs.lib.maintainers; {
6
-
maintainers = [ ma27 ];
4
+
meta = with pkgs.lib.maintainers; {
5
+
maintainers = [ ma27 ];
12
-
virtualisation.memorySize = 2047;
13
-
services.wiki-js = {
15
-
settings.db.host = "/run/postgresql";
16
-
settings.db.user = "wiki-js";
17
-
settings.db.db = "wiki-js";
18
-
settings.logLevel = "debug";
20
-
services.postgresql = {
22
-
ensureDatabases = [ "wiki-js" ];
26
-
ensureDBOwnership = true;
30
-
systemd.services.wiki-js = {
31
-
requires = [ "postgresql.service" ];
32
-
after = [ "postgresql.service" ];
34
-
environment.systemPackages = with pkgs; [ jq ];
11
+
virtualisation.memorySize = 2047;
12
+
services.wiki-js = {
14
+
settings.db.host = "/run/postgresql";
15
+
settings.db.user = "wiki-js";
16
+
settings.db.db = "wiki-js";
17
+
settings.logLevel = "debug";
39
-
payloads.finalize = pkgs.writeText "finalize.json" (
41
-
adminEmail = "webmaster@example.com";
42
-
adminPassword = "notapassword";
43
-
adminPasswordConfirm = "notapassword";
44
-
siteUrl = "http://localhost:3000";
19
+
services.postgresql = {
21
+
ensureDatabases = [ "wiki-js" ];
25
+
ensureDBOwnership = true;
48
-
payloads.login = pkgs.writeText "login.json" (
51
-
operationName = null;
54
-
mutation ($username: String!, $password: String!, $strategy: String!) {
56
-
login(username: $username, password: $password, strategy: $strategy) {
29
+
systemd.services.wiki-js = {
30
+
requires = [ "postgresql.service" ];
31
+
after = [ "postgresql.service" ];
33
+
environment.systemPackages = with pkgs; [ jq ];
38
+
payloads.finalize = pkgs.writeText "finalize.json" (
40
+
adminEmail = "webmaster@example.com";
41
+
adminPassword = "notapassword";
42
+
adminPasswordConfirm = "notapassword";
43
+
siteUrl = "http://localhost:3000";
47
+
payloads.login = pkgs.writeText "login.json" (
50
+
operationName = null;
53
+
mutation ($username: String!, $password: String!, $strategy: String!) {
55
+
login(username: $username, password: $password, strategy: $strategy) {
78
-
password = "notapassword";
80
-
username = "webmaster@example.com";
85
-
payloads.content = pkgs.writeText "content.json" (
89
-
operationName = null;
91
-
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!) {
93
-
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) {
77
+
password = "notapassword";
79
+
username = "webmaster@example.com";
84
+
payloads.content = pkgs.writeText "content.json" (
88
+
operationName = null;
90
+
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!) {
92
+
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) {
113
-
content = "# Header\n\nHello world!";
115
-
editor = "markdown";
117
-
isPublished = true;
120
-
publishEndDate = "";
121
-
publishStartDate = "";
125
-
title = "Hello world";
133
-
machine.wait_for_unit("multi-user.target")
134
-
machine.wait_for_open_port(3000)
112
+
content = "# Header\n\nHello world!";
114
+
editor = "markdown";
116
+
isPublished = true;
119
+
publishEndDate = "";
120
+
publishStartDate = "";
124
+
title = "Hello world";
132
+
machine.wait_for_unit("multi-user.target")
133
+
machine.wait_for_open_port(3000)
136
-
machine.succeed("curl -sSf localhost:3000")
135
+
machine.succeed("curl -sSf localhost:3000")
138
-
with subtest("Setup"):
139
-
result = machine.succeed(
140
-
"curl -sSf localhost:3000/finalize -X POST -d "
141
-
+ "@${payloads.finalize} -H 'Content-Type: application/json' "
142
-
+ "| jq .ok | xargs echo"
144
-
assert result.strip() == "true", f"Expected true, got {result}"
137
+
with subtest("Setup"):
138
+
result = machine.succeed(
139
+
"curl -sSf localhost:3000/finalize -X POST -d "
140
+
+ "@${payloads.finalize} -H 'Content-Type: application/json' "
141
+
+ "| jq .ok | xargs echo"
143
+
assert result.strip() == "true", f"Expected true, got {result}"
146
-
# During the setup the service gets restarted, so we use this
147
-
# to check if the setup is done.
148
-
machine.wait_until_fails("curl -sSf localhost:3000")
149
-
machine.wait_until_succeeds("curl -sSf localhost:3000")
145
+
# During the setup the service gets restarted, so we use this
146
+
# to check if the setup is done.
147
+
machine.wait_until_fails("curl -sSf localhost:3000")
148
+
machine.wait_until_succeeds("curl -sSf localhost:3000")
151
-
with subtest("Base functionality"):
152
-
auth = machine.succeed(
153
-
"curl -sSf localhost:3000/graphql -X POST "
154
-
+ "-d @${payloads.login} -H 'Content-Type: application/json' "
155
-
+ "| jq '.[0].data.authentication.login.jwt' | xargs echo"
150
+
with subtest("Base functionality"):
151
+
auth = machine.succeed(
152
+
"curl -sSf localhost:3000/graphql -X POST "
153
+
+ "-d @${payloads.login} -H 'Content-Type: application/json' "
154
+
+ "| jq '.[0].data.authentication.login.jwt' | xargs echo"
160
-
create = machine.succeed(
161
-
"curl -sSf localhost:3000/graphql -X POST "
162
-
+ "-d @${payloads.content} -H 'Content-Type: application/json' "
163
-
+ f"-H 'Authorization: Bearer {auth}' "
164
-
+ "| jq '.[0].data.pages.create.responseResult.succeeded'|xargs echo"
166
-
assert create.strip() == "true", f"Expected true, got {create}"
159
+
create = machine.succeed(
160
+
"curl -sSf localhost:3000/graphql -X POST "
161
+
+ "-d @${payloads.content} -H 'Content-Type: application/json' "
162
+
+ f"-H 'Authorization: Bearer {auth}' "
163
+
+ "| jq '.[0].data.pages.create.responseResult.succeeded'|xargs echo"
165
+
assert create.strip() == "true", f"Expected true, got {create}"