fix(remote): treat declined device authorization as cancellation

This commit is contained in:
Xubin Ren committed 2026-10-02 11:36:34 +08:00
1 parent 3ac60f0780
commit 92b0f1d285
2 files changed
+5 -2

No files matched your search

+3 -1
View File
@@ -127,7 +127,9 @@ def pair(
host = _default_host() or typer.prompt("Server public IP or hostname (shown in your cloud console)")
typer.echo(f"\nAuthorize {invitation.label} to use nanobot on {ssh_user}@{host}?\nConfig: {config}\nServer fingerprint: {fingerprint(host_key)}")
typer.echo("This grants full nanobot WebUI access, including configured tools and settings.\nA dedicated SSH key can only reach this nanobot port; no shell or other forwarding.\nAuthorization lasts 90 days. No existing keys, firewall rules or model settings change.")
typer.confirm("Authorize this computer?", abort=True, default=False)
if not typer.confirm("Authorize this computer?", default=False):
typer.echo("Cancelled. No device was authorized. Run the pairing command again when ready.")
return
# Check the service is running before granting access; no credential is sent.
import socket
+2 -1
View File
@@ -114,8 +114,9 @@ def test_readable_config_still_requires_device_authorization(protected):
protected.metadata.side_effect = None
protected.metadata.return_value = {"port": 8765}
result = CliRunner().invoke(remote.app, protected.args + ["--host", "example.com"], input="n\n")
assert result.exit_code == 1
assert result.exit_code == 0
assert "Authorize this computer?" in result.output
assert "Cancelled. No device was authorized" in result.output
assert "Continue as server administrator?" not in result.output
protected.run.assert_not_called()
protected.authorize.assert_not_called()