From 8350ac6afb2d678b74581000a6aafe1994b72231 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Wed, 16 Jan 2019 17:26:30 -0800 Subject: Update nitrokey crate to 0.3.3 This change updates the nitrokey crate to version 0.3.3. Along with that change we update rand to 0.6.4 because rand 0.6.1 does not yet contain a publicly accessible rand_os. Note that we no longer require all crates in rand's workspace, but only rand_os and rand_core, which is a significant reduction in the number of lines of code compiled. Import subrepo nitrokey/:nitrokey at 7cf747d56ddc0b7eeedc3caf36dcc909907a171c Import subrepo rand/:rand at 4336232dda03323634b10ec72ddf27914aebc3a2 --- nitrokey/tests/pws.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'nitrokey/tests/pws.rs') diff --git a/nitrokey/tests/pws.rs b/nitrokey/tests/pws.rs index b349558..fbcc0c1 100644 --- a/nitrokey/tests/pws.rs +++ b/nitrokey/tests/pws.rs @@ -20,7 +20,7 @@ fn get_slot_name_direct(slot: u8) -> Result { true => { let error = unsafe { nitrokey_sys::NK_get_last_command_status() } as c_int; match error { - 0 => Err(CommandError::Undefined), + 0 => Ok(s), other => Err(CommandError::from(other)), } } @@ -92,10 +92,12 @@ fn get_data(device: DeviceWrapper) { assert_eq!("password", pws.get_slot_password(1).unwrap()); assert_eq!(Ok(()), pws.erase_slot(1)); - // TODO: check error codes - assert_eq!(Err(CommandError::Undefined), pws.get_slot_name(1)); - assert_eq!(Err(CommandError::Undefined), pws.get_slot_login(1)); - assert_eq!(Err(CommandError::Undefined), pws.get_slot_password(1)); + assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_name(1)); + assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_login(1)); + assert_eq!( + Err(CommandError::SlotNotProgrammed), + pws.get_slot_password(1) + ); let name = "with å"; let login = "pär@test.com"; @@ -129,19 +131,22 @@ fn write(device: DeviceWrapper) { ); assert_eq!(Ok(()), pws.write_slot(0, "", "login", "password")); - assert_eq!(Err(CommandError::Undefined), pws.get_slot_name(0)); + assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_name(0)); assert_eq!(Ok(String::from("login")), pws.get_slot_login(0)); assert_eq!(Ok(String::from("password")), pws.get_slot_password(0)); assert_eq!(Ok(()), pws.write_slot(0, "name", "", "password")); assert_eq!(Ok(String::from("name")), pws.get_slot_name(0)); - assert_eq!(Err(CommandError::Undefined), pws.get_slot_login(0)); + assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_login(0)); assert_eq!(Ok(String::from("password")), pws.get_slot_password(0)); assert_eq!(Ok(()), pws.write_slot(0, "name", "login", "")); assert_eq!(Ok(String::from("name")), pws.get_slot_name(0)); assert_eq!(Ok(String::from("login")), pws.get_slot_login(0)); - assert_eq!(Err(CommandError::Undefined), pws.get_slot_password(0)); + assert_eq!( + Err(CommandError::SlotNotProgrammed), + pws.get_slot_password(0) + ); } #[test_device] @@ -152,5 +157,5 @@ fn erase(device: DeviceWrapper) { assert_eq!(Ok(()), pws.write_slot(0, "name", "login", "password")); assert_eq!(Ok(()), pws.erase_slot(0)); assert_eq!(Ok(()), pws.erase_slot(0)); - assert_eq!(Err(CommandError::Undefined), pws.get_slot_name(0)); + assert_eq!(Err(CommandError::SlotNotProgrammed), pws.get_slot_name(0)); } -- cgit v1.2.1