aboutsummaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan.zalega@gmail.com>2016-03-06 19:00:10 +0100
committerSzczepan Zalega <szczepan.zalega@gmail.com>2016-03-06 19:00:10 +0100
commit85506009d3323e977b6de63b9b9c31760a2200fc (patch)
tree64a1670a39d1915e6ba3dbae117d467464289635 /unittest
parentb4c40a129f374e8be347346bfca6dd064290586a (diff)
downloadlibnitrokey-85506009d3323e977b6de63b9b9c31760a2200fc.tar.gz
libnitrokey-85506009d3323e977b6de63b9b9c31760a2200fc.tar.bz2
Enabling Password Safe in unittest
Diffstat (limited to 'unittest')
-rw-r--r--unittest/test.cc47
1 files changed, 27 insertions, 20 deletions
diff --git a/unittest/test.cc b/unittest/test.cc
index 2004d1e..02f742c 100644
--- a/unittest/test.cc
+++ b/unittest/test.cc
@@ -25,7 +25,7 @@ TEST_CASE("Slot names are correct", "[slotNames]") {
bool connected = stick.connect();
REQUIRE(connected == true);
- // Log::instance().set_loglevel(Loglevel::DEBUG_L2);
+ Log::instance().set_loglevel(Loglevel::DEBUG);
auto resp = GetStatus::CommandTransaction::run(stick);
@@ -33,40 +33,47 @@ TEST_CASE("Slot names are correct", "[slotNames]") {
strcpy((char *)(authreq.card_password), "12345678");
FirstAuthenticate::CommandTransaction::run(stick, authreq);
+ {
+ EnablePasswordSafe::CommandTransaction::CommandPayload authreq;
+ strcpy((char *)(authreq.password), "123456");
+ EnablePasswordSafe::CommandTransaction::run(stick, authreq);
+ }
+
REQUIRE(getSlotName(stick, 0x20) == std::string("1"));
REQUIRE(getSlotName(stick, 0x21) == std::string("slot2"));
{
- auto resp = GetPasswordRetryCount::CommandTransaction::run(stick);
- REQUIRE( resp.password_retry_count == 3 );
+ auto resp = GetPasswordRetryCount::CommandTransaction::run(stick);
+ REQUIRE(resp.password_retry_count == 3);
}
{
- auto resp = GetUserPasswordRetryCount::CommandTransaction::run(stick);
- REQUIRE( resp.password_retry_count == 3 );
+ auto resp = GetUserPasswordRetryCount::CommandTransaction::run(stick);
+ REQUIRE(resp.password_retry_count == 3);
}
{
- GetPasswordSafeSlotName::CommandTransaction::CommandPayload slot;
- slot.slot_number = 0;
- auto resp2 = GetPasswordSafeSlotName::CommandTransaction::run(stick, slot);
- std::string sName(reinterpret_cast<char *>(resp2.slot_name));
- REQUIRE(sName == std::string("web1"));
+ GetPasswordSafeSlotName::CommandTransaction::CommandPayload slot;
+ slot.slot_number = 0;
+ auto resp2 = GetPasswordSafeSlotName::CommandTransaction::run(stick, slot);
+ std::string sName(reinterpret_cast<char *>(resp2.slot_name));
+ REQUIRE(sName == std::string("web1"));
}
{
- GetPasswordSafeSlotPassword::CommandTransaction::CommandPayload slot;
- slot.slot_number = 0;
- auto resp2 = GetPasswordSafeSlotPassword::CommandTransaction::run(stick, slot);
- std::string sName(reinterpret_cast<char *>(resp2.slot_password));
- REQUIRE(sName == std::string("pass1"));
+ GetPasswordSafeSlotPassword::CommandTransaction::CommandPayload slot;
+ slot.slot_number = 0;
+ auto resp2 =
+ GetPasswordSafeSlotPassword::CommandTransaction::run(stick, slot);
+ std::string sName(reinterpret_cast<char *>(resp2.slot_password));
+ REQUIRE(sName == std::string("pass1"));
}
{
- GetPasswordSafeSlotLogin::CommandTransaction::CommandPayload slot;
- slot.slot_number = 0;
- auto resp2 = GetPasswordSafeSlotLogin::CommandTransaction::run(stick, slot);
- std::string sName(reinterpret_cast<char *>(resp2.slot_login));
- REQUIRE(sName == std::string("login1"));
+ GetPasswordSafeSlotLogin::CommandTransaction::CommandPayload slot;
+ slot.slot_number = 0;
+ auto resp2 = GetPasswordSafeSlotLogin::CommandTransaction::run(stick, slot);
+ std::string sName(reinterpret_cast<char *>(resp2.slot_login));
+ REQUIRE(sName == std::string("login1"));
}
stick.disconnect();