dexter submitted this change.

View Change

Approvals: osmith: Looks good to me, approved Jenkins Builder: Verified
smdpp_Tests: optimize calling of f_init_esXplus

When we call the f_init_esXplus functions we always check the return
code to see if the initialization went ok. However in both functions
we already set the verdict and in the ES2+ variant of the functions
we already stop the MTC. Let's optimize the function calls so that
we only call the function without checking the return code. Let's
do all the error handling and the stopping of the MTC in inside
f_init_esXplus.

Related: SYS#7339
Change-Id: I64fc5a7eddd6c5aee8ce85dbfe56c076f3372f3d
---
M smdpp/smdpp_Tests.ttcn
1 file changed, 79 insertions(+), 156 deletions(-)

diff --git a/smdpp/smdpp_Tests.ttcn b/smdpp/smdpp_Tests.ttcn
index f079ab6..276791d 100644
--- a/smdpp/smdpp_Tests.ttcn
+++ b/smdpp/smdpp_Tests.ttcn
@@ -491,7 +491,7 @@
/* RSP CLIENT WRAPPER FUNCTIONS */

// Initialize RSP client for ES2+
-function f_init_es2plus() runs on smdpp_ConnHdlr return boolean {
+function f_init_es2plus() runs on smdpp_ConnHdlr {
// Initialize RSP client using imported function from smdpp_Tests
g_rsp_client_handle_es2p := smdpp_Tests.ext_RSPClient_create(
mp_es2plus_server_fqdn,
@@ -519,11 +519,10 @@
}

ext_logInfo("HTTP client (ES2+) configured");
- return true;
}

// Initialize RSP client for ES9+
-private function f_init_es9plus() runs on smdpp_ConnHdlr return boolean {
+private function f_init_es9plus() runs on smdpp_ConnHdlr {
ext_logInfo("Initializing RSP client");

g_rsp_client_handle_es9p := ext_RSPClient_create(
@@ -535,19 +534,19 @@

if (g_rsp_client_handle_es9p < 0) {
setverdict(fail, "Failed to initialize RSP client for ES9+");
- return false;
+ mtc.stop;
}

if (ext_RSPClient_loadEUICCCertificate(g_rsp_client_handle_es9p, g_pars_smdpp.euicc_cert_path) != 0) {
ext_logError("Failed to load eUICC certificate for ES9+");
f_rsp_client_cleanup();
- return false;
+ mtc.stop;
}

if (ext_RSPClient_loadEUICCKeyPair(g_rsp_client_handle_es9p, g_pars_smdpp.euicc_key_path) != 0) {
ext_logError("Failed to load eUICC private key for ES9+");
f_rsp_client_cleanup();
- return false;
+ mtc.stop;
}

// Configure HTTP client
@@ -562,11 +561,10 @@
if (result != 0) {
ext_logError("Failed to configure HTTP client");
f_rsp_client_cleanup();
- return false;
+ mtc.stop;
}

ext_logInfo("HTTP client (ES9+) configured");
- return true;
}

private function f_rsp_client_cleanup() runs on smdpp_ConnHdlr {
@@ -1815,10 +1813,8 @@
) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: " & params.testName & " ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -2033,10 +2029,7 @@
ext_logInfo("=== Testing AuthenticateClient Error: " & test_name & " ===");

/* Initialize HTTP/TLS and RSP client */
- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ f_init_es9plus();

/* Step 1: InitiateAuthentication (normal) */
var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();
@@ -2190,11 +2183,8 @@

ext_logInfo("=== Testing GetBoundProfilePackage Error: " & test_name & " ===");

- /* Initialize RSP client */
- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* Step 1: InitiateAuthentication */
var InitiateAuthenticationOkEs9 initAuthOk;
@@ -2327,10 +2317,8 @@
private function f_initiateAuth_generic(charstring id, template (omit) octetstring version := omit, charstring testDescription, charstring successMessage, boolean checkPkid := false) runs on smdpp_ConnHdlr {
ext_logInfo(testDescription);

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var RemoteProfileProvisioningRequest authRequest := f_create_initiate_authentication_request();

@@ -2392,10 +2380,8 @@
private function f_TC_InitiateAuth_02_Uniqueness(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: InitiateAuthentication - Uniqueness of Transaction ID and Server Challenge ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* Step 1: First InitiateAuthentication request */
var RemoteProfileProvisioningRequest authRequest1 := f_create_initiate_authentication_request();
@@ -2410,11 +2396,7 @@

/* Step 2: Re-initialize TLS connection (simulated by re-init) */
f_rsp_client_cleanup();
-
- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client re-initialization failed");
- return;
- }
+ f_init_es9plus();

/* Step 3: Second InitiateAuthentication request */
var RemoteProfileProvisioningRequest authRequest2 := f_create_initiate_authentication_request();
@@ -2455,10 +2437,8 @@
private function f_TC_InitiateAuth_03_InvalidServerAddress(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: InitiateAuthentication - Invalid Server Address Error ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* Create request with invalid server address */
var RemoteProfileProvisioningRequest authRequest := f_create_initiate_authentication_request();
@@ -2523,10 +2503,8 @@
) runs on smdpp_ConnHdlr {
ext_logInfo(params.testName);

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* retry scenarios */
var octetstring saved_euicc_otpk;
@@ -2750,10 +2728,8 @@
) runs on smdpp_ConnHdlr {
ext_logInfo(testName);

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus()

if (requireCC) {
g_pars_smdpp.cc_required := true;
@@ -2885,10 +2861,8 @@

ext_logInfo("=== Testing AuthenticateClient Retry After Cancelled Session ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* Step 1: First session - will be cancelled */
ext_logInfo("Step 1: Starting first session (to be cancelled)");
@@ -2967,7 +2941,6 @@
}

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();
-
var RemoteProfileProvisioningRequest authClientReq := f_create_authenticate_client_request(matchingId);
var RemoteProfileProvisioningResponse authClientResp := f_es9p_transceive_success(authClientReq);
var AuthenticateClientOk authClientOk := authClientResp.authenticateClientResponseEs9.authenticateClientOk;
@@ -3035,10 +3008,8 @@
) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: GetBoundProfilePackage Retry - " & test_description & " ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

ext_logInfo("Step 1: Initial session and cancellation");
var octetstring initial_smdp_otpk := f_perform_initial_session_and_cancel();
@@ -3218,10 +3189,8 @@
private function f_TC_GetBoundProfilePackage_Retry_09_ConfirmationCode(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: GetBoundProfilePackage - Confirmation Code Retry ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();
var RemoteProfileProvisioningRequest authClientReq := f_create_authenticate_client_request("CC_REQUIRED_TEST");
@@ -3315,10 +3284,9 @@
integer reason,
charstring reason_name
) runs on smdpp_ConnHdlr {
- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus()

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();

@@ -3397,10 +3365,9 @@
charstring id,
CancelSessionReason reason
) runs on smdpp_ConnHdlr {
- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus()

ext_logInfo("=== Steps 1-3: InitiateAuth, AuthenticateClient, GetBoundProfilePackage ===");
var GetBoundProfilePackageOk packageOk := f_perform_session_through_getBoundProfilePackage();
@@ -3506,10 +3473,9 @@
CancelSessionErrorInjection err_injection,
charstring test_description
) runs on smdpp_ConnHdlr {
- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus()

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();

@@ -3591,10 +3557,9 @@
CancelSessionErrorInjection err_injection,
charstring test_description
) runs on smdpp_ConnHdlr {
- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus()

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();

@@ -3774,10 +3739,8 @@

ext_logInfo("Starting complete RSP flow test");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus()

ext_logInfo("=== Step 1: InitiateAuthentication ===");

@@ -4042,10 +4005,8 @@
) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: HandleNotification - " & test_description & " ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();

@@ -4174,10 +4135,8 @@
private function f_TC_HandleNotification_02_OtherSignedNotification(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: HandleNotification - OtherSignedNotification ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var NotificationMetadata notifMeta := {
seqNumber := 2, /* Different sequence number from PIR */
@@ -4215,10 +4174,8 @@
) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: GetBoundProfilePackage - " & test_description & " ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();
var RemoteProfileProvisioningRequest authClientReq := f_create_authenticate_client_request();
@@ -4324,10 +4281,8 @@
private function f_TC_GetBoundProfilePackage_05_Metadata_Split(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: GetBoundProfilePackage - S-ENC/S-MAC with Metadata Split ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* Perform standard flow up to GetBoundProfilePackage */
var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();
@@ -4363,10 +4318,8 @@
private function f_TC_InitiateAuth_04_UnsupportedPKID(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: InitiateAuthentication - Unsupported Public Key Identifiers Error ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var RemoteProfileProvisioningRequest authRequest := f_create_initiate_authentication_request();
/* unsupported PKIDs that server won't recognize */
@@ -4385,10 +4338,8 @@
private function f_TC_InitiateAuth_05_UnsupportedVersion(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: InitiateAuthentication - Unsupported Specification Version Error ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* version too low */
ext_logInfo("Testing with SGP.22 version too low (v1.0.0)");
@@ -4415,10 +4366,8 @@
private function f_TC_InitiateAuth_06_UnavailableServerAuthCert(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: InitiateAuthentication - Unavailable Server Auth Certificate Error ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var RemoteProfileProvisioningRequest authRequest := f_create_initiate_authentication_request();
/* we need to:
@@ -4590,10 +4539,8 @@
private function f_TC_AuthenticateClient_19_Extended_UICC_Capability(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Extended UICC Capability ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4623,10 +4570,8 @@
private function f_TC_AuthenticateClient_20_Extended_DeviceInfo(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Extended DeviceInfo ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4678,10 +4623,8 @@
private function f_TC_AuthenticateClient_21_Extended_eUICCInfo2(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Extended eUICCInfo2 ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4726,10 +4669,8 @@
private function f_TC_AuthenticateClient_Error_01_InvalidEUMCert(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Error: Invalid EUM Certificate ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4752,10 +4693,8 @@
private function f_TC_AuthenticateClient_Error_02_ExpiredEUMCert(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Error: Expired EUM Certificate ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4778,10 +4717,8 @@
private function f_TC_AuthenticateClient_Error_03_InvalidEUICCCert(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Error: Invalid eUICC Certificate ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4804,10 +4741,8 @@
private function f_TC_AuthenticateClient_Error_04_ExpiredEUICCCert(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Error: Expired eUICC Certificate ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4830,10 +4765,8 @@
private function f_TC_AuthenticateClient_Error_07_UnknownCIKey(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Error: Unknown CI Public Key ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var octetstring serverChallenge := f_performInitiateAuthentication();

@@ -4913,10 +4846,8 @@
* The profile has PPR1 set (disabling not allowed) but the eUICC reports PPR1 as forbidden
* because an operational profile is already installed */

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

var InitiateAuthenticationOkEs9 authOk := f_initiate_authentication_and_validate();

@@ -5034,10 +4965,8 @@
private function f_TC_AuthenticateClient_03_SecondAttempt_AfterInvalidMatchingID(charstring id) runs on smdpp_ConnHdlr {
ext_logInfo("=== Test Case: AuthenticateClient - Second Attempt After Invalid MatchingID ===");

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();

/* Step IC1: PROC_ES9+_AUTH_CLIENT_FAIL_DEF_DP_USE_CASE_INVALID_MATCHING_ID */
ext_logInfo("Step IC1: First attempt with activation code matching ID (should fail)");
@@ -5726,15 +5655,9 @@
const charstring c_cert_path := "./test_certs/CERT_MNO_ECDSA_NIST.pem";
const charstring c_key_path := "./test_certs/SK_MNO_ECDSA_NIST.pem";

- if (not f_init_es9plus()) {
- setverdict(fail, "RSP client initialization failed");
- return;
- }
-
- if (not f_init_es2plus()) {
- setverdict(fail, "RSP client initialization for ES2+ failed");
- return;
- }
+ /* Initialize HTTP/TLS and RSP client */
+ f_init_es9plus();
+ f_init_es2plus();

// Step 1: Order profile via ES2+


To view, visit change 41285. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I64fc5a7eddd6c5aee8ce85dbfe56c076f3372f3d
Gerrit-Change-Number: 41285
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier@sysmocom.de>
Gerrit-Reviewer: Hoernchen <ewild@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier@sysmocom.de>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>