Library sync OsmAnd-style: brick is the server, a client (the car's maptool, SYNC_SERVER_URL) syncs on its Sync button — pulls the server's rows, pushes its own with the source files the server lacks, newer updated_at wins; /api/sync/* guarded by SYNC_TOKEN (written into brick's .env by CI). TRUSTED_NETWORKS logs in the car's LAN (no Gitea offline); TAKEOUT_HOST_DIR for a server without the Takeout; bin/pull-maps.sh pulls map data one way while at home
CI / check (push) Successful in 22s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-27 23:22:32 +01:00
1 parent 850a5946ad
commit dbe742321a
13 files changed
+460 -5

No files matched your search

+15
View File
@@ -137,6 +137,21 @@ class AppTest < Minitest::Test
assert_equal 401, request.get("/api/live").status
end
def test_the_sync_feed_needs_the_sync_token
# No SYNC_TOKEN in tests: closed, even with a login or an empty bearer.
assert_equal 401, request.get("/api/sync/changes").status
assert_equal 401, request.get("/api/sync/changes", "HTTP_AUTHORIZATION" => "Bearer ", **logged_in_env).status
assert_equal 401, request.get("/api/sync/source/x").status
assert_equal 401, request.post("/api/sync/apply", input: "{}").status
assert_equal 401, request.put("/api/sync/source/x", input: "x").status
end
def test_the_sync_button_is_only_a_clients
assert_equal 401, request.post("/api/sync/run").status
assert_equal 404, request.post("/api/sync/run", **logged_in_env).status
refute_includes request.get("/", **logged_in_env).body, "data-sync-client"
end
def test_can_requires_login_and_is_off_without_a_config
assert_equal 401, request.get("/api/can").status
assert_equal({ "interfaces" => {}, "nodes" => {}, "signals" => {}, "available" => false }, json_body(request.get("/api/can", **logged_in_env)))