mirror of
https://github.com/ekzhang/bore.git
synced 2025-12-15 19:37:47 +01:00
Add integration tests for auth and end-to-end proxying (#4)
* Add authentication handshake tests * Add basic proxy test * Add mismatched secret failure test * Add a failure test for invalid addresses
This commit is contained in:
35
tests/auth_test.rs
Normal file
35
tests/auth_test.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use anyhow::Result;
|
||||
use bore_cli::auth::Authenticator;
|
||||
use tokio::io::{self, BufReader};
|
||||
|
||||
#[tokio::test]
|
||||
async fn auth_handshake() -> Result<()> {
|
||||
let auth = Authenticator::new("some secret string");
|
||||
|
||||
let (client, server) = io::duplex(8); // Ensure correctness with limited capacity.
|
||||
let mut client = BufReader::new(client);
|
||||
let mut server = BufReader::new(server);
|
||||
|
||||
tokio::try_join!(
|
||||
auth.client_handshake(&mut client),
|
||||
auth.server_handshake(&mut server),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn auth_handshake_fail() {
|
||||
let auth = Authenticator::new("client secret");
|
||||
let auth2 = Authenticator::new("different server secret");
|
||||
|
||||
let (client, server) = io::duplex(8); // Ensure correctness with limited capacity.
|
||||
let mut client = BufReader::new(client);
|
||||
let mut server = BufReader::new(server);
|
||||
|
||||
let result = tokio::try_join!(
|
||||
auth.client_handshake(&mut client),
|
||||
auth2.server_handshake(&mut server),
|
||||
);
|
||||
assert!(result.is_err());
|
||||
}
|
||||
Reference in New Issue
Block a user