summaryrefslogtreecommitdiff
path: root/unittest/test2.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-10-24 15:50:15 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-11-26 18:56:23 +0100
commit003189e780af8208f243bbd312df5f5295015eb1 (patch)
tree09b7e8bcb1f422a4b0c3ed4b828bb377e8ddc33a /unittest/test2.cc
parent116523fbee311aa7af5151d1a601c8a0f11965e9 (diff)
downloadlibnitrokey-003189e780af8208f243bbd312df5f5295015eb1.tar.gz
libnitrokey-003189e780af8208f243bbd312df5f5295015eb1.tar.bz2
Test: check more commands
Add delay after each command by default. Check EnableHiddenEncryptedPartition more than once. Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test2.cc')
-rw-r--r--unittest/test2.cc36
1 files changed, 32 insertions, 4 deletions
diff --git a/unittest/test2.cc b/unittest/test2.cc
index 503ab49..61fb502 100644
--- a/unittest/test2.cc
+++ b/unittest/test2.cc
@@ -18,11 +18,16 @@ using namespace nitrokey::misc;
template<typename CMDTYPE>
-void execute_password_command(Device &stick, const char *password) {
+void execute_password_command(Device &stick, const char *password, const char kind = 'P') {
auto p = get_payload<CMDTYPE>();
- p.set_kind_user();
+ if (kind == 'P'){
+ p.set_kind_user();
+ } else {
+ p.set_kind_admin();
+ }
strcpyT(p.password, password);
CMDTYPE::CommandTransaction::run(stick, p);
+ this_thread::sleep_for(1000ms);
}
@@ -36,10 +41,33 @@ TEST_CASE("test", "[test]") {
stick10::LockDevice::CommandTransaction::run(stick);
// execute_password_command<EnableEncryptedPartition>(stick, "123456");
// execute_password_command<DisableEncryptedPartition>(stick, "123456");
- execute_password_command<EnableEncryptedPartition>(stick, "123456");
this_thread::sleep_for(1000ms);
- execute_password_command<EnableHiddenEncryptedPartition>(stick, "123123123");
+ execute_password_command<EnableEncryptedPartition>(stick, "123456");
+ this_thread::sleep_for(4000ms);
+ bool passed = false;
+ for(int i=0; i<5; i++){
+ try {
+ execute_password_command<EnableHiddenEncryptedPartition>(stick, "123123123");
+ CHECK(true);
+ passed=true;
+ break;
+ }
+ catch (CommandFailedException &e){
+ this_thread::sleep_for(2000ms);
+ }
+ }
+ if(!passed){
+ CHECK(false);
+ }
+
+ execute_password_command<DisableHiddenEncryptedPartition>(stick, "123123123");
+ execute_password_command<SendSetReadonlyToUncryptedVolume>(stick, "123456");
+ execute_password_command<SendSetReadwriteToUncryptedVolume>(stick, "123456");
+ execute_password_command<SendClearNewSdCardFound>(stick, "12345678", 'A');
this_thread::sleep_for(1000ms);
+// execute_password_command<LockFirmware>(stick, "123123123");
+// execute_password_command<EnableFirmwareUpdate>(stick, "123123123"); //FIRMWARE PIN
+
stick10::LockDevice::CommandTransaction::run(stick);
stick.disconnect();