From 6af0fa2c553ca1a31da63b7164b53defe11172df Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 28 Oct 2016 19:07:51 +0200 Subject: Tests refactoring - replace magic values with constants Signed-off-by: Szczepan Zalega --- unittest/test2.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/unittest/test2.cc b/unittest/test2.cc index 9aaef3f..94a0dd3 100644 --- a/unittest/test2.cc +++ b/unittest/test2.cc @@ -1,4 +1,8 @@ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() +static const char *const default_admin_pin = "12345678"; + +static const char *const default_user_pin = "123456"; + #include "catch.hpp" #include @@ -37,10 +41,9 @@ TEST_CASE("long operation test", "[test_long]") { REQUIRE(connected == true); Log::instance().set_loglevel(Loglevel::DEBUG_L2); try{ -// execute_password_command(stick, "12345678", 'P'); auto p = get_payload(); p.set_defaults(); - strcpyT(p.admin_pin, "12345678"); + strcpyT(p.admin_pin, default_admin_pin); FillSDCardWithRandomChars::CommandTransaction::run(stick, p); this_thread::sleep_for(1000ms); @@ -140,7 +143,8 @@ TEST_CASE("setup hidden volume test", "[hidden]") { stick10::LockDevice::CommandTransaction::run(stick); this_thread::sleep_for(2000ms); - execute_password_command(stick, "123456"); + auto user_pin = default_user_pin; + execute_password_command(stick, user_pin); auto p = get_payload(); p.SlotNr_u8 = 0; @@ -160,7 +164,7 @@ TEST_CASE("setup multiple hidden volumes", "[hidden2]") { REQUIRE(connected == true); Log::instance().set_loglevel(Loglevel::DEBUG_L2); - auto user_pin = "123456"; + auto user_pin = default_user_pin; stick10::LockDevice::CommandTransaction::run(stick); this_thread::sleep_for(2000ms); execute_password_command(stick, user_pin); @@ -194,7 +198,7 @@ TEST_CASE("update password change", "[dangerous]") { REQUIRE(connected == true); Log::instance().set_loglevel(Loglevel::DEBUG_L2); - auto pass1 = "12345678"; + auto pass1 = default_admin_pin; auto pass2 = "12345678901234567890"; auto data = { @@ -220,7 +224,7 @@ TEST_CASE("update password change", "[dangerous]") { // execute_password_command(stick, "123456"); // execute_password_command(stick, "123456"); this_thread::sleep_for(1000ms); - execute_password_command(stick, "123456"); + execute_password_command(stick, default_user_pin); this_thread::sleep_for(4000ms); bool passed = false; for(int i=0; i<5; i++){ @@ -239,9 +243,11 @@ TEST_CASE("update password change", "[dangerous]") { } execute_password_command(stick, "123123123"); - execute_password_command(stick, "123456"); - execute_password_command(stick, "123456"); - execute_password_command(stick, "12345678", 'A'); + + + execute_password_command(stick, default_user_pin); + execute_password_command(stick, default_user_pin); + execute_password_command(stick, default_admin_pin, 'A'); stick20::GetDeviceStatus::CommandTransaction::run(stick); this_thread::sleep_for(1000ms); // execute_password_command(stick, "123123123"); //CAUTION -- cgit v1.2.3