#!/usr/bin/env python3 """tests/cgi.py - the control JSON API of plugin_github, driven as real CGI. The binary is spawned per request with QUERY_STRING / REQUEST_METHOD / CONTENT_LENGTH + stdin, exactly the way scorpiox-server invokes it, so the CGI contract itself is what is tested: * every ?action= without the node password is 401 (never "works anyway") * status / save / test / tools / clear answer valid JSON with the right fields, and NONE of them ever contains the saved token text * save writes config.json at mode 0600 under SX_CONNECTOR_DIR * save validates the api base (rejects a userinfo URL, accepts the mock's loopback http base) * test relays GitHub's own "Bad credentials" for a wrong token, and the account login for a good one * clear deletes the token and keeps the api base * the HTML page: 200, no