test: add real site test
This commit is contained in:
parent
fd6702d029
commit
d1fc9f278b
1 changed files with 33 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
use tokio::runtime::Runtime;
|
||||
|
||||
use crate::certs::{fingerprint::CertFingerprint, CertificateDer};
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
@ -40,3 +42,34 @@ fn check_parser() {
|
|||
drop(resp); // to free recv from mutable borrowing
|
||||
assert_eq!(recv.as_slice(), b"gemini://unw.dc09.ru\r\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_real_site() {
|
||||
let rt = Runtime::new().unwrap();
|
||||
let client = Client::builder()
|
||||
.with_selfsigned_cert_verifier(Verifier {})
|
||||
.build();
|
||||
|
||||
rt.block_on(client.request("gemini://geminiprotocol.net/docs"))
|
||||
.unwrap();
|
||||
|
||||
struct Verifier;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl SelfsignedCertVerifier for Verifier {
|
||||
async fn verify(
|
||||
&self,
|
||||
cert: &CertificateDer<'_>,
|
||||
host: &str,
|
||||
port: u16,
|
||||
) -> Result<bool, LibError> {
|
||||
assert_eq!(host, "geminiprotocol.net");
|
||||
assert_eq!(port, 1965);
|
||||
assert_eq!(
|
||||
CertFingerprint::new_sha256(cert).base64(),
|
||||
"OBuOKRLSTQcgHXdQ0QFshcGQSgc5o+g0fnHDY+7SolE",
|
||||
);
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue