diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-03-11 17:18:59 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-03-11 17:18:59 +0100 |
commit | 22d05ce647281056d71fbd3c31df3bcd6396188d (patch) | |
tree | 90208930f54c47987bfd5ffcf0a0acaaad2510da /unittest/test3.cc | |
parent | ed5044da43172d86a1aa475473561a4818b7c69c (diff) | |
parent | ac6b9c18ef55f4cd36e85069cf0cf82c14e04404 (diff) | |
download | libnitrokey-22d05ce647281056d71fbd3c31df3bcd6396188d.tar.gz libnitrokey-22d05ce647281056d71fbd3c31df3bcd6396188d.tar.bz2 |
Merge branch 'libnitrokey_3'
Diffstat (limited to 'unittest/test3.cc')
-rw-r--r-- | unittest/test3.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/unittest/test3.cc b/unittest/test3.cc index 9049365..9e0ef11 100644 --- a/unittest/test3.cc +++ b/unittest/test3.cc @@ -1,8 +1,3 @@ -// -// Created by sz on 08.11.16. -// - -#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() static const char *const default_admin_pin = "12345678"; static const char *const default_user_pin = "123456"; @@ -26,13 +21,16 @@ using namespace nitrokey::proto::stick10_08; using namespace nitrokey::log; using namespace nitrokey::misc; -void connect_and_setup(Stick10 &stick) { - bool connected = stick.connect(); +using Dev = Stick10; +using Dev10 = std::shared_ptr<Dev>; + +void connect_and_setup(Dev10 stick) { + bool connected = stick->connect(); REQUIRE(connected == true); Log::instance().set_loglevel(Loglevel::DEBUG); } -void authorize(Stick10 &stick) { +void authorize(Dev10 stick) { auto authreq = get_payload<FirstAuthenticate>(); strcpy((char *) (authreq.card_password), default_admin_pin); strcpy((char *) (authreq.temporary_password), temporary_password); @@ -45,7 +43,8 @@ void authorize(Stick10 &stick) { } TEST_CASE("write slot", "[pronew]"){ - Stick10 stick; + auto stick = make_shared<Dev>(); + connect_and_setup(stick); authorize(stick); @@ -81,7 +80,7 @@ TEST_CASE("write slot", "[pronew]"){ TEST_CASE("erase slot", "[pronew]"){ - Stick10 stick; + auto stick = make_shared<Dev>(); connect_and_setup(stick); authorize(stick); @@ -107,7 +106,7 @@ TEST_CASE("erase slot", "[pronew]"){ } TEST_CASE("write general config", "[pronew]") { - Stick10 stick; + auto stick = make_shared<Dev>(); connect_and_setup(stick); authorize(stick); @@ -121,7 +120,7 @@ TEST_CASE("write general config", "[pronew]") { } TEST_CASE("authorize user HOTP", "[pronew]") { - Stick10 stick; + auto stick = make_shared<Dev>(); connect_and_setup(stick); authorize(stick); @@ -164,7 +163,7 @@ TEST_CASE("authorize user HOTP", "[pronew]") { } TEST_CASE("check firmware version", "[pronew]") { - Stick10 stick; + auto stick = make_shared<Dev>(); connect_and_setup(stick); auto p = GetStatus::CommandTransaction::run(stick); @@ -172,7 +171,7 @@ TEST_CASE("check firmware version", "[pronew]") { } TEST_CASE("authorize user TOTP", "[pronew]") { - Stick10 stick; + auto stick = make_shared<Dev>(); connect_and_setup(stick); authorize(stick); |