Skip to content

Commit

Permalink
Strip device metadata from lookup (#2143)
Browse files Browse the repository at this point in the history
This PR removes the `metadata` field from the `lookup` endpoint.
  • Loading branch information
Frederik Rothenberger authored Dec 15, 2023
1 parent c306d46 commit f28f51d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/internet_identity/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ fn lookup(anchor_number: AnchorNumber) -> Vec<DeviceData> {
.map(|mut d| {
// Remove non-public fields.
d.alias = "".to_string();
d.metadata = None;
d
})
.collect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,23 @@ fn should_lookup() -> Result<(), CallError> {
user_number,
&recovery_device_data_1(),
)?;
api::add(
&env,
canister_id,
principal_1(),
user_number,
&large_size_device(),
)?;

let mut devices = api::lookup(&env, canister_id, user_number)?;
devices.sort_by(|a, b| a.pubkey.cmp(&b.pubkey));

let mut anchor_info = api::get_anchor_info(&env, canister_id, principal_1(), user_number)?;
// clear alias to make it consistent with lookup
anchor_info
.devices
.iter_mut()
.for_each(|device| device.alias = "".to_string());
anchor_info.devices.iter_mut().for_each(|device| {
device.alias = "".to_string();
device.metadata = None;
});
anchor_info.devices.sort_by(|a, b| a.pubkey.cmp(&b.pubkey));

assert_eq!(devices, anchor_info.into_device_data());
Expand Down

0 comments on commit f28f51d

Please sign in to comment.