Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeoghegan committed Sep 22, 2023
1 parent 0273c6d commit 5fca9e0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
70 changes: 70 additions & 0 deletions aggregator_core/src/datastore/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,76 @@ async fn roundtrip_task(ephemeral_datastore: EphemeralDatastore) {
assert_eq!(want_tasks, got_tasks);
}

#[rstest_reuse::apply(schema_versions_template)]
#[tokio::test]
async fn put_task_invalid_aggregator_auth_tokens(ephemeral_datastore: EphemeralDatastore) {
install_test_trace_subscriber();
let ds = ephemeral_datastore.datastore(MockClock::default()).await;

let task = TaskBuilder::new(
task::QueryType::TimeInterval,
VdafInstance::Prio3Count,
Role::Leader,
)
.build();

ds.put_task(&task).await.unwrap();

for (auth_token, auth_token_type) in [("NULL", "'BEARER'"), ("\\xDEADBEEF::bytea", "NULL")] {
ds.run_tx(|tx| {
Box::pin(async move {
tx.query_one(
&format!(
"UPDATE tasks SET aggregator_auth_token = {auth_token},
aggregator_auth_token_type = {auth_token_type}"
),
&[],
)
.await
.unwrap_err();
Ok(())
})
})
.await
.unwrap();
}
}

#[rstest_reuse::apply(schema_versions_template)]
#[tokio::test]
async fn put_task_invalid_collector_auth_tokens(ephemeral_datastore: EphemeralDatastore) {
install_test_trace_subscriber();
let ds = ephemeral_datastore.datastore(MockClock::default()).await;

let task = TaskBuilder::new(
task::QueryType::TimeInterval,
VdafInstance::Prio3Count,
Role::Leader,
)
.build();

ds.put_task(&task).await.unwrap();

for (auth_token, auth_token_type) in [("NULL", "'BEARER'"), ("\\xDEADBEEF::bytea", "NULL")] {
ds.run_tx(|tx| {
Box::pin(async move {
tx.query_one(
&format!(
"UPDATE tasks SET collector_auth_token = {auth_token},
collector_auth_token_type = {auth_token_type}"
),
&[],
)
.await
.unwrap_err();
Ok(())
})
})
.await
.unwrap();
}
}

#[rstest_reuse::apply(schema_versions_template)]
#[tokio::test]
async fn get_task_metrics(ephemeral_datastore: EphemeralDatastore) {
Expand Down
2 changes: 1 addition & 1 deletion aggregator_core/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub struct Task {
/// Token used to authenticate messages sent to or received from the other aggregator. Only set
/// if the task was not created via taskprov.
aggregator_auth_token: Option<AuthenticationToken>,
/// Token used to authenticate messages sent to received from the collector. Only set if this
/// Token used to authenticate messages sent to or received from the collector. Only set if this
/// aggregator is the leader.
collector_auth_token: Option<AuthenticationToken>,
/// HPKE configurations & private keys used by this aggregator to decrypt client reports.
Expand Down

0 comments on commit 5fca9e0

Please sign in to comment.