24 lines
717 B
Python
24 lines
717 B
Python
|
|
"""WebSSH terminal DATA payload encoding (ANSI-safe base64)."""
|
||
|
|
import base64
|
||
|
|
|
||
|
|
from server.api.webssh import WEBSSH_PTY_ENV, _terminal_payload_b64
|
||
|
|
|
||
|
|
|
||
|
|
def test_pty_env_has_color_term():
|
||
|
|
assert WEBSSH_PTY_ENV["TERM"] == "xterm-256color"
|
||
|
|
assert WEBSSH_PTY_ENV["COLORTERM"] == "truecolor"
|
||
|
|
assert WEBSSH_PTY_ENV["FORCE_COLOR"] == "1"
|
||
|
|
|
||
|
|
|
||
|
|
def test_terminal_payload_b64_preserves_ansi_escapes():
|
||
|
|
raw = "\x1b[31mred\x1b[32mgreen\x1b[0m\n"
|
||
|
|
b64 = _terminal_payload_b64(raw)
|
||
|
|
decoded = base64.b64decode(b64)
|
||
|
|
assert decoded == raw.encode("utf-8")
|
||
|
|
|
||
|
|
|
||
|
|
def test_terminal_payload_b64_from_bytes():
|
||
|
|
raw = b"\x1b[33myellow\x1b[0m"
|
||
|
|
b64 = _terminal_payload_b64(raw)
|
||
|
|
assert base64.b64decode(b64) == raw
|