aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-12-29 23:00:09 +0100
committerRobin Krahl <robin.krahl@ireas.org>2019-12-29 23:00:09 +0100
commit0e07d9cdd6b333ebd16160d673f8735940af3a43 (patch)
tree409a9ac5b6f6ab186f4351df0d69fd9a7800fdc3
parent9b864579a818002a3a6025a4155530966da2312d (diff)
downloadnitrokey-rs-0e07d9cdd6b333ebd16160d673f8735940af3a43.tar.gz
nitrokey-rs-0e07d9cdd6b333ebd16160d673f8735940af3a43.tar.bz2
Use dyn keyword for trait arguments in tests/otp.rs
To fix a compiler warning, we use the dyn keyword for trait arguments in the otp.rs instead of using the trait directly.
-rw-r--r--tests/otp.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/otp.rs b/tests/otp.rs
index aafda59..38cd8a9 100644
--- a/tests/otp.rs
+++ b/tests/otp.rs
@@ -44,12 +44,12 @@ where
unwrap_ok!(device.authenticate_admin(DEFAULT_ADMIN_PIN))
}
-fn configure_hotp(admin: &mut ConfigureOtp, counter: u8) {
+fn configure_hotp(admin: &mut dyn ConfigureOtp, counter: u8) {
let slot_data = OtpSlotData::new(1, "test-hotp", HOTP_SECRET, OtpMode::SixDigits);
assert_ok!((), admin.write_hotp_slot(slot_data, counter.into()));
}
-fn check_hotp_codes(device: &mut GenerateOtp, offset: u8) {
+fn check_hotp_codes(device: &mut dyn GenerateOtp, offset: u8) {
HOTP_CODES.iter().enumerate().for_each(|(i, code)| {
if i >= offset as usize {
assert_ok!(code.to_string(), device.get_hotp_code(1));
@@ -146,13 +146,13 @@ fn hotp_erase(device: DeviceWrapper) {
assert_ok!("test2".to_string(), device.get_hotp_slot_name(2));
}
-fn configure_totp(admin: &mut ConfigureOtp, factor: u64) {
+fn configure_totp(admin: &mut dyn ConfigureOtp, factor: u64) {
let slot_data = OtpSlotData::new(1, "test-totp", TOTP_SECRET, OtpMode::EightDigits);
let time_window = 30u64.checked_mul(factor).unwrap();
assert_ok!((), admin.write_totp_slot(slot_data, time_window as u16));
}
-fn check_totp_codes(device: &mut GenerateOtp, factor: u64, timestamp_size: TotpTimestampSize) {
+fn check_totp_codes(device: &mut dyn GenerateOtp, factor: u64, timestamp_size: TotpTimestampSize) {
for (base_time, codes) in TOTP_CODES {
let time = base_time.checked_mul(factor).unwrap();
let is_u64 = time > u32::max_value() as u64;