From 3a0ed1b3b81b29530c0dd5d65a5409c349f85aae Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 5 Feb 2019 14:47:14 +0000 Subject: Return AuthenticationError from authenticate_* --- tests/device.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/device.rs b/tests/device.rs index e367558..630dd93 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -103,7 +103,7 @@ where let result = device.authenticate_admin(&(DEFAULT_ADMIN_PIN.to_owned() + suffix)); let device = match result { Ok(admin) => admin.device(), - Err((device, _)) => device, + Err(err) => err.into_device(), }; assert_ok!(count, device.get_admin_retry_count()); return device; @@ -116,7 +116,7 @@ where let result = device.authenticate_user(&(DEFAULT_USER_PIN.to_owned() + suffix)); let device = match result { Ok(admin) => admin.device(), - Err((device, _)) => device, + Err(err) => err.into_device(), }; assert_ok!(count, device.get_user_retry_count()); return device; @@ -158,7 +158,10 @@ fn config(device: DeviceWrapper) { #[test_device] fn change_user_pin(device: DeviceWrapper) { let device = device.authenticate_user(DEFAULT_USER_PIN).unwrap().device(); - let device = device.authenticate_user(USER_NEW_PASSWORD).unwrap_err().0; + let device = device + .authenticate_user(USER_NEW_PASSWORD) + .unwrap_err() + .into_device(); let mut device = device; assert_ok!( @@ -166,7 +169,10 @@ fn change_user_pin(device: DeviceWrapper) { device.change_user_pin(DEFAULT_USER_PIN, USER_NEW_PASSWORD) ); - let device = device.authenticate_user(DEFAULT_USER_PIN).unwrap_err().0; + let device = device + .authenticate_user(DEFAULT_USER_PIN) + .unwrap_err() + .into_device(); let device = device .authenticate_user(USER_NEW_PASSWORD) .unwrap() @@ -191,14 +197,20 @@ fn change_admin_pin(device: DeviceWrapper) { .authenticate_admin(DEFAULT_ADMIN_PIN) .unwrap() .device(); - let mut device = device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap_err().0; + let mut device = device + .authenticate_admin(ADMIN_NEW_PASSWORD) + .unwrap_err() + .into_device(); assert_ok!( (), device.change_admin_pin(DEFAULT_ADMIN_PIN, ADMIN_NEW_PASSWORD) ); - let device = device.authenticate_admin(DEFAULT_ADMIN_PIN).unwrap_err().0; + let device = device + .authenticate_admin(DEFAULT_ADMIN_PIN) + .unwrap_err() + .into_device(); let mut device = device .authenticate_admin(ADMIN_NEW_PASSWORD) .unwrap() @@ -229,11 +241,11 @@ where let result = device.authenticate_user(password); assert!(result.is_err()); let err = result.unwrap_err(); - match err.1 { + match *err.as_error() { Error::CommandError(err) => assert_eq!(error, err), _ => assert!(false), }; - err.0 + err.into_device() } #[test_device] -- cgit v1.2.3