implements Default for Response type
This commit is contained in:
@@ -49,17 +49,10 @@ fn enumerate_rps_response(
|
|||||||
let rp_id_hash = rp_id.map(|rp_id| Sha256::hash(rp_id.as_bytes()).to_vec());
|
let rp_id_hash = rp_id.map(|rp_id| Sha256::hash(rp_id.as_bytes()).to_vec());
|
||||||
|
|
||||||
Ok(AuthenticatorCredentialManagementResponse {
|
Ok(AuthenticatorCredentialManagementResponse {
|
||||||
existing_resident_credentials_count: None,
|
|
||||||
max_possible_remaining_resident_credentials_count: None,
|
|
||||||
rp,
|
rp,
|
||||||
rp_id_hash,
|
rp_id_hash,
|
||||||
total_rps,
|
total_rps,
|
||||||
user: None,
|
..Default::default()
|
||||||
credential_id: None,
|
|
||||||
public_key: None,
|
|
||||||
total_credentials: None,
|
|
||||||
cred_protect: None,
|
|
||||||
large_blob_key: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,11 +86,6 @@ fn enumerate_credentials_response(
|
|||||||
};
|
};
|
||||||
let public_key = CoseKey::from(private_key.genpk());
|
let public_key = CoseKey::from(private_key.genpk());
|
||||||
Ok(AuthenticatorCredentialManagementResponse {
|
Ok(AuthenticatorCredentialManagementResponse {
|
||||||
existing_resident_credentials_count: None,
|
|
||||||
max_possible_remaining_resident_credentials_count: None,
|
|
||||||
rp: None,
|
|
||||||
rp_id_hash: None,
|
|
||||||
total_rps: None,
|
|
||||||
user: Some(user),
|
user: Some(user),
|
||||||
credential_id: Some(credential_id),
|
credential_id: Some(credential_id),
|
||||||
public_key: Some(public_key),
|
public_key: Some(public_key),
|
||||||
@@ -105,6 +93,7 @@ fn enumerate_credentials_response(
|
|||||||
cred_protect: cred_protect_policy,
|
cred_protect: cred_protect_policy,
|
||||||
// TODO(kaczmarczyck) add when largeBlobKey is implemented
|
// TODO(kaczmarczyck) add when largeBlobKey is implemented
|
||||||
large_blob_key: None,
|
large_blob_key: None,
|
||||||
|
..Default::default()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,15 +106,7 @@ fn process_get_creds_metadata(
|
|||||||
max_possible_remaining_resident_credentials_count: Some(
|
max_possible_remaining_resident_credentials_count: Some(
|
||||||
persistent_store.remaining_credentials()? as u64,
|
persistent_store.remaining_credentials()? as u64,
|
||||||
),
|
),
|
||||||
rp: None,
|
..Default::default()
|
||||||
rp_id_hash: None,
|
|
||||||
total_rps: None,
|
|
||||||
user: None,
|
|
||||||
credential_id: None,
|
|
||||||
public_key: None,
|
|
||||||
total_credentials: None,
|
|
||||||
cred_protect: None,
|
|
||||||
large_blob_key: None,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ impl From<AuthenticatorClientPinResponse> for cbor::Value {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
|
#[cfg_attr(any(test, feature = "debug_ctap"), derive(Debug))]
|
||||||
pub struct AuthenticatorCredentialManagementResponse {
|
pub struct AuthenticatorCredentialManagementResponse {
|
||||||
@@ -435,19 +436,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_used_credential_management_into_cbor() {
|
fn test_used_credential_management_into_cbor() {
|
||||||
let cred_management_response = AuthenticatorCredentialManagementResponse {
|
let cred_management_response = AuthenticatorCredentialManagementResponse::default();
|
||||||
existing_resident_credentials_count: None,
|
|
||||||
max_possible_remaining_resident_credentials_count: None,
|
|
||||||
rp: None,
|
|
||||||
rp_id_hash: None,
|
|
||||||
total_rps: None,
|
|
||||||
user: None,
|
|
||||||
credential_id: None,
|
|
||||||
public_key: None,
|
|
||||||
total_credentials: None,
|
|
||||||
cred_protect: None,
|
|
||||||
large_blob_key: None,
|
|
||||||
};
|
|
||||||
let response_cbor: Option<cbor::Value> =
|
let response_cbor: Option<cbor::Value> =
|
||||||
ResponseData::AuthenticatorCredentialManagement(Some(cred_management_response)).into();
|
ResponseData::AuthenticatorCredentialManagement(Some(cred_management_response)).into();
|
||||||
let expected_cbor = cbor_map_options! {};
|
let expected_cbor = cbor_map_options! {};
|
||||||
|
|||||||
Reference in New Issue
Block a user