test: Refactor log entry parsing integration test to use new api client

This commit is contained in:
Tyler Beckman 2024-10-27 17:18:35 -06:00
parent 03f4151f66
commit c46dfd4457
Signed by: Ty
GPG key ID: 2813440C772555A4

View file

@ -2,41 +2,28 @@ use std::sync::Arc;
use base64ct::Encoding; use base64ct::Encoding;
use ct::{ use ct::{
merkle::{ api::{responses::GetEntriesResponseEntry, CtApiClient}, merkle::{
consts::EXTRA_DATA_BASE64_BUFFER_SIZE, consts::EXTRA_DATA_BASE64_BUFFER_SIZE,
types::{MerkleLeafType, Version} types::{MerkleLeafType, Version}
}, }, parsing::entry::{parse_entry_extra_data_precert, parse_entry_extra_data_x509}
parsing::entry::{parse_entry_extra_data_precert, parse_entry_extra_data_x509}
}; };
use serde::Deserialize;
use tokio::task::JoinSet; use tokio::task::JoinSet;
#[derive(Debug, Deserialize)] async fn fetch_entries() -> impl Iterator<Item = GetEntriesResponseEntry> {
pub struct Entry { let client = Arc::new(
leaf_input: String, CtApiClient::new_with_client(
extra_data: String "https://oak.ct.letsencrypt.org/2024h2/ct/v1/get-entries",
} Arc::new(reqwest::Client::new())
)
#[derive(Debug, Deserialize)] );
pub struct GetEntriesResponse { let mut join_set: JoinSet<_> = JoinSet::new();
entries: Vec<Entry> for i in 0..12u64 {
}
async fn fetch_entries() -> impl Iterator<Item = Entry> {
let client = Arc::new(reqwest::Client::new());
let mut join_set: JoinSet<GetEntriesResponse> = JoinSet::new();
for i in 0..12u32 {
let client = client.clone(); let client = client.clone();
join_set.spawn(async move { join_set.spawn(async move {
client client
.get("https://oak.ct.letsencrypt.org/2024h2/ct/v1/get-entries") .get_log_entries(i * 256, (i+1) * 256 - 1)
.query(&[("start", i * 256), ("end", (i + 1) * 256 - 1)])
.send()
.await .await
.expect("Request to ct log should succeed") .expect("Request should succeed")
.json()
.await
.expect("Request to ct log should parse properly")
}); });
} }
join_set join_set