Skip to content

Commit

Permalink
tests/reading: test reading keys and keyrings as each other
Browse files Browse the repository at this point in the history
  • Loading branch information
mathstuf committed Aug 2, 2019
1 parent 603d114 commit 82d2878
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/tests/reading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ fn read_keyring() {
keyring.invalidate().unwrap();
}

#[test]
fn read_key_as_keyring() {
let mut keyring = utils::new_test_keyring();
let payload = "payload".as_bytes();
let key = keyring
.add_key::<User, _, _>("read_key_as_keyring", payload)
.unwrap();
let not_a_keyring = utils::key_as_keyring(&key);

let err = not_a_keyring.read().unwrap_err();
assert_eq!(err, errno::Errno(libc::ENOTDIR));

keyring.invalidate().unwrap();
}

#[test]
fn read_keyring_as_key() {
let keyring = utils::new_test_keyring();
let not_a_key = utils::keyring_as_key(&keyring);

let payload = not_a_key.read().unwrap();
assert_eq!(b"", payload.as_slice());

keyring.invalidate().unwrap();
}

#[test]
fn read_no_read_perm_with_search() {
let mut keyring = utils::new_test_keyring();
Expand Down

0 comments on commit 82d2878

Please sign in to comment.