Skip to content

Commit

Permalink
further offline authorization checks in unit cases
Browse files Browse the repository at this point in the history
  • Loading branch information
matth-x committed Aug 15, 2024
1 parent a24cdbb commit 032672b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
15 changes: 8 additions & 7 deletions tests/Boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ TEST_CASE( "Boot Behavior" ) {

REQUIRE( isOperative() ); //normal BN succeeded

loopback.setOnline( false );
loopback.setConnected( false );

beginTransaction_authorized("mIdTag");

Expand All @@ -106,7 +106,7 @@ TEST_CASE( "Boot Behavior" ) {

mocpp_deinitialize();

loopback.setOnline( true );
loopback.setConnected( true );

MO_DBG_INFO("Start charger again with queued transaction messages, also init non-tx-related msg, but now delay BN procedure");

Expand Down Expand Up @@ -239,11 +239,11 @@ TEST_CASE( "Boot Behavior" ) {

//start one transaction in full offline mode

loopback.setOnline( false );
loopback.setConnected( false );
loop();
REQUIRE( getChargePointStatus() == ChargePointStatus_Available );

beginTransaction_authorized("mIdTag");
beginTransaction("mIdTag");
loop();
REQUIRE( getChargePointStatus() == ChargePointStatus_Charging );

Expand All @@ -269,15 +269,16 @@ TEST_CASE( "Boot Behavior" ) {
});
});

loopback.setOnline( true );
loopback.setConnected( true );
loop();
REQUIRE( startTxCount == 0 );

beginTransaction_authorized("mIdTag");
beginTransaction("mIdTag2");
mtime += 20 * 1000;
loop();
REQUIRE( getChargePointStatus() == ChargePointStatus_Charging );

endTransaction("mIdTag");
endTransaction();
loop();
REQUIRE( getChargePointStatus() == ChargePointStatus_Available );

Expand Down
11 changes: 6 additions & 5 deletions tests/ChargingSessions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,16 @@ TEST_CASE( "Charging sessions" ) {
const char *tx3_idTag = "Tx#3";
const char *tx4_idTag = "Tx#4";

declareConfiguration<bool>(MO_CONFIG_EXT_PREFIX "PreBootTransactions", true, CONFIGURATION_FN)->setBool(true);
declareConfiguration<bool>(MO_CONFIG_EXT_PREFIX "PreBootTransactions", true)->setBool(true);
declareConfiguration<bool>("AllowOfflineTxForUnknownId", true)->setBool(true);
configuration_save();
loop();

// start Tx #1 (offline tx)
loopback.setConnected(false);

MO_DBG_DEBUG("begin tx (%s)", tx1_idTag);
beginTransaction_authorized(tx1_idTag);
beginTransaction(tx1_idTag);
loop();
REQUIRE(isTransactionRunning());
endTransaction();
Expand All @@ -543,7 +544,7 @@ TEST_CASE( "Charging sessions" ) {
// start Tx #2 (PreBoot tx, won't get timestamp)

MO_DBG_DEBUG("begin tx (%s)", tx2_idTag);
beginTransaction_authorized(tx2_idTag);
beginTransaction(tx2_idTag);
loop();
REQUIRE(isTransactionRunning());
endTransaction();
Expand All @@ -558,7 +559,7 @@ TEST_CASE( "Charging sessions" ) {
// start Tx #3 (PreBoot tx, will eventually get timestamp)

MO_DBG_DEBUG("begin tx (%s)", tx3_idTag);
beginTransaction_authorized(tx3_idTag);
beginTransaction(tx3_idTag);
loop();
REQUIRE(isTransactionRunning());
endTransaction();
Expand Down Expand Up @@ -604,7 +605,7 @@ TEST_CASE( "Charging sessions" ) {

// start Tx #4
MO_DBG_DEBUG("begin tx (%s)", tx4_idTag);
beginTransaction_authorized(tx4_idTag);
beginTransaction(tx4_idTag);
loop();
REQUIRE(isTransactionRunning());
endTransaction();
Expand Down

0 comments on commit 032672b

Please sign in to comment.