moo.shell.tests.test_server

Tests for moo.shell.server — SSH session lifecycle and authentication logic.

Tests that require a live asyncssh server (interact, server()) are excluded; the testable surface is MooPromptToolkitSSHSession, SSHServer auth methods, and session_requested().

Functions

test_data_received_full_mtts_negotiation_flow()

End-to-end dance: client says WILL TTYPE, server asks three times, client finishes with an MTTS bitfield.

test_data_received_mirrors_capabilities_after_do_gmcp()

End-to-end: a client that enables GMCP via DO (without running TTYPE) should see the gmcp capability land in _session_settings immediately, so Celery verbs picking up the next command see GMCP as available.

test_data_received_strips_iac_and_forwards_residual()

data_received pulls IAC frames out of the surrogate-escaped str stream and forwards plain text to prompt_toolkit's input pipe.

test_dispatch_editor_cancel_pops_pending()

Editor.Cancel removes the pending edit without invoking the callback.

test_dispatch_editor_save_invokes_callback()

Editor.Save with a known edit_id schedules invoke_verb.delay with the saved metadata.

test_dispatch_editor_save_rejects_non_wizard_caller()

Editor.Save bound to a non-wizard caller is dropped without dispatching.

test_dispatch_editor_save_unknown_id_is_noop()

An Editor.Save with an unknown edit_id logs and returns without crashing.

test_is_mud_term_recognizes_known_clients_and_raw_opt_in()

The TERM heuristic gates everything IAC-related.

test_on_gmcp_dispatches_core_supports()

The _on_gmcp top-level dispatcher routes Core.Supports.Set to the recorder.

test_record_gmcp_supports_add_merges()

Core.Supports.Add merges into existing gmcp_packages without clearing.

test_record_gmcp_supports_ignores_non_list_payload()

A malformed payload (not a list) is ignored without raising.

test_record_gmcp_supports_remove_drops_packages()

Core.Supports.Remove pops named packages; version field on remove is optional.

test_record_gmcp_supports_set_replaces_packages()

Core.Supports.Set wipes any existing gmcp_packages and installs the new list.

test_session_requested_sets_user()

session_requested() returns a MooPromptToolkitSSHSession with user assigned.

test_session_started_clears_stale_iac_cache_for_vanilla_term()

A vanilla SSH session must wipe any leftover iac cache from a previous MUD-client session.

test_session_started_default_term_is_rich_mode()

A normal terminal (e.g. xterm-256color) produces rich mode.

test_session_started_emits_iac_only_for_mud_clients()

xterm-256-basic opts into IAC; vanilla xterm leaves the channel untouched.

test_session_started_moo_automation_term_is_no_longer_special_cased()

The legacy TERM=moo-automation special case has been removed; treated as a vanilla terminal.

test_session_started_switches_encoding_policy_for_mud_clients()

For MUD-client TERM, session_started flips the channel encoding to surrogate-escape UTF-8 so 0xFF IAC bytes round-trip cleanly.

test_session_started_unknown_term_skips_iac()

A non-MUD TERM (e.g. left over from the retired moo-automation client) skips IAC negotiation.

test_session_started_xterm_256_basic_sets_raw_mode()

TERM=xterm-256-basic selects raw mode; whitespace and case are tolerated.

test_validate_password_correct()

validate_password returns True and sets server.user when password is correct.

test_validate_password_incorrect()

validate_password returns False when the password is wrong.

test_validate_password_nonexistent_user()

validate_password returns False (not an exception) for an unknown username.