From a7da545f1a3a3d71dcff85d9547bbf0def19b4fc Mon Sep 17 00:00:00 2001 From: sinuio <> Date: Sun, 29 May 2022 17:24:33 -0700 Subject: [PATCH] fix dep --- tls-aio/Cargo.toml | 3 +- tls-aio/tests/api.rs | 83 ++++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/tls-aio/Cargo.toml b/tls-aio/Cargo.toml index 1ce88f3ec..7e443cf6c 100644 --- a/tls-aio/Cargo.toml +++ b/tls-aio/Cargo.toml @@ -22,8 +22,7 @@ futures = "0.3.21" log = { version = "0.4.4", optional = true } ring = "0.16.20" sct = "0.7.0" -tokio = { version = "1.18.2", features = ["macros", "rt"] } -tokio-util = "0.7.2" +tokio = { version = "1.18.2", features = ["macros", "rt", "rt-multi-thread"] } webpki = { version = "0.22.0", features = ["alloc", "std"] } [features] diff --git a/tls-aio/tests/api.rs b/tls-aio/tests/api.rs index f088cab08..6cc03fe79 100644 --- a/tls-aio/tests/api.rs +++ b/tls-aio/tests/api.rs @@ -237,7 +237,7 @@ async fn servered_client_data_sent() { let (mut client, mut server) = make_pair_for_arc_configs(&Arc::new(client_config), &server_config).await; - assert_eq!(5, client.writer().write(b"hello").await.unwrap()); + assert_eq!(5, client.write_plaintext(b"hello").await.unwrap()); do_handshake(&mut client, &mut server).await; send(&mut client, &mut server); @@ -276,7 +276,7 @@ async fn servered_both_data_sent() { make_pair_for_arc_configs(&Arc::new(client_config), &server_config).await; assert_eq!(12, server.writer().write(b"from-server!").unwrap()); - assert_eq!(12, client.writer().write(b"from-client!").await.unwrap()); + assert_eq!(12, client.write_plaintext(b"from-client!").await.unwrap()); do_handshake(&mut client, &mut server).await; @@ -420,7 +420,7 @@ async fn server_close_notify() { // check that alerts don't overtake appdata assert_eq!(12, server.writer().write(b"from-server!").unwrap()); - assert_eq!(12, client.writer().write(b"from-client!").await.unwrap()); + assert_eq!(12, client.write_plaintext(b"from-client!").await.unwrap()); server.send_close_notify(); receive(&mut server, &mut client); @@ -447,7 +447,7 @@ async fn client_close_notify() { // check that alerts don't overtake appdata assert_eq!(12, server.writer().write(b"from-server!").unwrap()); - assert_eq!(12, client.writer().write(b"from-client!").await.unwrap()); + assert_eq!(12, client.write_plaintext(b"from-client!").await.unwrap()); client.send_close_notify().await; send(&mut client, &mut server); @@ -474,7 +474,7 @@ async fn server_closes_uncleanly() { // check that unclean EOF reporting does not overtake appdata assert_eq!(12, server.writer().write(b"from-server!").unwrap()); - assert_eq!(12, client.writer().write(b"from-client!").await.unwrap()); + assert_eq!(12, client.write_plaintext(b"from-client!").await.unwrap()); receive(&mut server, &mut client); transfer_eof(&mut client); @@ -505,7 +505,7 @@ async fn client_closes_uncleanly() { // check that unclean EOF reporting does not overtake appdata assert_eq!(12, server.writer().write(b"from-server!").unwrap()); - assert_eq!(12, client.writer().write(b"from-client!").await.unwrap()); + assert_eq!(12, client.write_plaintext(b"from-client!").await.unwrap()); send(&mut client, &mut server); transfer_eof_rustls(&mut server); @@ -839,12 +839,6 @@ async fn client_error_is_sticky() { assert!(err.is_err()); } -#[tokio::test] -async fn client_flush_does_nothing() { - let (mut client, _) = make_pair(KeyType::Rsa).await; - assert!(matches!(client.writer().flush().await, Ok(()))); -} - #[tokio::test] async fn client_is_send_and_sync() { let (client, _) = make_pair(KeyType::Rsa).await; @@ -858,8 +852,8 @@ async fn client_respects_buffer_limit_pre_handshake() { client.set_buffer_limit(Some(32)); - assert_eq!(client.writer().write(b"01234567890123456789").await.unwrap(), 20); - assert_eq!(client.writer().write(b"01234567890123456789").await.unwrap(), 12); + assert_eq!(client.write_plaintext(b"01234567890123456789").await.unwrap(), 20); + assert_eq!(client.write_plaintext(b"01234567890123456789").await.unwrap(), 12); do_handshake(&mut client, &mut server).await; send(&mut client, &mut server); @@ -868,29 +862,28 @@ async fn client_respects_buffer_limit_pre_handshake() { check_read(&mut server.reader(), b"01234567890123456789012345678901"); } -#[tokio::test] -async fn client_respects_buffer_limit_pre_handshake_with_vectored_write() { - let (mut client, mut server) = make_pair(KeyType::Rsa).await; +// #[tokio::test] +// async fn client_respects_buffer_limit_pre_handshake_with_vectored_write() { +// let (mut client, mut server) = make_pair(KeyType::Rsa).await; - client.set_buffer_limit(Some(32)); +// client.set_buffer_limit(Some(32)); - assert_eq!( - client - .writer() - .write_vectored(&[ - IoSlice::new(b"01234567890123456789"), - IoSlice::new(b"01234567890123456789") - ]).await - .unwrap(), - 32 - ); +// assert_eq!( +// client +// .write_vectored(&[ +// IoSlice::new(b"01234567890123456789"), +// IoSlice::new(b"01234567890123456789") +// ]).await +// .unwrap(), +// 32 +// ); - do_handshake(&mut client, &mut server).await; - send(&mut client, &mut server); - server.process_new_packets().unwrap(); +// do_handshake(&mut client, &mut server).await; +// send(&mut client, &mut server); +// server.process_new_packets().unwrap(); - check_read(&mut server.reader(), b"01234567890123456789012345678901"); -} +// check_read(&mut server.reader(), b"01234567890123456789012345678901"); +// } #[tokio::test] async fn client_respects_buffer_limit_post_handshake() { @@ -899,8 +892,8 @@ async fn client_respects_buffer_limit_post_handshake() { do_handshake(&mut client, &mut server).await; client.set_buffer_limit(Some(48)); - assert_eq!(client.writer().write(b"01234567890123456789").await.unwrap(), 20); - assert_eq!(client.writer().write(b"01234567890123456789").await.unwrap(), 6); + assert_eq!(client.write_plaintext(b"01234567890123456789").await.unwrap(), 20); + assert_eq!(client.write_plaintext(b"01234567890123456789").await.unwrap(), 6); send(&mut client, &mut server); server.process_new_packets().unwrap(); @@ -1143,8 +1136,8 @@ async fn client_complete_io_for_write() { do_handshake(&mut client, &mut server).await; - client.writer().write_all(b"01234567890123456789").await.unwrap(); - client.writer().write_all(b"01234567890123456789").await.unwrap(); + client.write_plaintext(b"01234567890123456789").await.unwrap(); + client.write_plaintext(b"01234567890123456789").await.unwrap(); { let mut pipe = ServerSession::new(&mut server); let (rdlen, wrlen) = client.complete_io(&mut pipe).await.unwrap(); @@ -1268,7 +1261,7 @@ async fn server_stream_read() { for kt in ALL_KEY_TYPES.iter() { let (mut client, mut server) = make_pair(*kt).await; - client.writer().write_all(b"world").await.unwrap(); + client.write_all_plaintext(b"world").await.unwrap(); { let mut pipe = ClientSession::new(&mut client); @@ -1283,7 +1276,7 @@ async fn server_streamowned_read() { for kt in ALL_KEY_TYPES.iter() { let (mut client, server) = make_pair(*kt).await; - client.writer().write_all(b"world").await.unwrap(); + client.write_all_plaintext(b"world").await.unwrap(); { let pipe = ClientSession::new(&mut client); @@ -1328,7 +1321,7 @@ impl io::Write for FailsWrites { // errkind: io::ErrorKind::ConnectionAborted, // after: 0, // }; -// client.writer().write_all(b"hello").await.unwrap(); +// client.write_all_plaintext(b"hello").await.unwrap(); // let mut client_stream = Stream::new(&mut client, &mut pipe); // let rc = client_stream.write(b"world"); // assert!(rc.is_err()); @@ -1345,7 +1338,7 @@ impl io::Write for FailsWrites { // errkind: io::ErrorKind::ConnectionAborted, // after: 1, // }; -// client.writer().write_all(b"hello").await.unwrap(); +// client.write_all_plaintext(b"hello").await.unwrap(); // let mut client_stream = Stream::new(&mut client, &mut pipe); // let rc = client_stream.write(b"world"); // assert_eq!(format!("{:?}", rc), "Ok(5)"); @@ -1831,8 +1824,8 @@ async fn servered_write_for_client_appdata() { let (mut client, mut server) = make_pair(KeyType::Rsa).await; do_handshake(&mut client, &mut server).await; - client.writer().write_all(b"01234567890123456789").await.unwrap(); - client.writer().write_all(b"01234567890123456789").await.unwrap(); + client.write_all_plaintext(b"01234567890123456789").await.unwrap(); + client.write_all_plaintext(b"01234567890123456789").await.unwrap(); { let mut pipe = ServerSession::new(&mut server); let wrlen = client.write_tls(&mut pipe).unwrap(); @@ -1937,8 +1930,8 @@ async fn servered_write_for_server_handshake_no_half_rtt_by_default() { async fn servered_write_for_client_handshake() { let (mut client, mut server) = make_pair(KeyType::Rsa).await; - client.writer().write_all(b"01234567890123456789").await.unwrap(); - client.writer().write_all(b"0123456789").await.unwrap(); + client.write_all_plaintext(b"01234567890123456789").await.unwrap(); + client.write_all_plaintext(b"0123456789").await.unwrap(); { let mut pipe = ServerSession::new(&mut server); let wrlen = client.write_tls(&mut pipe).unwrap();