aboutsummaryrefslogtreecommitdiff
path: root/src/tests/otp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/otp.rs')
-rw-r--r--src/tests/otp.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/tests/otp.rs b/src/tests/otp.rs
index f923170..1b59669 100644
--- a/src/tests/otp.rs
+++ b/src/tests/otp.rs
@@ -23,7 +23,10 @@ use crate::args;
#[test_device]
fn set_invalid_slot_raw(model: nitrokey::Model) {
- let (rc, out, err) = Nitrocli::with_model(model).run(&["otp", "set", "100", "name", "1234"]);
+ let (rc, out, err) = Nitrocli::make()
+ .model(model)
+ .build()
+ .run(&["otp", "set", "100", "name", "1234"]);
assert_ne!(rc, 0);
assert_eq!(out, b"");
@@ -32,7 +35,10 @@ fn set_invalid_slot_raw(model: nitrokey::Model) {
#[test_device]
fn set_invalid_slot(model: nitrokey::Model) {
- let res = Nitrocli::with_model(model).handle(&["otp", "set", "100", "name", "1234"]);
+ let res = Nitrocli::make()
+ .model(model)
+ .build()
+ .handle(&["otp", "set", "100", "name", "1234"]);
assert_eq!(
res.unwrap_lib_err(),
@@ -51,7 +57,7 @@ fn status(model: nitrokey::Model) -> crate::Result<()> {
)
.unwrap();
- let mut ncli = Nitrocli::with_model(model);
+ let mut ncli = Nitrocli::make().model(model).build();
// Make sure that we have at least something to display by ensuring
// that there is one slot programmed.
let _ = ncli.handle(&["otp", "set", "0", "the-name", "123456"])?;
@@ -69,7 +75,7 @@ fn set_get_hotp(model: nitrokey::Model) -> crate::Result<()> {
const OTP1: &str = concat!(755224, "\n");
const OTP2: &str = concat!(287082, "\n");
- let mut ncli = Nitrocli::with_model(model);
+ let mut ncli = Nitrocli::make().model(model).build();
let _ = ncli.handle(&[
"otp", "set", "-a", "hotp", "-f", "ascii", "1", "name", &SECRET,
])?;
@@ -90,7 +96,7 @@ fn set_get_totp(model: nitrokey::Model) -> crate::Result<()> {
const TIME: &str = stringify!(1111111111);
const OTP: &str = concat!(14050471, "\n");
- let mut ncli = Nitrocli::with_model(model);
+ let mut ncli = Nitrocli::make().model(model).build();
let _ = ncli.handle(&["otp", "set", "-d", "8", "-f", "ascii", "2", "name", &SECRET])?;
let out = ncli.handle(&["otp", "get", "-t", TIME, "2"])?;
@@ -106,7 +112,7 @@ fn set_totp_uneven_chars(model: nitrokey::Model) -> crate::Result<()> {
];
for (format, secret) in &secrets {
- let mut ncli = Nitrocli::with_model(model);
+ let mut ncli = Nitrocli::make().model(model).build();
let _ = ncli.handle(&["otp", "set", "-f", format.as_ref(), "3", "foobar", &secret])?;
}
Ok(())
@@ -114,7 +120,7 @@ fn set_totp_uneven_chars(model: nitrokey::Model) -> crate::Result<()> {
#[test_device]
fn clear(model: nitrokey::Model) -> crate::Result<()> {
- let mut ncli = Nitrocli::with_model(model);
+ let mut ncli = Nitrocli::make().model(model).build();
let _ = ncli.handle(&["otp", "set", "3", "hotp-test", "abcdef"])?;
let _ = ncli.handle(&["otp", "clear", "3"])?;
let res = ncli.handle(&["otp", "get", "3"]);