aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-06-20 10:15:26 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2018-06-20 10:15:26 +0200
commita71507ba0ca4643201c4ceb3d4dfc0f6dd5ae770 (patch)
tree75d5fff6d41808b7d81f80508e0c687cc4f701a1
parent8ea740f3cc872b2585a4ecf97a29127aa9316137 (diff)
downloadlibnitrokey-a71507ba0ca4643201c4ceb3d4dfc0f6dd5ae770.tar.gz
libnitrokey-a71507ba0ca4643201c4ceb3d4dfc0f6dd5ae770.tar.bz2
Add extended test for the connect() return value in offline mode
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--unittest/test_offline.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/unittest/test_offline.cc b/unittest/test_offline.cc
index 468849e..e34eeb4 100644
--- a/unittest/test_offline.cc
+++ b/unittest/test_offline.cc
@@ -160,3 +160,29 @@ TEST_CASE("Test device commands ids", "[fast]") {
REQUIRE(STICK20_CMD_CHANGE_UPDATE_PIN == static_cast<uint8_t>(CommandID::CHANGE_UPDATE_PIN));
}
+
+
+TEST_CASE("Connect should not return true after the second attempt", "[fast]") {
+ int result = 0;
+
+ result = NK_login("S");
+ REQUIRE(result == 0);
+
+ result = NK_login_auto();
+ REQUIRE(result == 0);
+
+ result = NK_logout();
+ REQUIRE(result == 0);
+
+ result = NK_logout();
+ REQUIRE(result == 0);
+
+ result = NK_login("P");
+ REQUIRE(result == 0);
+
+ result = NK_login_auto();
+ REQUIRE(result == 0);
+
+ result = NK_logout();
+ REQUIRE(result == 0);
+}