Skip to content

Commit

Permalink
adopt new divviup-client (#2121)
Browse files Browse the repository at this point in the history
The PRs related to divviup/divviup-api#542
implement the new concept of "collector credential". This entails
changes to the API for provisioning tasks via divviup-api that we use in
e2e integration tests. In this commit we adopt the new `divviup-client`
and fix up its usage.

Part of #2071
  • Loading branch information
tgeoghegan authored Oct 23, 2023
1 parent 4a4bedf commit 21806a7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
38 changes: 23 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aggregator_api/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub(super) async fn post_task<C: Clock>(
})?;
let collector_auth_token_hash = req.collector_auth_token_hash.ok_or_else(|| {
Error::BadRequest(
"aggregator acting in leader role must be provided a collector auth token"
"aggregator acting in leader role must be provided a collector auth token hash"
.to_string(),
)
})?;
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +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"], rev = "06667dbeb93d4870bb257b7ddf9a19b37a7e5da5" }
divviup-client = { git = "https://github.com/divviup/divviup-api", features = ["admin"], tag = "0.0.30" }
futures = "0.3.28"
hex = "0.4"
http = "0.2"
Expand Down
25 changes: 9 additions & 16 deletions integration_tests/tests/in_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![cfg(feature = "in-cluster")]
use common::{submit_measurements_and_verify_aggregate, test_task_builder};
use divviup_client::{
Client, CollectorAuthenticationToken, DivviupClient, Histogram, HpkeConfigContents,
NewAggregator, NewSharedAggregator, NewTask, Vdaf,
Client, DivviupClient, Histogram, HpkeConfig, NewAggregator, NewSharedAggregator, NewTask, Vdaf,
};
use janus_aggregator_core::task::QueryType;
use janus_core::{
Expand Down Expand Up @@ -145,10 +144,10 @@ impl InClusterJanusPair {
.unwrap();

let hpke_config = task.collector_hpke_keypair().config();
let collector_hpke_config = divviup_api
.create_hpke_config(
let collector_credential = divviup_api
.create_collector_credential(
account.id,
&HpkeConfigContents::new(
&HpkeConfig::new(
u8::from(*hpke_config.id()).into(),
u16::from(*hpke_config.kem_id()).try_into().unwrap(),
u16::from(*hpke_config.kdf_id()).try_into().unwrap(),
Expand Down Expand Up @@ -200,7 +199,7 @@ impl InClusterJanusPair {
QueryType::FixedSize { max_batch_size, .. } => Some(*max_batch_size),
},
time_precision_seconds: task.time_precision().as_seconds(),
hpke_config_id: collector_hpke_config.id,
collector_credential_id: collector_credential.id,
};

// Provision the task into both aggregators via divviup-api
Expand All @@ -209,18 +208,12 @@ impl InClusterJanusPair {
.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).unwrap();
task_parameters.collector_auth_token =
AuthenticationToken::new_bearer_token_from_string(token.clone()).unwrap();
task_parameters.collector_auth_token = AuthenticationToken::new_bearer_token_from_string(
collector_credential.token.clone().unwrap(),
)
.unwrap();

Self {
task_parameters,
Expand Down

0 comments on commit 21806a7

Please sign in to comment.