From d92707ca48137b47800006a09539470acb4e4d69 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sat, 5 Mar 2016 17:10:14 +0100 Subject: adding basic tests --- include/stick10_commands.h | 32 ++++++++++++++++++++++++++++++++ unittest/test.cc | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/include/stick10_commands.h b/include/stick10_commands.h index b140e99..ab1a5bb 100644 --- a/include/stick10_commands.h +++ b/include/stick10_commands.h @@ -196,6 +196,10 @@ class GetPasswordRetryCount : Command { uint8_t password_retry_count; bool isValid() const { return true; } + std::string dissect() const { + std::stringstream ss; + ss << " password_retry_count\t" << password_retry_count<< std::endl; + return ss.str(); } } __packed; typedef Transaction @@ -209,6 +213,10 @@ class GetUserPasswordRetryCount uint8_t password_retry_count; bool isValid() const { return true; } + std::string dissect() const { + std::stringstream ss; + ss << " password_retry_count\t" << password_retry_count<< std::endl; + return ss.str(); } } __packed; typedef Transaction @@ -233,12 +241,20 @@ class GetPasswordSafeSlotName : Command { uint8_t slot_number; bool isValid() const { return !(slot_number & 0xF0); } + std::string dissect() const { + std::stringstream ss; + ss << "slot_number\t" << slot_number << std::endl; + return ss.str(); } } __packed; struct ResponsePayload { uint8_t slot_name[PWS_SLOTNAME_LENGTH]; bool isValid() const { return true; } + std::string dissect() const { + std::stringstream ss; + ss << " slot_name\t" << slot_name << std::endl; + return ss.str(); } } __packed; typedef Transaction(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(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(resp2.slot_login)); + REQUIRE(sName == std::string("login1")); + } + stick.disconnect(); } -- cgit v1.2.3