Allow to delete an IKM
This commit is contained in:
parent
c6a3855847
commit
6ceb598c04
1 changed files with 24 additions and 0 deletions
24
src/ikm.rs
24
src/ikm.rs
|
@ -98,6 +98,11 @@ impl InputKeyMaterialList {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ikm-management")]
|
||||||
|
pub fn delete_ikm(&mut self, id: IkmId) {
|
||||||
|
self.ikm_lst.retain(|ikm| ikm.id != id);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ikm-management")]
|
#[cfg(feature = "ikm-management")]
|
||||||
pub fn revoke_ikm(&mut self, id: IkmId) -> Result<()> {
|
pub fn revoke_ikm(&mut self, id: IkmId) -> Result<()> {
|
||||||
let ikm = self
|
let ikm = self
|
||||||
|
@ -288,6 +293,25 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "ikm-management")]
|
||||||
|
fn delete_ikm() {
|
||||||
|
let mut lst = InputKeyMaterialList::new();
|
||||||
|
let _ = lst.add_ikm();
|
||||||
|
let _ = lst.add_ikm();
|
||||||
|
|
||||||
|
let latest_ikm = lst.get_latest_ikm().unwrap();
|
||||||
|
assert_eq!(latest_ikm.id, 2);
|
||||||
|
|
||||||
|
lst.delete_ikm(2);
|
||||||
|
let latest_ikm = lst.get_latest_ikm().unwrap();
|
||||||
|
assert_eq!(latest_ikm.id, 1);
|
||||||
|
|
||||||
|
lst.delete_ikm(1);
|
||||||
|
let res = lst.get_latest_ikm();
|
||||||
|
assert!(res.is_err());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "ikm-management")]
|
#[cfg(feature = "ikm-management")]
|
||||||
fn revoke_ikm() {
|
fn revoke_ikm() {
|
||||||
|
|
Loading…
Reference in a new issue