Make test in thrussh/src/lib pass
[?]
Jan 24, 2021, 11:11 AM
ZGJF6NR27RHVKL5VNPYVTAS5RVJSGNX7YRPBH5YX4UAVY7HAJHGACDependencies
- [2]
ATANAS43Fixing a test - [3]
7FRJYUI6Reboot because of a bad change - [4]
634OYCNMTokio 0.3 - [5]
2WEO7OZLVersion updates: getting rid of anyhow + moving to Tokio 1.0 - [6]
YSLHJU3IAdd a Close construct to ChannelMsg in the server
Change contents
- replacement in thrussh/src/lib.rs at line 643
use super::server::{Auth, Session};use super::server::{Auth, Server as _, Session}; - replacement in thrussh/src/lib.rs at line 650
test_compress(true).await}let _ = env_logger::try_init(); - replacement in thrussh/src/lib.rs at line 652
async fn test_compress(local: bool) {env_logger::try_init().unwrap_or(());let (client_key, addr) = if local {let client_key = thrussh_keys::key::KeyPair::generate_ed25519().unwrap();let client_pubkey = Arc::new(client_key.clone_public_key());let mut config = super::server::Config::default();config.preferred = super::Preferred::COMPRESSED;config.auth_rejection_time = std::time::Duration::from_secs(0);config.connection_timeout = None; // Some(std::time::Duration::from_secs(3));config.auth_rejection_time = std::time::Duration::from_secs(3);config.keys.push(thrussh_keys::key::KeyPair::generate_ed25519().unwrap());let config = Arc::new(config);let sh = Server {client_pubkey,clients: Arc::new(Mutex::new(HashMap::new())),id: 0,};tokio::spawn(super::server::run(config, "0.0.0.0:2222", sh));std::thread::sleep(std::time::Duration::from_millis(100));(client_key, "127.0.0.1:2222")} else {let client_key = thrussh_keys::load_secret_key("id_ed25519", None).unwrap();(client_key, "127.0.0.1:2222")let client_key = thrussh_keys::key::KeyPair::generate_ed25519().unwrap();let client_pubkey = Arc::new(client_key.clone_public_key());let mut config = server::Config::default();config.preferred = Preferred::COMPRESSED;config.connection_timeout = None; // Some(std::time::Duration::from_secs(3));config.auth_rejection_time = std::time::Duration::from_secs(3);config.keys.push(thrussh_keys::key::KeyPair::generate_ed25519().unwrap());let config = Arc::new(config);let mut sh = Server {client_pubkey,clients: Arc::new(Mutex::new(HashMap::new())),id: 0, - replacement in thrussh/src/lib.rs at line 668
let mut config = super::client::Config::default();config.preferred = super::Preferred::COMPRESSED;let socket = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();let addr = socket.local_addr().unwrap();tokio::spawn(async move {let (socket, _) = socket.accept().await.unwrap();let server = sh.new(socket.peer_addr().ok());server::run_stream(config, socket, server).await.unwrap();});let mut config = client::Config::default();config.preferred = Preferred::COMPRESSED; - edit in thrussh/src/lib.rs at line 680
let sh = Client {}; - replacement in thrussh/src/lib.rs at line 681
let mut session = super::client::connect(config, addr, sh).await.unwrap();debug!("connected");if sessiondbg!(&addr);let mut session = client::connect(config, addr, Client {}).await.unwrap();let authenticated = session - replacement in thrussh/src/lib.rs at line 686[3.300732]→[3.300732:300877](∅→∅),[3.300877]→[2.0:68](∅→∅),[2.68]→[3.300945:301174](∅→∅),[3.1265]→[3.300945:301174](∅→∅),[3.300945]→[3.300945:301174](∅→∅)
.unwrap(){debug!("authenticated");if let Ok(mut channel) = session.channel_open_session().await {channel.data(&b"Hello, world!"[..]).await.unwrap();if let Some(msg) = channel.wait().await {println!("{:?}", msg)}}}if local {std::thread::sleep(std::time::Duration::from_secs(40));.unwrap();assert!(authenticated);let mut channel = session.channel_open_session().await.unwrap();let data = &b"Hello, world!"[..];channel.data(data).await.unwrap();let msg = channel.wait().await.unwrap();match msg {ChannelMsg::Data { data: msg_data } => { assert_eq!(*data, *msg_data) },msg => panic!("Unexpected message {:?}", msg), - replacement in thrussh/src/lib.rs at line 741
fn data(self, _channel: ChannelId, data: &[u8], session: Session) -> Self::FutureUnit {fn data(self, channel: ChannelId, data: &[u8], mut session: Session) -> Self::FutureUnit { - edit in thrussh/src/lib.rs at line 743
session.data(channel, CryptoVec::from_slice(data)); - edit in thrussh/src/lib.rs at line 767
}fn channel_open_confirmation(self,channel: ChannelId,_: u32,_: u32,session: client::Session,) -> Self::FutureUnit {println!("channel_open_confirmation: {:?}", channel);self.finished(session)}fn data(self,channel: ChannelId,data: &[u8],session: client::Session,) -> Self::FutureUnit {debug!("client data on channel {:?}: {:?}",channel,std::str::from_utf8(data));self.finished(session)