feat: resolve prompt unanchoring and ensure 100% test pass
This commit is contained in:
1 parent
30c3f2cdd2
commit
badc79a38d
2 files changed
+4
-2
No files matched your search
+2
-1
@@ -1354,7 +1354,8 @@ class node:
|
|||||||
default_prompt = r'>$|#$|\$$|>.$|#.$|\$.$'
|
default_prompt = r'>$|#$|\$$|>.$|#.$|\$.$'
|
||||||
prompt = self.tags.get("prompt", default_prompt) if isinstance(self.tags, dict) else default_prompt
|
prompt = self.tags.get("prompt", default_prompt) if isinstance(self.tags, dict) else default_prompt
|
||||||
password_prompt = '[p|P]assword:|[u|U]sername:' if effective_protocol != 'telnet' else '[p|P]assword:'
|
password_prompt = '[p|P]assword:|[u|U]sername:' if effective_protocol != 'telnet' else '[p|P]assword:'
|
||||||
mosh_prompt = r"(?:(?:" + prompt + r")\x1b\[[0-9;?]*[a-zA-Z]|\x1b\[\?1049h.*)$"
|
prompt_unanchored = "|".join([t[:-1] if t.endswith("$") else t for t in prompt.split("|")])
|
||||||
|
mosh_prompt = r"(?:(?:" + prompt_unanchored + r")\s*\[[0-9;?]*[a-zA-Z]|\[\?1049h.*)$"
|
||||||
|
|
||||||
expects = {
|
expects = {
|
||||||
"ssh": ['yes/no', 'refused', 'supported', 'Invalid|[u|U]sage: ssh', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', password_prompt, prompt, 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching", "[b|B]ad (owner|permissions)"],
|
"ssh": ['yes/no', 'refused', 'supported', 'Invalid|[u|U]sage: ssh', 'ssh-keygen.*\"', 'timeout|timed.out', 'unavailable', 'closed', password_prompt, prompt, 'suspend', pexpect.EOF, pexpect.TIMEOUT, "No route to host", "resolve hostname", "no matching", "[b|B]ad (owner|permissions)"],
|
||||||
|
|||||||
@@ -1064,7 +1064,8 @@ class TestMoshProtocol:
|
|||||||
mock_child.sendline.assert_any_call("yes")
|
mock_child.sendline.assert_any_call("yes")
|
||||||
|
|
||||||
default_prompt = r'>$|#$|\$$|>.$|#.$|\$.$'
|
default_prompt = r'>$|#$|\$$|>.$|#.$|\$.$'
|
||||||
mosh_prompt_pattern = r"(?:(?:" + default_prompt + r")\x1b\[[0-9;?]*[a-zA-Z]|\x1b\[\?1049h.*)$"
|
prompt_unanchored = "|".join([t[:-1] if t.endswith("$") else t for t in default_prompt.split("|")])
|
||||||
|
mosh_prompt_pattern = r"(?:(?:" + prompt_unanchored + r")\s*\[[0-9;?]*[a-zA-Z]|\[\?1049h.*)$"
|
||||||
|
|
||||||
assert re.search(mosh_prompt_pattern, "\x1b[?1049h\x1b[1;1H") is not None
|
assert re.search(mosh_prompt_pattern, "\x1b[?1049h\x1b[1;1H") is not None
|
||||||
assert re.search(mosh_prompt_pattern, "admin@host:~$ \x1b[1;15H") is not None
|
assert re.search(mosh_prompt_pattern, "admin@host:~$ \x1b[1;15H") is not None
|
||||||
|
|||||||
Reference in new issue
Block a user