summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/pro.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/tests/pro.rs b/src/tests/pro.rs
index a23d42a..d2132f8 100644
--- a/src/tests/pro.rs
+++ b/src/tests/pro.rs
@@ -4,7 +4,9 @@ use {set_debug, AdminAuthenticatedDevice, CommandError, CommandStatus, Config, D
OtpMode, OtpSlotData, UnauthenticatedDevice};
static ADMIN_PASSWORD: &str = "12345678";
+static ADMIN_NEW_PASSWORD: &str = "1234567890";
static USER_PASSWORD: &str = "123456";
+static USER_NEW_PASSWORD: &str = "abcdefghij";
// test suite according to RFC 4226, Appendix D
static HOTP_SECRET: &str = "3132333435363738393031323334353637383930";
@@ -330,3 +332,49 @@ fn read_write_config() {
let get_config = admin.get_config().unwrap();
assert_eq!(config, get_config);
}
+
+#[test]
+#[cfg_attr(not(feature = "test-pro"), ignore)]
+fn change_user_pin() {
+ let device = get_test_device();
+ let device = device.authenticate_user(USER_PASSWORD).unwrap().device();
+ let device = device.authenticate_user(USER_NEW_PASSWORD).unwrap_err().0;
+
+ let result = device.change_user_pin(USER_PASSWORD, USER_NEW_PASSWORD);
+ assert_eq!(CommandStatus::Success, result);
+
+ let device = device.authenticate_user(USER_PASSWORD).unwrap_err().0;
+ let device = device.authenticate_user(USER_NEW_PASSWORD).unwrap().device();
+
+ let result = device.change_user_pin(USER_PASSWORD, USER_PASSWORD);
+ assert_eq!(CommandStatus::Error(CommandError::WrongPassword), result);
+
+ let result = device.change_user_pin(USER_NEW_PASSWORD, USER_PASSWORD);
+ assert_eq!(CommandStatus::Success, result);
+
+ let device = device.authenticate_user(USER_PASSWORD).unwrap().device();
+ device.authenticate_user(USER_NEW_PASSWORD).unwrap_err();
+}
+
+#[test]
+#[cfg_attr(not(feature = "test-pro"), ignore)]
+fn change_admin_pin() {
+ let device = get_test_device();
+ let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap().device();
+ let device = device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap_err().0;
+
+ let result = device.change_admin_pin(ADMIN_PASSWORD, ADMIN_NEW_PASSWORD);
+ assert_eq!(CommandStatus::Success, result);
+
+ let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap_err().0;
+ let device = device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap().device();
+
+ let result = device.change_admin_pin(ADMIN_PASSWORD, ADMIN_PASSWORD);
+ assert_eq!(CommandStatus::Error(CommandError::WrongPassword), result);
+
+ let result = device.change_admin_pin(ADMIN_NEW_PASSWORD, ADMIN_PASSWORD);
+ assert_eq!(CommandStatus::Success, result);
+
+ let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap().device();
+ device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap_err();
+}