mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-06-27 19:49:31 +00:00
chore: mock registry server for ci
This commit is contained in:
parent
9b4c8c49a0
commit
616df843c1
46
.github/scripts/mock-registry.py
vendored
Normal file
46
.github/scripts/mock-registry.py
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Mock keypackage/account registry for the chat-cli CI smoketest.
|
||||
|
||||
On startup the client registers its keypackage and account bundle. Publishing the
|
||||
bundle first fetches any existing record, so the stub answers:
|
||||
|
||||
* POST /v0/keypackage, POST /v0/account -> 200 (accept the write)
|
||||
* GET (any) -> 404 (nothing published yet)
|
||||
|
||||
A 404 is what a fresh account looks like, which the client reads as "no existing
|
||||
record". This validates nothing — it only unblocks the smoketest; protocol-level
|
||||
behavior is covered by the workspace tests.
|
||||
"""
|
||||
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
# Match the client's HTTP/1.1 requests so reqwest frames the response body.
|
||||
protocol_version = "HTTP/1.1"
|
||||
|
||||
def _drain(self):
|
||||
# Consume the request body so the client's request completes cleanly.
|
||||
length = int(self.headers.get("Content-Length", 0))
|
||||
if length:
|
||||
self.rfile.read(length)
|
||||
|
||||
def _reply(self, status):
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Length", "0")
|
||||
self.end_headers()
|
||||
|
||||
def do_POST(self):
|
||||
self._drain()
|
||||
self._reply(200)
|
||||
|
||||
def do_GET(self):
|
||||
self._drain()
|
||||
self._reply(404)
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
HTTPServer(("127.0.0.1", 18080), Handler).serve_forever()
|
||||
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -73,4 +73,15 @@ jobs:
|
||||
- name: Build chat-cli (logos-delivery)
|
||||
run: nix develop -c bash -c 'LOGOS_DELIVERY_LIB_DIR=./result/lib cargo build --release -p chat-cli'
|
||||
- name: Run chat-cli smoketest
|
||||
run: nix develop -c ./target/release/chat-cli --name ci-test --smoketest
|
||||
# The client registers against the keypackage/account registry on
|
||||
# startup, so stand up a mock that accepts those calls. It runs on the
|
||||
# system Python (no Nix needed); only chat-cli needs the dev shell.
|
||||
run: |
|
||||
python3 .github/scripts/mock-registry.py &
|
||||
mock_pid=$!
|
||||
trap 'kill "$mock_pid" 2>/dev/null || true' EXIT
|
||||
for _ in $(seq 1 50); do
|
||||
curl -s -o /dev/null http://127.0.0.1:18080/ && break
|
||||
sleep 0.2
|
||||
done
|
||||
nix develop -c ./target/release/chat-cli --name ci-test --smoketest
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user