diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2018-05-28 22:02:10 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2018-05-29 00:03:56 +0200 |
commit | 89b8a947e5c622272362e967847eb19337aa68da (patch) | |
tree | ccbd24b53b4a98312247a304b51774fac2e3b685 /src/tests/otp.rs | |
parent | f58400a22986cdedf34f85dc17d1d59335ffb404 (diff) | |
download | nitrokey-rs-89b8a947e5c622272362e967847eb19337aa68da.tar.gz nitrokey-rs-89b8a947e5c622272362e967847eb19337aa68da.tar.bz2 |
Add rudimentary support for the Nitrokey Storage
This patch adds the Storage struct and the test-storage feature. It
also enables all currently supported Pro commands for the Storage.
Diffstat (limited to 'src/tests/otp.rs')
-rw-r--r-- | src/tests/otp.rs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/tests/otp.rs b/src/tests/otp.rs index e96bbfe..10f569d 100644 --- a/src/tests/otp.rs +++ b/src/tests/otp.rs @@ -1,7 +1,7 @@ use std::ops::Deref; -use {Admin, Authenticate, CommandError, CommandStatus, Config, ConfigureOtp, DeviceWrapper, GenerateOtp, +use {Admin, Authenticate, CommandError, CommandStatus, Config, ConfigureOtp, GenerateOtp, OtpMode, OtpSlotData}; -use tests::util::{ADMIN_PASSWORD, USER_PASSWORD}; +use tests::util::{Target, ADMIN_PASSWORD, USER_PASSWORD}; // test suite according to RFC 4226, Appendix D static HOTP_SECRET: &str = "3132333435363738393031323334353637383930"; @@ -21,8 +21,8 @@ static TOTP_CODES: &[(u64, &str)] = &[ (20000000000, "65353130"), ]; -fn get_admin_test_device() -> Admin<DeviceWrapper> { - ::connect().expect("Could not connect to the Nitrokey Pro.") +fn get_admin_test_device() -> Admin<Target> { + Target::connect().expect("Could not connect to the Nitrokey Pro.") .authenticate_admin(ADMIN_PASSWORD) .expect("Could not login as admin.") } @@ -40,7 +40,7 @@ fn check_hotp_codes(device: &GenerateOtp) { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn hotp_no_pin() { let admin = get_admin_test_device(); let config = Config::new(None, None, None, false); @@ -54,7 +54,7 @@ fn hotp_no_pin() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn hotp_pin() { let admin = get_admin_test_device(); let config = Config::new(None, None, None, true); @@ -68,7 +68,7 @@ fn hotp_pin() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn hotp_slot_name() { let admin = get_admin_test_device(); let slot_data = OtpSlotData::new(1, "test-hotp", HOTP_SECRET, OtpMode::SixDigits); @@ -82,7 +82,7 @@ fn hotp_slot_name() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn hotp_error() { let admin = get_admin_test_device(); let slot_data = OtpSlotData::new(1, "", HOTP_SECRET, OtpMode::SixDigits); @@ -100,7 +100,7 @@ fn hotp_error() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn hotp_erase() { let admin = get_admin_test_device(); let config = Config::new(None, None, None, false); @@ -141,7 +141,7 @@ fn check_totp_codes(device: &GenerateOtp) { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn totp_no_pin() { // TODO: this test may fail due to bad timing --> find solution let admin = get_admin_test_device(); @@ -156,7 +156,7 @@ fn totp_no_pin() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn totp_pin() { // TODO: this test may fail due to bad timing --> find solution let admin = get_admin_test_device(); @@ -171,7 +171,7 @@ fn totp_pin() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn totp_slot_name() { let admin = get_admin_test_device(); let slot_data = OtpSlotData::new(1, "test-totp", TOTP_SECRET, OtpMode::EightDigits); @@ -186,7 +186,7 @@ fn totp_slot_name() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn totp_error() { let admin = get_admin_test_device(); let slot_data = OtpSlotData::new(1, "", HOTP_SECRET, OtpMode::SixDigits); @@ -204,7 +204,7 @@ fn totp_error() { } #[test] -#[cfg_attr(not(feature = "test-pro"), ignore)] +#[cfg_attr(not(any(feature = "test-pro", feature = "test-storage")), ignore)] fn totp_erase() { let admin = get_admin_test_device(); let config = Config::new(None, None, None, false); @@ -224,4 +224,3 @@ fn totp_erase() { assert_eq!("test2", device.get_totp_slot_name(2).unwrap()); } - |