mirror of
https://github.com/denoland/deno.git
synced 2025-02-07 23:06:50 -05:00
chore: fix some broken pty tests on windows (#27899)
These have been failing locally for some time.
This commit is contained in:
parent
7643bb71a6
commit
d5c105b30e
1 changed files with 36 additions and 18 deletions
|
@ -250,7 +250,7 @@ fn permissions_prompt_allow_all() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all run access.");
|
||||
console.expect("Granted all run access.");
|
||||
// "read" permissions
|
||||
console.expect(concat!(
|
||||
"┏ ⚠️ Deno requests read access to \"FOO\".\r\n",
|
||||
|
@ -262,7 +262,7 @@ fn permissions_prompt_allow_all() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all read access.");
|
||||
console.expect("Granted all read access.");
|
||||
// "write" permissions
|
||||
console.expect(concat!(
|
||||
"┏ ⚠️ Deno requests write access to \"FOO\".\r\n",
|
||||
|
@ -274,7 +274,7 @@ fn permissions_prompt_allow_all() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all write access.");
|
||||
console.expect("Granted all write access.");
|
||||
// "net" permissions
|
||||
console.expect(concat!(
|
||||
"┏ ⚠️ Deno requests net access to \"foo\".\r\n",
|
||||
|
@ -286,7 +286,7 @@ fn permissions_prompt_allow_all() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all net access.");
|
||||
console.expect("Granted all net access.");
|
||||
// "env" permissions
|
||||
console.expect(concat!(
|
||||
"┏ ⚠️ Deno requests env access to \"FOO\".\r\n",
|
||||
|
@ -298,7 +298,7 @@ fn permissions_prompt_allow_all() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all env access.");
|
||||
console.expect("Granted all env access.");
|
||||
// "sys" permissions
|
||||
console.expect(concat!(
|
||||
"┏ ⚠️ Deno requests sys access to \"loadavg\".\r\n",
|
||||
|
@ -310,7 +310,7 @@ fn permissions_prompt_allow_all() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all sys access.");
|
||||
console.expect("Granted all sys access.");
|
||||
// "ffi" permissions
|
||||
console.expect(concat!(
|
||||
"┏ ⚠️ Deno requests ffi access to \"FOO\".\r\n",
|
||||
|
@ -322,7 +322,7 @@ fn permissions_prompt_allow_all() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all ffi access.")
|
||||
console.expect("Granted all ffi access.")
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ fn permissions_prompt_allow_all_2() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all env access.");
|
||||
console.expect("Granted all env access.");
|
||||
|
||||
// "sys" permissions
|
||||
console.expect(concat!(
|
||||
|
@ -356,7 +356,7 @@ fn permissions_prompt_allow_all_2() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all sys access.");
|
||||
console.expect("Granted all sys access.");
|
||||
|
||||
let text = console.read_until("Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)");
|
||||
// "read" permissions
|
||||
|
@ -371,7 +371,7 @@ fn permissions_prompt_allow_all_2() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all read access.");
|
||||
console.expect("Granted all read access.");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ fn permissions_cache() {
|
|||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
console.expect("✅ Granted read access to \"foo\".");
|
||||
console.expect("Granted read access to \"foo\".");
|
||||
console.expect("granted");
|
||||
console.expect("prompt");
|
||||
});
|
||||
|
@ -455,7 +455,7 @@ fn permissions_trace() {
|
|||
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
console.expect("✅ Granted sys access to \"hostname\".");
|
||||
console.expect("Granted sys access to \"hostname\".");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2762,20 +2762,38 @@ fn stdio_streams_are_locked_in_permission_prompt() {
|
|||
// The worker is blocked, so nothing else should get written here
|
||||
console.human_delay();
|
||||
console.write_line_raw("i");
|
||||
// We ensure that nothing gets written here between the permission prompt and this text, despire the delay
|
||||
// We ensure that nothing gets written here between the permission prompt and this text, despite the delay
|
||||
let newline = if cfg!(target_os = "linux") {
|
||||
"^J"
|
||||
} else {
|
||||
"\r\n"
|
||||
};
|
||||
console.expect_raw_next(format!("i{newline}\u{1b}[1A\u{1b}[0J┗ Unrecognized option. Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) > "));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
// We ensure that nothing gets written here between the permission prompt and this text, despire the delay
|
||||
console.expect_raw_next(format!("y{newline}\x1b[6A\x1b[0J✅ Granted read access to \""));
|
||||
if cfg!(windows) {
|
||||
// it's too difficult to inspect the raw text on windows because the console
|
||||
// outputs a bunch of control characters, so we instead rely on the last assertion
|
||||
// in this test that checks to ensure we didn't receive any malicious output during
|
||||
// the permission prompts
|
||||
console.expect("Unrecognized option. Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) >");
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
console.expect("Granted read access to");
|
||||
} else {
|
||||
console.expect_raw_next(format!("i{newline}\u{1b}[1A\u{1b}[0J┗ Unrecognized option. Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) > "));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
// We ensure that nothing gets written here between the permission prompt and this text, despite the delay
|
||||
console.expect_raw_next(format!("y{newline}\x1b[6A\x1b[0J✅ Granted read access to \""));
|
||||
}
|
||||
|
||||
// Back to spamming!
|
||||
console.expect(malicious_output);
|
||||
|
||||
// Ensure during the permission prompt showing we didn't receive any malicious output
|
||||
let all_text = console.all_output();
|
||||
let start_prompt_index = all_text.find("Allow?").unwrap();
|
||||
let end_prompt_index = all_text.find("Granted read access to").unwrap();
|
||||
let prompt_text = &all_text[start_prompt_index..end_prompt_index];
|
||||
assert!(!prompt_text.contains(malicious_output), "Prompt text: {:?}", prompt_text);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue