Choose even the first region in the browser; update Docker and Nix
A node now starts without any region (it only helps others connect, and prints a hint). The owner's sign-in link leads straight to the Regions page when none is followed, visitors get a notice instead of an empty search, and status always lists regions as an array. The Docker image no longer pins Bonn, the NixOS module no longer requires regions, and the VM test now starts without any, chooses the first region over the API and checks it survives a restart. README and the init hint follow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
+15
-2
@@ -7,7 +7,7 @@ pkgs.testers.runNixOSTest {
|
||||
imports = [ module ];
|
||||
services.allmende = {
|
||||
enable = true;
|
||||
regions = [ "u1j" ];
|
||||
# No regions: the owner chooses the first one in the browser (see below).
|
||||
openFirewall = true;
|
||||
};
|
||||
};
|
||||
@@ -33,8 +33,21 @@ pkgs.testers.runNixOSTest {
|
||||
machine.wait_for_open_port(8080)
|
||||
machine.wait_for_open_port(4001)
|
||||
status = machine.succeed("curl -sf http://127.0.0.1:8080/api/v1/status")
|
||||
assert '"regions":["u1j"]' in status, status
|
||||
assert '"regions":[]' in status, status
|
||||
machine.succeed("curl -sf http://127.0.0.1:8080/ | grep -qi '<html'")
|
||||
# (no grep -q here: it would close the pipe early and make curl fail with exit 23)
|
||||
machine.succeed("curl -sf http://127.0.0.1:8080/places.tsv | grep -c '^Bonn'")
|
||||
|
||||
with subtest("the owner chooses the first region, and it survives a restart"):
|
||||
auth = "-H \"Authorization: Bearer $(cat /var/lib/allmende/admin.token)\""
|
||||
machine.succeed("test $(curl -s -o /dev/null -w '%{http_code}' -X PUT http://127.0.0.1:8080/api/v1/regions -d '{\"regions\":[\"u1j\"]}') = 401")
|
||||
machine.succeed(f"curl -sf {auth} -X PUT http://127.0.0.1:8080/api/v1/regions -d '{{\"regions\":[\"u1j\"]}}'")
|
||||
status = machine.succeed("curl -sf http://127.0.0.1:8080/api/v1/status")
|
||||
assert '"regions":["u1j"]' in status, status
|
||||
machine.succeed("systemctl restart allmende")
|
||||
machine.wait_for_open_port(8080)
|
||||
status = machine.succeed("curl -sf http://127.0.0.1:8080/api/v1/status")
|
||||
assert '"regions":["u1j"]' in status, status
|
||||
|
||||
with subtest("the owner API needs the admin token"):
|
||||
machine.succeed("test $(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8080/api/v1/mine) = 401")
|
||||
|
||||
Reference in New Issue
Block a user