dexter submitted this change.
eIM_Tests: allow an expected JSON error in f_esipa_receive
When receiving from the ESipa interface using the ASN.1 binding,
then errors are communicated using the normal ASN.1 structs. When
using the JSON bindings, we have a completely different error
handling mechanism. The error codes are not communicated via fields
in the body of the message. Instead there is an error code sent
within the JSON header of the message, which follows an entirely
different scheme. In order to be able to test JSON and ASN.1
bindings, we must be able to pass an expected JSON error message,
when testing error situations. Depending on which binding is used,
we either pick the ASN.1 message (esipa_res) or the JSON error
message (expected_Json_err).
Change-Id: Ib5df2e63843186f61a0849ed81ddf35453270588
Related: SYS#8203
---
M eim/eIM_Tests.ttcn
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/eim/eIM_Tests.ttcn b/eim/eIM_Tests.ttcn
index e2ed6ef..1ad6efa 100644
--- a/eim/eIM_Tests.ttcn
+++ b/eim/eIM_Tests.ttcn
@@ -45,6 +45,7 @@
import from PIPEasp_Types all;
import from SGP23_Constants all;
+import from esx_header_Types_JSON all;
type component MTC_CT {
timer g_Tguard;
@@ -420,7 +421,8 @@
}
/* Receive ESipa HTTP response */
-private function f_esipa_receive(template EsipaMessageFromEimToIpa expected_esipa_res := omit)
+private function f_esipa_receive(template EsipaMessageFromEimToIpa expected_esipa_res := omit,
+ template JSON_ESx_FunctionExecutionStatusCodeData expected_json_err := omit)
runs on eIM_ConnHdlr return template EsipaMessageFromEimToIpa {
var template EsipaMessageFromEimToIpa esipa_res;
var DecodedEimToIpaMessage_Wrap esipa_res_wrap; /* JSON */
@@ -455,13 +457,39 @@
} else if (ispresent(response_http.response)) {
if (mp_esipa_json == true) {
dec_EsipaMessageFromEimToIpa_from_JSON(response_http.response.body, esipa_res_wrap);
- esipa_res := esipa_res_wrap.asn1_pdu;
- if (not istemplatekind(expected_esipa_res, "omit")) {
- if (not match(valueof(esipa_res), expected_esipa_res)) {
- setverdict(fail, "unexpected response (JSON) from eIM on ESipa");
+ if (isbound(esipa_res_wrap.asn1_pdu)) {
+ esipa_res := esipa_res_wrap.asn1_pdu;
+
+ if (not istemplatekind(expected_esipa_res, "omit")) {
+ /* The JSON message definition of the ProvideEimPackageResultResponse contains
+ * only one optional field (eimAcknowledgements). When this field is missing,
+ * the ProvideEimPackageResultResponse becomes indistinguishable from an empty
+ * response and is decoded as such. In case an expected_esipa_res is given, we
+ * can check if a ProvideEimPackageResultResponse is expected. When this is the
+ * case and the decoded response (esipa_res) was empty, we may infer the
+ * appropriate ProvideEimPackageResultResponse. */
+ if (ispresent(expected_esipa_res.provideEimPackageResultResponse) and istemplatekind(esipa_res, "omit")) {
+ esipa_res := { provideEimPackageResultResponse := { emptyResponse := { } } }
+ }
+ if (not match(valueof(esipa_res), expected_esipa_res)) {
+ setverdict(fail, "unexpected response (JSON) from eIM on ESipa");
+ log(valueof(esipa_res));
+ }
}
+ return esipa_res;
+ } else if (isbound(esipa_res_wrap.err)) {
+ if (not istemplatekind(expected_json_err, "omit")) {
+ if (not match(valueof(esipa_res_wrap.err), expected_json_err)) {
+ setverdict(fail, "unexpected error response (JSON) from eIM on ESipa");
+ }
+ }
+ return omit;
+ } else {
+ /* The decoder should always either return an error result or a decoded asn1_pdu, but the
+ * result should never be completely empty. */
+ setverdict(fail, "unexpected empty decoding result while decoding received response (JSON) from eIM on ESipa");
+ return omit;
}
- return esipa_res;
} else {
setverdict(fail, "unexpected response from eIM on ESipa (response is ASN.1 instead of JSON?)");
return omit;
To view, visit change 43927. To unsubscribe, or for help writing mail filters, visit settings.