aboutsummaryrefslogtreecommitdiff
path: root/unittest/test_issues.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-06-27 12:32:56 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2017-06-27 12:34:46 +0200
commit8f7435e4553916e6cc431e4b5316cc5861fd9063 (patch)
tree080345d319b20f8ef28d1bacc5a6e20cd34bf4ed /unittest/test_issues.cc
parent06c0deb7935a9390a67bc02d6c323e64c785a026 (diff)
downloadlibnitrokey-8f7435e4553916e6cc431e4b5316cc5861fd9063.tar.gz
libnitrokey-8f7435e4553916e6cc431e4b5316cc5861fd9063.tar.bz2
Add C++ tests for some current issues
Issues: https://github.com/Nitrokey/nitrokey-storage-firmware/issues/36 https://github.com/Nitrokey/nitrokey-storage-firmware/issues/31 Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test_issues.cc')
-rw-r--r--unittest/test_issues.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/unittest/test_issues.cc b/unittest/test_issues.cc
new file mode 100644
index 0000000..ec3f933
--- /dev/null
+++ b/unittest/test_issues.cc
@@ -0,0 +1,78 @@
+
+const char * const default_admin_pin = "12345678";
+const char * const default_user_pin = "123456";
+const char * const temporary_password = "123456789012345678901234";
+const char * const RFC_SECRET = "12345678901234567890";
+const char * const hidden_volume_pass = "123456789012345";
+
+#include "catch.hpp"
+
+#include <NitrokeyManager.h>
+
+using namespace std;
+using namespace nitrokey;
+
+
+bool test_36(){
+ auto i = NitrokeyManager::instance();
+ i->set_debug(true);
+ REQUIRE(i->connect());
+
+ for (int j = 0; j < 200; ++j) {
+ i->get_status();
+ i->get_status_storage_as_string();
+ INFO( "Iteration: " << j);
+ }
+ return true;
+}
+
+bool test_31(){
+ auto i = NitrokeyManager::instance();
+ i->set_debug(true);
+ REQUIRE(i->connect());
+
+// i->unlock_encrypted_volume(default_user_pin);
+// i->create_hidden_volume(0, 70, 80, hidden_volume_pass);
+// i->lock_device();
+
+ try{
+ i->get_password_safe_slot_status();
+ }
+ catch (...){
+ //pass
+ }
+
+ i->get_status_storage();
+ i->get_admin_retry_count();
+ i->get_status_storage();
+ i->get_user_retry_count();
+ i->unlock_encrypted_volume(default_user_pin);
+ i->get_status_storage();
+ i->get_password_safe_slot_status();
+ i->get_status_storage();
+ i->get_user_retry_count();
+ i->get_password_safe_slot_status();
+ i->get_status();
+ i->get_status_storage();
+ i->get_admin_retry_count();
+ i->get_status();
+ i->get_user_retry_count();
+ i->unlock_hidden_volume(hidden_volume_pass);
+ i->get_status_storage();
+ i->get_password_safe_slot_status();
+
+
+ return true;
+}
+
+TEST_CASE("issue 31", "[issue]"){
+ for(int i=0; i<20; i++){
+ REQUIRE(test_31());
+ }
+}
+
+
+
+TEST_CASE("issue 36", "[issue]"){
+ REQUIRE(test_36());
+}