From 8fa55082f9c7e0a438ee0976d62b0773a16bf64c Mon Sep 17 00:00:00 2001 From: Jacob Rothstein Date: Mon, 18 Sep 2023 16:06:48 -0700 Subject: [PATCH] use divviup-api-client (#1697) Re-enables the in-cluster Prio3Histogram test --- Cargo.lock | 192 ++++++++++++---- integration_tests/Cargo.toml | 2 + integration_tests/src/divviup_api_client.rs | 238 -------------------- integration_tests/src/lib.rs | 1 - integration_tests/tests/in_cluster.rs | 121 ++++++---- 5 files changed, 230 insertions(+), 324 deletions(-) delete mode 100644 integration_tests/src/divviup_api_client.rs diff --git a/Cargo.lock b/Cargo.lock index 5bd59ab79..e48efac87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -819,6 +819,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.0", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "deadpool" version = "0.9.5" @@ -873,6 +886,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +dependencies = [ + "serde", +] + [[package]] name = "derivative" version = "2.2.0" @@ -926,6 +948,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "divviup-client" +version = "0.0.1" +source = "git+https://github.com/divviup/divviup-api?tag=0.0.25#8eda807aff7a6ed20d7ea8873b4d36b2421cdb95" +dependencies = [ + "base64 0.21.4", + "email_address", + "janus_messages 0.5.20", + "log", + "pad-adapter", + "serde", + "serde_json", + "thiserror", + "time", + "trillium-client", + "trillium-http", + "url", + "uuid", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -967,6 +1009,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "email_address" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2153bd83ebc09db15bcbdc3e2194d901804952e3dc96967e1cd3b0c5c32d112" +dependencies = [ + "serde", +] + [[package]] name = "encoding_rs" version = "0.8.32" @@ -1402,15 +1453,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.14.0" @@ -1788,7 +1830,7 @@ dependencies = [ "janus_aggregator_api", "janus_aggregator_core", "janus_core", - "janus_messages", + "janus_messages 0.6.0", "k8s-openapi", "kube", "mockito", @@ -1798,7 +1840,7 @@ dependencies = [ "opentelemetry-semantic-conventions", "postgres-protocol", "postgres-types", - "prio", + "prio 0.15.1", "prometheus", "rand", "regex", @@ -1850,7 +1892,7 @@ dependencies = [ "futures", "janus_aggregator_core", "janus_core", - "janus_messages", + "janus_messages 0.6.0", "opentelemetry", "querystring", "rand", @@ -1890,13 +1932,13 @@ dependencies = [ "hyper", "janus_aggregator_core", "janus_core", - "janus_messages", + "janus_messages 0.6.0", "k8s-openapi", "kube", "opentelemetry", "postgres-protocol", "postgres-types", - "prio", + "prio 0.15.1", "rand", "regex", "reqwest", @@ -1941,9 +1983,9 @@ dependencies = [ "http-api-problem", "itertools", "janus_core", - "janus_messages", + "janus_messages 0.6.0", "mockito", - "prio", + "prio 0.15.1", "rand", "reqwest", "thiserror", @@ -1967,9 +2009,9 @@ dependencies = [ "http-api-problem", "janus_collector", "janus_core", - "janus_messages", + "janus_messages 0.6.0", "mockito", - "prio", + "prio 0.15.1", "rand", "reqwest", "retry-after", @@ -1996,11 +2038,11 @@ dependencies = [ "http", "http-api-problem", "janus_core", - "janus_messages", + "janus_messages 0.6.0", "k8s-openapi", "kube", "mockito", - "prio", + "prio 0.15.1", "rand", "reqwest", "ring", @@ -2029,6 +2071,7 @@ dependencies = [ "anyhow", "backoff", "base64 0.21.4", + "divviup-client", "futures", "hex", "http", @@ -2039,10 +2082,10 @@ dependencies = [ "janus_collector", "janus_core", "janus_interop_binaries", - "janus_messages", + "janus_messages 0.6.0", "k8s-openapi", "kube", - "prio", + "prio 0.15.1", "rand", "reqwest", "serde", @@ -2050,6 +2093,7 @@ dependencies = [ "tempfile", "testcontainers", "tokio", + "trillium-tokio", "url", ] @@ -2072,9 +2116,9 @@ dependencies = [ "janus_collector", "janus_core", "janus_interop_binaries", - "janus_messages", + "janus_messages 0.6.0", "opentelemetry", - "prio", + "prio 0.15.1", "rand", "regex", "reqwest", @@ -2095,6 +2139,24 @@ dependencies = [ "zstd", ] +[[package]] +name = "janus_messages" +version = "0.5.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7269662cdac52cea2a98cf10cb35028d1d673951e4ff1bcf8c653b5d3b8577" +dependencies = [ + "anyhow", + "base64 0.21.4", + "derivative", + "hex", + "num_enum", + "prio 0.12.3", + "rand", + "serde", + "thiserror", + "url", +] + [[package]] name = "janus_messages" version = "0.6.0" @@ -2105,7 +2167,7 @@ dependencies = [ "derivative", "hex", "num_enum", - "prio", + "prio 0.15.1", "rand", "serde", "serde_test", @@ -2126,8 +2188,8 @@ dependencies = [ "fixed", "janus_collector", "janus_core", - "janus_messages", - "prio", + "janus_messages 0.6.0", + "prio 0.15.1", "rand", "reqwest", "serde_json", @@ -2311,9 +2373,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "matchers" @@ -2714,6 +2776,12 @@ dependencies = [ "elliptic-curve", ] +[[package]] +name = "pad-adapter" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d80efc4b6721e8be2a10a5df21a30fa0b470f1539e53d8b4e6e75faf938b63" + [[package]] name = "parking" version = "2.1.0" @@ -2935,6 +3003,22 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prio" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56d6fbe33c4d999c3ba5e5f2673cfeadffd2c8e1ffd58ab67a3cf06cd576d834" +dependencies = [ + "base64 0.21.4", + "byteorder", + "getrandom", + "serde", + "sha3", + "static_assertions", + "subtle", + "thiserror", +] + [[package]] name = "prio" version = "0.15.1" @@ -3577,9 +3661,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "indexmap 2.0.0", "itoa", @@ -3771,6 +3855,12 @@ version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +[[package]] +name = "size" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fed904c7fb2856d868b92464fc8fa597fce366edea1a9cbfaa8cb5fe080bd6d" + [[package]] name = "slab" version = "0.4.8" @@ -4232,10 +4322,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ + "deranged", "itoa", "serde", "time-core", @@ -4250,9 +4341,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.10" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -4649,6 +4740,29 @@ dependencies = [ "trillium", ] +[[package]] +name = "trillium-client" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe6ea026104c7c51ebe0bab6633ad66c4112bd95aa97c118e5110340c3055a39" +dependencies = [ + "crossbeam-queue", + "dashmap", + "encoding_rs", + "futures-lite", + "httparse", + "log", + "memmem", + "mime", + "serde", + "serde_json", + "size", + "thiserror", + "trillium-http", + "trillium-server-common", + "url", +] + [[package]] name = "trillium-head" version = "0.2.0" @@ -4660,13 +4774,13 @@ dependencies = [ [[package]] name = "trillium-http" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150f7908e705f7fe806735b23a7a81c342ff0c1cc29faee39bd7a16e30e3aab0" +checksum = "fb554db15b8b056d593ba768948d87cff0a819ea9823a1aa228344b4abed37ce" dependencies = [ "encoding_rs", "futures-lite", - "hashbrown 0.13.2", + "hashbrown 0.14.0", "httparse", "httpdate", "log", @@ -4917,6 +5031,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ "getrandom", + "rand", + "serde", ] [[package]] diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index 2d11463dc..19c92d9b6 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -15,6 +15,7 @@ in-cluster = ["dep:k8s-openapi", "dep:kube"] anyhow.workspace = true backoff = { version = "0.4", features = ["tokio"] } base64.workspace = true +divviup-client = { git = "https://github.com/divviup/divviup-api", features = ["admin"], tag = "0.0.25" } futures = "0.3.28" hex = "0.4" http = "0.2" @@ -36,6 +37,7 @@ serde_json = "1.0.106" testcontainers = "0.14.0" tokio.workspace = true url = { version = "2.4.1", features = ["serde"] } +trillium-tokio.workspace = true [dev-dependencies] janus_collector = { workspace = true, features = ["test-util"] } diff --git a/integration_tests/src/divviup_api_client.rs b/integration_tests/src/divviup_api_client.rs deleted file mode 100644 index 71622a866..000000000 --- a/integration_tests/src/divviup_api_client.rs +++ /dev/null @@ -1,238 +0,0 @@ -use anyhow::{anyhow, Context}; -use http::{ - header::{ACCEPT, CONTENT_TYPE}, - Method, -}; -use janus_core::{task::VdafInstance, test_util::kubernetes::PortForward}; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use serde_json::json; -use url::Url; - -/// Representation of a `divviup-api` account. -#[derive(Deserialize)] -pub struct Account { - id: String, -} - -/// Representation of a VDAF in `divviup-api`. -#[derive(Serialize)] -#[serde(rename_all = "snake_case", tag = "type")] -pub enum ApiVdaf { - /// Corresponds to Prio3Count - Count, - Histogram { - buckets: Vec, - }, - Sum { - bits: usize, - }, -} - -impl TryFrom<&VdafInstance> for ApiVdaf { - type Error = anyhow::Error; - - fn try_from(vdaf: &VdafInstance) -> Result { - match vdaf { - VdafInstance::Prio3Count => Ok(ApiVdaf::Count), - VdafInstance::Prio3Sum { bits } => Ok(ApiVdaf::Sum { bits: *bits }), - VdafInstance::Prio3Histogram { length } => { - // divviup-api does not yet support the new Prio3Histogram representation. Until it - // does, we synthesize fake bucket boundaries that will yield the number of buckets - // we want. - // https://github.com/divviup/divviup-api/issues/410 - Ok(ApiVdaf::Histogram { - buckets: (0..*length - 1) - .map(|length| u64::try_from(length).context("cannot convert length to u64")) - .collect::, _>>()?, - }) - } - _ => Err(anyhow!("unsupported VDAF: {vdaf:?}")), - } - } -} - -#[derive(Serialize)] -pub struct NewTaskRequest { - pub name: String, - pub leader_aggregator_id: String, - pub helper_aggregator_id: String, - pub vdaf: ApiVdaf, - pub min_batch_size: u64, - pub max_batch_size: Option, - pub expiration: String, - pub time_precision_seconds: u64, - pub hpke_config_id: String, -} - -/// Representation of a DAP task in responses from divviup-api. This application ignores several -/// fields that we never use. -#[derive(Deserialize)] -pub struct DivviUpApiTask { - /// DAP task ID - pub id: String, -} - -/// Request to pair an aggregator with divviup-api -#[derive(Serialize)] -pub struct NewAggregatorRequest { - pub name: String, - pub api_url: String, - /// Bearer token for authenticating requests to this aggregator's aggregator API - pub bearer_token: String, -} - -/// Representation of an aggregator in responses from divviup-api. This application ignores several -/// fields that we never use. -#[derive(Deserialize)] -pub struct DivviUpAggregator { - pub id: String, - pub dap_url: Url, -} - -/// Request to create an HPKE config in divviup-api. -#[derive(Serialize)] -pub struct NewHpkeConfigRequest { - pub name: String, - pub contents: String, -} - -/// Representation of an HPKE config in responses from divviup-api. This application ignores most -/// fields that we never use. -#[derive(Deserialize)] -pub struct DivviUpHpkeConfig { - pub id: String, -} - -/// Representation of a collector auth token in divviup-api. -#[derive(Deserialize)] -pub struct CollectorAuthToken { - /// Type of the authentication token. Always "Bearer" in divviup-api. - pub r#type: String, - /// Encoded value of the token. The encoding is opaque to divviup-api. - pub token: String, -} - -const DIVVIUP_CONTENT_TYPE: &str = "application/vnd.divviup+json;version=0.1"; - -pub struct DivviupApiClient { - port_forward: PortForward, - client: reqwest::Client, -} - -impl DivviupApiClient { - pub fn new(port_forward: PortForward) -> Self { - Self { - port_forward, - client: reqwest::Client::new(), - } - } - - pub async fn make_request( - &self, - method: Method, - path: &str, - body: Option, - request_description: &str, - ) -> R { - let mut builder = self - .client - .request( - method, - format!( - "http://127.0.0.1:{}/api/{path}", - self.port_forward.local_port() - ), - ) - .header(CONTENT_TYPE, DIVVIUP_CONTENT_TYPE) - .header(ACCEPT, DIVVIUP_CONTENT_TYPE); - if let Some(body) = body { - let body_string = serde_json::to_string(&body).unwrap(); - builder = builder.body(body_string); - } - - let resp = builder.send().await.unwrap(); - let status = resp.status(); - if !status.is_success() { - let resp_text = resp.text().await; - panic!("{request_description} request returned status code {status}, {resp_text:?}"); - } - - resp.json().await.unwrap() - } - - pub async fn create_account(&self) -> Account { - self.make_request( - Method::POST, - "accounts", - Some(json!({"name": "Integration test account"})), - "Account creation", - ) - .await - } - - pub async fn pair_global_aggregator( - &self, - request: &NewAggregatorRequest, - ) -> DivviUpAggregator { - self.make_request( - Method::POST, - "aggregators", - Some(request), - "Global aggregator pairing", - ) - .await - } - - pub async fn pair_aggregator( - &self, - account: &Account, - request: &NewAggregatorRequest, - ) -> DivviUpAggregator { - self.make_request( - Method::POST, - &format!("accounts/{}/aggregators", account.id), - Some(request), - "Aggregator pairing", - ) - .await - } - - pub async fn create_hpke_config( - &self, - account: &Account, - request: &NewHpkeConfigRequest, - ) -> DivviUpHpkeConfig { - self.make_request( - Method::POST, - &format!("accounts/{}/hpke_configs", account.id), - Some(request), - "HPKE config creation", - ) - .await - } - - pub async fn create_task(&self, account: &Account, request: &NewTaskRequest) -> DivviUpApiTask { - self.make_request( - Method::POST, - &format!("accounts/{}/tasks", account.id), - Some(request), - "Task creation", - ) - .await - } - - pub async fn list_collector_auth_tokens( - &self, - task: &DivviUpApiTask, - ) -> Vec { - // Hack: we must choose some specialization for the B type despite the request having no - // Body - self.make_request::( - Method::GET, - &format!("tasks/{}/collector_auth_tokens", task.id), - None, - "List collector auth tokens", - ) - .await - } -} diff --git a/integration_tests/src/lib.rs b/integration_tests/src/lib.rs index 96c79da26..ad57c0fdd 100644 --- a/integration_tests/src/lib.rs +++ b/integration_tests/src/lib.rs @@ -8,7 +8,6 @@ use url::Url; pub mod client; pub mod daphne; -pub mod divviup_api_client; pub mod interop_api; pub mod janus; diff --git a/integration_tests/tests/in_cluster.rs b/integration_tests/tests/in_cluster.rs index 450a32f3e..8ece2e2d1 100644 --- a/integration_tests/tests/in_cluster.rs +++ b/integration_tests/tests/in_cluster.rs @@ -1,7 +1,9 @@ #![cfg(feature = "in-cluster")] - -use base64::engine::{general_purpose::STANDARD, Engine}; use common::{submit_measurements_and_verify_aggregate, test_task_builders}; +use divviup_client::{ + Client, CollectorAuthenticationToken, DivviupClient, Histogram, HpkeConfigContents, + NewAggregator, NewSharedAggregator, NewTask, Vdaf, +}; use janus_aggregator_core::task::QueryType; use janus_core::{ task::AuthenticationToken, @@ -11,16 +13,10 @@ use janus_core::{ kubernetes::{Cluster, PortForward}, }, }; -use janus_integration_tests::{ - client::ClientBackend, - divviup_api_client::{ - DivviupApiClient, NewAggregatorRequest, NewHpkeConfigRequest, NewTaskRequest, - }, - TaskParameters, -}; +use janus_integration_tests::{client::ClientBackend, TaskParameters}; use janus_messages::TaskId; -use prio::codec::Encode; use std::{env, str::FromStr}; +use trillium_tokio::ClientConfig; use url::Url; mod common; @@ -101,15 +97,23 @@ impl InClusterJanusPair { // so they need the in-cluster DNS name of the other aggregator, and they can use well-known // service port numbers. - let divviup_api = DivviupApiClient::new( - cluster - .forward_port(&divviup_api_namespace, "divviup-api", 80) - .await, + let port_forward = cluster + .forward_port(&divviup_api_namespace, "divviup-api", 80) + .await; + let port = port_forward.local_port(); + + let mut divviup_api = DivviupClient::new( + "DUATignored".into(), + Client::new(ClientConfig::new()).with_default_pool(), ); + divviup_api.set_url(format!("http://127.0.0.1:{port}").parse().unwrap()); // Create an account first. (We should be implicitly logged in as a testing user already, // assuming divviup-api was built with the integration-testing feature) - let account = divviup_api.create_account().await; + let account = divviup_api + .create_account("Integration test account") + .await + .unwrap(); // Pair the aggregators. The same Janus instances will get paired multiple times across // multiple tests, but it's to a different divviup-api account each time, so that's @@ -118,68 +122,92 @@ impl InClusterJanusPair { // // - setting up tasks with one global aggregator and one per-account aggregator is most // representative of the subscriber use cases Divvi Up supports, - // - pairing a global aggregator implictly marks it as "first-party" in divviup-api, which - // is necessary for the task we later provision to pass a validity check. let paired_leader_aggregator = divviup_api - .pair_global_aggregator(&NewAggregatorRequest { + .create_shared_aggregator(NewSharedAggregator { name: "leader".to_string(), - api_url: Self::in_cluster_aggregator_api_url(&leader_namespace).to_string(), + api_url: Self::in_cluster_aggregator_api_url(&leader_namespace), bearer_token: leader_aggregator_api_auth_token, + is_first_party: true, }) - .await; + .await + .unwrap(); let paired_helper_aggregator = divviup_api - .pair_aggregator( - &account, - &NewAggregatorRequest { + .create_aggregator( + account.id, + NewAggregator { name: "helper".to_string(), - api_url: Self::in_cluster_aggregator_api_url(&helper_namespace).to_string(), + api_url: Self::in_cluster_aggregator_api_url(&helper_namespace), bearer_token: helper_aggregator_api_auth_token, }, ) - .await; + .await + .unwrap(); + let hpke_config = task.collector_hpke_config().unwrap(); let collector_hpke_config = divviup_api .create_hpke_config( - &account, - &NewHpkeConfigRequest { - name: "Integration test key".to_string(), - contents: STANDARD.encode(task.collector_hpke_config().unwrap().get_encoded()), - }, + account.id, + &HpkeConfigContents::new( + u8::from(*hpke_config.id()).into(), + (*hpke_config.kem_id() as u16).try_into().unwrap(), + (*hpke_config.kdf_id() as u16).try_into().unwrap(), + (*hpke_config.aead_id() as u16).try_into().unwrap(), + hpke_config.public_key().as_ref().to_vec().into(), + ), + Some("Integration test key"), ) - .await; + .await + .unwrap(); - let provision_task_request = NewTaskRequest { + let provision_task_request = NewTask { name: "Integration test task".to_string(), leader_aggregator_id: paired_leader_aggregator.id, helper_aggregator_id: paired_helper_aggregator.id, - vdaf: task.vdaf().try_into().unwrap(), + vdaf: match task.vdaf().to_owned() { + VdafInstance::Prio3Count => Vdaf::Count, + VdafInstance::Prio3Sum { bits } => Vdaf::Sum { + bits: bits.try_into().unwrap(), + }, + VdafInstance::Prio3SumVec { bits, length } => Vdaf::SumVec { + bits: bits.try_into().unwrap(), + length: length.try_into().unwrap(), + }, + VdafInstance::Prio3Histogram { length } => Vdaf::Histogram(Histogram::Length { + length: length.try_into().unwrap(), + }), + VdafInstance::Prio3CountVec { length } => Vdaf::CountVec { + length: length.try_into().unwrap(), + }, + other => panic!("unsupported vdaf {other:?}"), + }, min_batch_size: task.min_batch_size(), max_batch_size: match task.query_type() { QueryType::TimeInterval => None, QueryType::FixedSize { max_batch_size, .. } => Some(*max_batch_size), }, - expiration: "3000-01-01T00:00:00Z".to_owned(), time_precision_seconds: task.time_precision().as_seconds(), hpke_config_id: collector_hpke_config.id, }; // Provision the task into both aggregators via divviup-api let provisioned_task = divviup_api - .create_task(&account, &provision_task_request) - .await; - - let collector_auth_tokens = divviup_api - .list_collector_auth_tokens(&provisioned_task) - .await; - assert_eq!(collector_auth_tokens[0].r#type, "Bearer"); + .create_task(account.id, provision_task_request) + .await + .unwrap(); + + let CollectorAuthenticationToken::Bearer { token } = divviup_api + .task_collector_auth_tokens(&provisioned_task.id) + .await + .unwrap() + .into_iter() + .next() + .unwrap(); // Update the task parameters with the ID and collector auth token from divviup-api. - task_parameters.task_id = TaskId::from_str(provisioned_task.id.as_ref()).unwrap(); - task_parameters.collector_auth_token = AuthenticationToken::new_bearer_token_from_string( - collector_auth_tokens[0].token.clone(), - ) - .unwrap(); + task_parameters.task_id = TaskId::from_str(&provisioned_task.id).unwrap(); + task_parameters.collector_auth_token = + AuthenticationToken::new_bearer_token_from_string(token.clone()).unwrap(); Self { task_parameters, @@ -252,7 +280,6 @@ async fn in_cluster_sum() { } #[tokio::test(flavor = "multi_thread")] -#[ignore = "divviup-api does not currently support DAP-07 (https://github.com/divviup/divviup-api/issues/410)"] async fn in_cluster_histogram() { install_test_trace_subscriber();