Skip to content

Commit

Permalink
crypto: Be consistent about /keys/query endpoint name
Browse files Browse the repository at this point in the history
Sometimes, we called this `keys query`, sometimes `/keys/query`, and sometimes,
just for variety, `keys/query`. Generally in Matrix we talk about `/keys/query`
so let's standardise on that.
  • Loading branch information
richvdh authored Nov 22, 2023
1 parent 5c37acb commit 086e988
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
6 changes: 3 additions & 3 deletions benchmarks/benches/crypto_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ fn keys_query_response() -> get_keys::v3::Response {
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

fn keys_claim_response() -> claim_keys::v3::Response {
let data = include_bytes!("crypto_bench/keys_claim.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
claim_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

fn huge_keys_query_response() -> get_keys::v3::Response {
let data = include_bytes!("crypto_bench/keys_query_2000_members.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys query response")
.expect("Can't parse the `/keys/query` response")
}

pub fn keys_query(c: &mut Criterion) {
Expand Down
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-crypto-ffi/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl OlmMachine {
///
/// *Note*: Only users that aren't already tracked will be considered for an
/// update. It's safe to call this with already tracked users, it won't
/// result in excessive keys query requests.
/// result in excessive `/keys/query` requests.
///
/// # Arguments
///
Expand Down
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-crypto-ffi/src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl From<OutgoingRequest> for Request {
Request::KeysUpload {
request_id: r.request_id().to_string(),
body: serde_json::to_string(&body)
.expect("Can't serialize keys upload request"),
.expect("Can't serialize `/keys/upload` request"),
}
}
KeysQuery(k) => {
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-crypto/src/identities/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,14 +887,14 @@ impl ReadOnlyDevice {

/// Create a `ReadOnlyDevice` from an `Account`
///
/// We will have our own device in the store once we receive a keys/query
/// We will have our own device in the store once we receive a `/keys/query`
/// response, but this is useful to create it before we receive such a
/// response.
///
/// It also makes it easier to check that the server doesn't lie about our
/// own device.
///
/// *Don't* use this after we received a keys/query response, other
/// *Don't* use this after we received a `/keys/query` response, other
/// users/devices might add signatures to our own device, which can't be
/// replicated locally.
pub fn from_account(account: &Account) -> ReadOnlyDevice {
Expand Down
24 changes: 12 additions & 12 deletions crates/matrix-sdk-crypto/src/identities/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl IdentityManager {
&self.store.static_account().user_id
}

/// Receive a successful keys query response.
/// Receive a successful `/keys/query` response.
///
/// Returns a list of devices newly discovered devices and devices that
/// changed.
Expand All @@ -115,7 +115,7 @@ impl IdentityManager {
///
/// * `request_id` - The request_id returned by `users_for_key_query` or
/// `build_key_query_for_users`
/// * `response` - The keys query response of the request that the client
/// * `response` - The response of the `/keys/query` request that the client
/// performed.
pub async fn receive_keys_query_response(
&self,
Expand All @@ -126,7 +126,7 @@ impl IdentityManager {
?request_id,
users = ?response.device_keys.keys().collect::<BTreeSet<_>>(),
failures = ?response.failures,
"Handling a keys query response"
"Handling a `/keys/query` response"
);

// Parse the strings into server names and filter out our own server. We should
Expand Down Expand Up @@ -214,7 +214,7 @@ impl IdentityManager {
?deleted_devices,
?new_identities,
?changed_identities,
"Finished handling of the keys/query response"
"Finished handling of the `/keys/query` response"
);

Ok((devices, identities))
Expand Down Expand Up @@ -958,7 +958,7 @@ impl IdentityManager {
"Waiting for `/keys/query` to complete for users who have no devices"
);

// For each user with no devices, fire off a task to wait for a keys/query
// For each user with no devices, fire off a task to wait for a `/keys/query`
// result if one is pending.
//
// We don't actually update the `devices_by_user` map here since that could
Expand Down Expand Up @@ -1117,7 +1117,7 @@ pub(crate) mod testing {
"user_signing_keys": {}
}));
KeyQueryResponse::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

// An updated version of `other_key_query` featuring an additional signature on
Expand Down Expand Up @@ -1183,7 +1183,7 @@ pub(crate) mod testing {
"user_signing_keys": {}
}));
KeyQueryResponse::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

/// Mocked response to a /keys/query request.
Expand Down Expand Up @@ -1285,7 +1285,7 @@ pub(crate) mod testing {
}
}));
KeyQueryResponse::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

pub fn own_key_query() -> KeyQueryResponse {
Expand Down Expand Up @@ -1316,7 +1316,7 @@ pub(crate) mod testing {
);

KeyQueryResponse::try_from_http_response(response_from_file(&json))
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}
}

Expand Down Expand Up @@ -1485,7 +1485,7 @@ pub(crate) mod tests {
});

let response = KeysQueryResponse::try_from_http_response(response_from_file(&response))
.expect("Can't parse the keys query response");
.expect("Can't parse the `/keys/query` response");

manager.receive_keys_query_response(&TransactionId::new(), &response).await.unwrap();

Expand Down Expand Up @@ -1535,7 +1535,7 @@ pub(crate) mod tests {
});

let response = KeysQueryResponse::try_from_http_response(response_from_file(&response))
.expect("Can't parse the keys query response");
.expect("Can't parse the `/keys/query` response");

let (_, private_identity) = manager.handle_cross_signing_keys(&response).await.unwrap();

Expand Down Expand Up @@ -1719,7 +1719,7 @@ pub(crate) mod tests {
let (new_request_id, _) =
manager.as_ref().unwrap().build_key_query_for_users(vec![user_id()]);

// A second `keys/query` response with the same result shouldn't fire a change
// A second `/keys/query` response with the same result shouldn't fire a change
// notification: the identity should be unchanged.
manager
.as_ref()
Expand Down
24 changes: 12 additions & 12 deletions crates/matrix-sdk-crypto/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,12 @@ impl OlmMachine {
})
}

/// Receive a successful keys upload response.
/// Receive a successful `/keys/upload` response.
///
/// # Arguments
///
/// * `response` - The keys upload response of the request that the client
/// performed.
/// * `response` - The response of the `/keys/upload` request that the
/// client performed.
async fn receive_keys_upload_response(&self, response: &UploadKeysResponse) -> OlmResult<()> {
self.inner
.store
Expand Down Expand Up @@ -617,15 +617,15 @@ impl OlmMachine {
self.inner.session_manager.get_missing_sessions(users).await
}

/// Receive a successful keys query response.
/// Receive a successful `/keys/query` response.
///
/// Returns a list of devices newly discovered devices and devices that
/// changed.
///
/// # Arguments
///
/// * `response` - The keys query response of the request that the client
/// performed.
/// * `response` - The response of the `/keys/query` request that the client
/// performed.
async fn receive_keys_query_response(
&self,
request_id: &TransactionId,
Expand Down Expand Up @@ -2152,13 +2152,13 @@ pub(crate) mod tests {
fn keys_upload_response() -> upload_keys::v3::Response {
let data = response_from_file(&test_json::KEYS_UPLOAD);
upload_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

fn keys_query_response() -> get_keys::v3::Response {
let data = response_from_file(&test_json::KEYS_QUERY);
get_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

pub fn to_device_requests_to_content(
Expand Down Expand Up @@ -3210,7 +3210,7 @@ pub(crate) mod tests {
);

let kq_response = KeyQueryResponse::try_from_http_response(response_from_file(&json))
.expect("Can't parse the keys upload response");
.expect("Can't parse the `/keys/upload` response");

alice.receive_keys_query_response(&TransactionId::new(), &kq_response).await.unwrap();
bob.receive_keys_query_response(&TransactionId::new(), &kq_response).await.unwrap();
Expand Down Expand Up @@ -3278,7 +3278,7 @@ pub(crate) mod tests {
);

let kq_response = KeyQueryResponse::try_from_http_response(response_from_file(&json))
.expect("Can't parse the keys upload response");
.expect("Can't parse the `/keys/upload` response");

alice.receive_keys_query_response(&TransactionId::new(), &kq_response).await.unwrap();
bob.receive_keys_query_response(&TransactionId::new(), &kq_response).await.unwrap();
Expand Down Expand Up @@ -3343,7 +3343,7 @@ pub(crate) mod tests {
);

let kq_response = KeyQueryResponse::try_from_http_response(response_from_file(&json))
.expect("Can't parse the keys upload response");
.expect("Can't parse the `/keys/upload` response");

alice.receive_keys_query_response(&TransactionId::new(), &kq_response).await.unwrap();
bob.receive_keys_query_response(&TransactionId::new(), &kq_response).await.unwrap();
Expand All @@ -3368,7 +3368,7 @@ pub(crate) mod tests {

let data = response_from_file(&test_json::KEYS_QUERY_TWO_DEVICES_ONE_SIGNED);
let response = get_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys upload response");
.expect("Can't parse the `/keys/upload` response");

let (device_change, identity_change) =
bob.receive_keys_query_response(&TransactionId::new(), &response).await.unwrap();
Expand Down
12 changes: 6 additions & 6 deletions crates/matrix-sdk-crypto/src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ impl KeysQueryRequest {
/// Enum over the different outgoing requests we can have.
#[derive(Debug)]
pub enum OutgoingRequests {
/// The keys upload request, uploading device and one-time keys.
/// The `/keys/upload` request, uploading device and one-time keys.
KeysUpload(KeysUploadRequest),
/// The keys query request, fetching the device and cross signing keys of
/// The `/keys/query` request, fetching the device and cross signing keys of
/// other users.
KeysQuery(KeysQueryRequest),
/// The request to claim one-time keys for a user/device pair from the
Expand Down Expand Up @@ -292,18 +292,18 @@ impl From<KeysUploadRequest> for OutgoingRequest {
/// Enum over all the incoming responses we need to receive.
#[derive(Debug)]
pub enum IncomingResponse<'a> {
/// The keys upload response, notifying us about the amount of uploaded
/// The `/keys/upload` response, notifying us about the amount of uploaded
/// one-time keys.
KeysUpload(&'a KeysUploadResponse),
/// The keys query response, giving us the device and cross signing keys of
/// other users.
/// The `/keys/query` response, giving us the device and cross signing keys
/// of other users.
KeysQuery(&'a KeysQueryResponse),
/// The to-device response, an empty response.
ToDevice(&'a ToDeviceResponse),
/// The key claiming requests, giving us new one-time keys of other users so
/// new Olm sessions can be created.
KeysClaim(&'a KeysClaimResponse),
/// The cross signing keys upload response, marking our private cross
/// The cross signing `/keys/upload` response, marking our private cross
/// signing identity as shared.
SigningKeysUpload(&'a SigningKeysUploadResponse),
/// The cross signing signature upload response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ mod tests {
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

fn bob_keys_query_response() -> get_keys::v3::Response {
Expand Down Expand Up @@ -910,7 +910,7 @@ mod tests {
let data = response_from_file(&data);

get_keys::v3::Response::try_from_http_response(data)
.expect("Can't parse the keys upload response")
.expect("Can't parse the `/keys/upload` response")
}

/// Returns a keys claim response for device `BOBDEVICE` of user
Expand Down
8 changes: 4 additions & 4 deletions crates/matrix-sdk-crypto/src/session_manager/sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,8 @@ mod tests {
async fn test_session_creation_waits_for_keys_query() {
let (manager, identity_manager) = session_manager_test_helper().await;

// start a keys query request. At this point, we are only interested in our own
// devices.
// start a `/keys/query` request. At this point, we are only interested in our
// own devices.
let (key_query_txn_id, key_query_request) =
identity_manager.users_for_key_query().await.unwrap().pop_first().unwrap();
info!("Initial key query: {:?}", key_query_request);
Expand Down Expand Up @@ -752,7 +752,7 @@ mod tests {
})
};

// the initial keys query completes, and we start another
// the initial `/keys/query` completes, and we start another
let response_json =
json!({ "device_keys": { manager.store.static_account().user_id.to_owned(): {}}});
let response =
Expand Down Expand Up @@ -797,7 +797,7 @@ mod tests {
.unwrap();
}

// Do a keys query request, in which Bob's server is a failure.
// Do a `/keys/query` request, in which Bob's server is a failure.
let (key_query_txn_id, _key_query_request) =
identity_manager.users_for_key_query().await.unwrap().pop_first().unwrap();
let response = KeysQueryResponse::try_from_http_response(response_from_file(
Expand Down

0 comments on commit 086e988

Please sign in to comment.