Fix early-data test (#132)

* Fix domain name in early-data test

* Run early data test in CI

* Add missing wake call

* Workaround: write to OpenSSL's input

This is necessary to work around an issue that only appears on Windows.

* Don't rerun other tests in CI
This commit is contained in:
David Cook 2023-02-18 18:40:05 -06:00 committed by GitHub
parent e3841d6e3a
commit 357bc56248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -45,7 +45,9 @@ jobs:
toolchain: ${{ matrix.rust }} toolchain: ${{ matrix.rust }}
- name: Test - name: Test
run: cargo test --all run: |
cargo test --all
cargo test -p tokio-rustls --features early-data --test early-data
lints: lints:
name: Lints name: Lints

View File

@ -9,6 +9,7 @@ use std::pin::Pin;
use std::process::{Child, Command, Stdio}; use std::process::{Child, Command, Stdio};
use std::sync::Arc; use std::sync::Arc;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use std::thread;
use std::time::Duration; use std::time::Duration;
use tokio::io::{split, AsyncRead, AsyncWriteExt, ReadBuf}; use tokio::io::{split, AsyncRead, AsyncWriteExt, ReadBuf};
use tokio::net::TcpStream; use tokio::net::TcpStream;
@ -34,6 +35,7 @@ impl<T: AsyncRead + Unpin> Future for Read1<T> {
if buf.filled().is_empty() { if buf.filled().is_empty() {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} else { } else {
cx.waker().wake_by_ref();
Poll::Pending Poll::Pending
} }
} }
@ -46,7 +48,7 @@ async fn send(
) -> io::Result<TlsStream<TcpStream>> { ) -> io::Result<TlsStream<TcpStream>> {
let connector = TlsConnector::from(config).early_data(true); let connector = TlsConnector::from(config).early_data(true);
let stream = TcpStream::connect(&addr).await?; let stream = TcpStream::connect(&addr).await?;
let domain = rustls::ServerName::try_from("testserver.com").unwrap(); let domain = rustls::ServerName::try_from("foobar.com").unwrap();
let stream = connector.connect(domain, stream).await?; let stream = connector.connect(domain, stream).await?;
let (mut rd, mut wd) = split(stream); let (mut rd, mut wd) = split(stream);
@ -140,6 +142,17 @@ async fn test_0rtt() -> io::Result<()> {
let config = Arc::new(config); let config = Arc::new(config);
let addr = SocketAddr::from(([127, 0, 0, 1], 12354)); let addr = SocketAddr::from(([127, 0, 0, 1], 12354));
// workaround: write to openssl s_server standard input periodically, to
// get it unstuck on Windows
let stdin = handle.0.stdin.take().unwrap();
thread::spawn(move || {
let mut stdin = stdin;
loop {
thread::sleep(std::time::Duration::from_secs(5));
std::io::Write::write_all(&mut stdin, b"\n").unwrap();
}
});
let io = send(config.clone(), addr, b"hello").await?; let io = send(config.clone(), addr, b"hello").await?;
assert!(!io.get_ref().1.is_early_data_accepted()); assert!(!io.get_ref().1.is_early_data_accepted());