From c46dfd445751ccb69890abc0534a7b7440bba9e6 Mon Sep 17 00:00:00 2001 From: Tyler Beckman Date: Sun, 27 Oct 2024 17:18:35 -0600 Subject: [PATCH] test: Refactor log entry parsing integration test to use new api client --- tests/log_entry_parsing.rs | 39 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/tests/log_entry_parsing.rs b/tests/log_entry_parsing.rs index 0e60021..8820a87 100644 --- a/tests/log_entry_parsing.rs +++ b/tests/log_entry_parsing.rs @@ -2,41 +2,28 @@ use std::sync::Arc; use base64ct::Encoding; use ct::{ - merkle::{ + api::{responses::GetEntriesResponseEntry, CtApiClient}, merkle::{ consts::EXTRA_DATA_BASE64_BUFFER_SIZE, 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; -#[derive(Debug, Deserialize)] -pub struct Entry { - leaf_input: String, - extra_data: String -} - -#[derive(Debug, Deserialize)] -pub struct GetEntriesResponse { - entries: Vec -} - -async fn fetch_entries() -> impl Iterator { - let client = Arc::new(reqwest::Client::new()); - let mut join_set: JoinSet = JoinSet::new(); - for i in 0..12u32 { +async fn fetch_entries() -> impl Iterator { + let client = Arc::new( + CtApiClient::new_with_client( + "https://oak.ct.letsencrypt.org/2024h2/ct/v1/get-entries", + Arc::new(reqwest::Client::new()) + ) + ); + let mut join_set: JoinSet<_> = JoinSet::new(); + for i in 0..12u64 { let client = client.clone(); join_set.spawn(async move { client - .get("https://oak.ct.letsencrypt.org/2024h2/ct/v1/get-entries") - .query(&[("start", i * 256), ("end", (i + 1) * 256 - 1)]) - .send() + .get_log_entries(i * 256, (i+1) * 256 - 1) .await - .expect("Request to ct log should succeed") - .json() - .await - .expect("Request to ct log should parse properly") + .expect("Request should succeed") }); } join_set