diff options
Diffstat (limited to 'src/tests/pro.rs')
-rw-r--r-- | src/tests/pro.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/tests/pro.rs b/src/tests/pro.rs index e39c95a..ece94bf 100644 --- a/src/tests/pro.rs +++ b/src/tests/pro.rs @@ -1,7 +1,6 @@ use std::ffi::CStr; -use std::marker::Sized; -use {set_debug, AdminAuthenticatedDevice, CommandError, CommandStatus, Config, Device, Model, - OtpMode, OtpSlotData, UnauthenticatedDevice}; +use {set_debug, AdminAuthenticatedDevice, CommandError, CommandStatus, Config, ConfigureOtp, + Device, GenerateOtp, Model, OtpMode, OtpSlotData, UnauthenticatedDevice}; static ADMIN_PASSWORD: &str = "12345678"; static ADMIN_NEW_PASSWORD: &str = "1234567890"; @@ -84,15 +83,12 @@ fn get_serial_number() { assert!(serial_number.chars().all(|c| c.is_ascii_hexdigit())); } -fn configure_hotp(admin: &AdminAuthenticatedDevice) { +fn configure_hotp(admin: &ConfigureOtp) { let slot_data = OtpSlotData::new(1, "test-hotp", HOTP_SECRET, OtpMode::SixDigits); assert_eq!(CommandStatus::Success, admin.write_hotp_slot(slot_data, 0)); } -fn check_hotp_codes<T: Device>(device: &T) -where - T: Sized, -{ +fn check_hotp_codes<T: GenerateOtp>(device: &T) { for code in HOTP_CODES { let result = device.get_hotp_code(1); assert_eq!(code, &result.unwrap()); @@ -181,15 +177,12 @@ fn hotp_erase() { assert_eq!("test2", device.get_hotp_slot_name(2).unwrap()); } -fn configure_totp(admin: &AdminAuthenticatedDevice) { +fn configure_totp(admin: &ConfigureOtp) { let slot_data = OtpSlotData::new(1, "test-totp", TOTP_SECRET, OtpMode::EightDigits); assert_eq!(CommandStatus::Success, admin.write_totp_slot(slot_data, 30)); } -fn check_totp_codes<T: Device>(device: &T) -where - T: Sized, -{ +fn check_totp_codes<T: Device + GenerateOtp>(device: &T) { for (i, &(time, code)) in TOTP_CODES.iter().enumerate() { assert_eq!(CommandStatus::Success, device.set_time(time)); let result = device.get_totp_code(1); |