Skip to content

Commit

Permalink
Try #32:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Nov 2, 2021
2 parents ed69b90 + 50e02bc commit 0b4dfbb
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
Binary file added other/tests/missing_key/c_a_e.pgp
Binary file not shown.
Binary file added other/tests/missing_key/s_c_a.pgp
Binary file not shown.
Binary file added other/tests/missing_key/s_c_a_e_e.pgp
Binary file not shown.
Binary file added other/tests/missing_key/s_c_a_es.pgp
Binary file not shown.
Binary file added other/tests/missing_key/s_c_a_et_es.pgp
Binary file not shown.
Binary file added other/tests/missing_key/s_c_e.pgp
Binary file not shown.
Binary file added other/tests/missing_key/valid.pgp
Binary file not shown.
37 changes: 37 additions & 0 deletions src/certificate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,40 @@ impl Certificate {
}
}
}

#[cfg(test)]
mod tests {
use crate::certificate::Certificate;
#[test]
fn missing_key_check() {
// is missing an encryption key
let s_c_a = include_bytes!("../../other/tests/missing_key/s_c_a.pgp")[..].into();
Certificate::check(&s_c_a).expect_err("cert is missing encryption keys");

// is missing authentication key
let s_c_e = include_bytes!("../../other/tests/missing_key/s_c_e.pgp")[..].into();
Certificate::check(&s_c_e).expect_err("cert is missing authentication key");

// is missing signing key
let c_a_e = include_bytes!("../../other/tests/missing_key/c_a_e.pgp")[..].into();
Certificate::check(&c_a_e).expect_err("cert is missing signing key");

// has only a key for storage encryption but not one for transport encryption
let s_c_a_es = include_bytes!("../../other/tests/missing_key/s_c_a_es.pgp")[..].into();
Certificate::check(&s_c_a_es).expect_err("cert is missing transport encryption key");

// has two keys one with storage encryption, one with transport encryption
let s_c_a_et_es =
include_bytes!("../../other/tests/missing_key/s_c_a_et_es.pgp")[..].into();
Certificate::check(&s_c_a_et_es)
.expect_err("cert has two encryption keys for transport and storage encryption");

// this cert is valid but has two encryption keys
let s_c_a_e_e = include_bytes!("../../other/tests/missing_key/s_c_a_e_e.pgp")[..].into();
Certificate::check(&s_c_a_e_e).expect_err("cert has two encryption keys");

// this is a valid cert
let valid = include_bytes!("../../other/tests/missing_key/valid.pgp")[..].into();
Certificate::check(&valid).expect("cert is valid");
}
}

0 comments on commit 0b4dfbb

Please sign in to comment.