forked from lavina/lavina
Rollback tests
This commit is contained in:
parent
7376f4cd0a
commit
d9bdb207cc
|
@ -108,7 +108,6 @@ impl<'a> TestScopeTls<'a> {
|
|||
}
|
||||
|
||||
struct IgnoreCertVerification;
|
||||
|
||||
impl ServerCertVerifier for IgnoreCertVerification {
|
||||
fn verify_server_cert(
|
||||
&self,
|
||||
|
@ -123,79 +122,6 @@ impl ServerCertVerifier for IgnoreCertVerification {
|
|||
}
|
||||
}
|
||||
|
||||
/// Some clients prefer to close their tags, i.e. Gajim.
|
||||
#[tokio::test]
|
||||
async fn scenario_basic_closed_tag() -> Result<()> {
|
||||
tracing_subscriber::fmt::try_init();
|
||||
let config = ServerConfig {
|
||||
listen_on: "127.0.0.1:0".parse().unwrap(),
|
||||
cert: "tests/certs/xmpp.pem".parse().unwrap(),
|
||||
key: "tests/certs/xmpp.key".parse().unwrap(),
|
||||
};
|
||||
let mut metrics = MetricsRegistry::new();
|
||||
let mut storage = Storage::open(StorageConfig {
|
||||
db_path: ":memory:".into(),
|
||||
})
|
||||
.await?;
|
||||
let rooms = RoomRegistry::new(&mut metrics, storage.clone()).unwrap();
|
||||
let players = PlayerRegistry::empty(rooms.clone(), &mut metrics).unwrap();
|
||||
let server = launch(config, players, rooms, metrics, storage.clone()).await.unwrap();
|
||||
|
||||
// test scenario
|
||||
|
||||
storage.create_user("tester").await?;
|
||||
storage.set_password("tester", "password").await?;
|
||||
|
||||
let mut stream = TcpStream::connect(server.addr).await?;
|
||||
let mut s = TestScope::new(&mut stream);
|
||||
tracing::info!("TCP connection established");
|
||||
|
||||
s.send(r#"<?xml version='1.0'?>"#).await?;
|
||||
s.send(r#"
|
||||
<stream:stream xmlns="jabber:client" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" to="sauer" xml:lang="en">
|
||||
"#).await?;
|
||||
|
||||
assert_matches!(s.next_xml_event().await?, Event::Decl(_) => {});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(b.local_name().into_inner(), b"stream"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(b.local_name().into_inner(), b"features"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(b.local_name().into_inner(), b"starttls"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::Empty(b) => assert_eq!(b.local_name().into_inner(), b"required"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(b.local_name().into_inner(), b"starttls"));
|
||||
assert_matches!(s.next_xml_event().await?, Event::End(b) => assert_eq!(b.local_name().into_inner(), b"features"));
|
||||
s.send(r#"<starttls/>"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Empty(b) => assert_eq!(b.local_name().into_inner(), b"proceed"));
|
||||
let buffer = s.buffer;
|
||||
tracing::info!("TLS feature negotiation complete");
|
||||
|
||||
let connector = TlsConnector::from(Arc::new(
|
||||
ClientConfig::builder()
|
||||
.with_safe_defaults()
|
||||
.with_custom_certificate_verifier(Arc::new(IgnoreCertVerification))
|
||||
.with_no_client_auth(),
|
||||
));
|
||||
tracing::info!("Initiating TLS connection...");
|
||||
let mut stream = connector.connect(ServerName::IpAddress(server.addr.ip()), stream).await?;
|
||||
tracing::info!("TLS connection established");
|
||||
|
||||
let mut s = TestScopeTls::new(&mut stream, buffer);
|
||||
|
||||
s.send(r#"<?xml version="1.0"?>"#).await?;
|
||||
s.send(r#"
|
||||
<!-- Outgoing Tue 02 Apr 2024 06:39:24 PM CEST (Account Wizard) -->
|
||||
</stream:stream>
|
||||
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" to="127.0.0.1" xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns="jabber:client" version="1.0">
|
||||
"#).await?;
|
||||
assert_matches!(s.next_xml_event().await?, Event::Decl(_) => {});
|
||||
assert_matches!(s.next_xml_event().await?, Event::Start(b) => assert_eq!(b.local_name().into_inner(), b"stream"));
|
||||
|
||||
stream.shutdown().await?;
|
||||
|
||||
// wrap up
|
||||
|
||||
server.terminate().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn scenario_basic() -> Result<()> {
|
||||
tracing_subscriber::fmt::try_init();
|
||||
|
|
Loading…
Reference in New Issue