dexter has uploaded this change for review.
esipa_json_handler: return subjectCode and reasonCode on error
When an ESipa request runs into an error, the JSON API only returns
a status ("Failed") but no statusCodeData field is returned. This
is technically acceptable since the statusCodeData field is an
optional field.
However, it is common sense that an error response should include
a statusCodeData field. So let's at least put a statusCodeData
fields with a generic subjectCode and reasonCode field into the
response. Let's also add TODO comments and placeholders into the
code, so that we can pick this up later to add more specific
error codes.
(For our concrete implementation the JSON API bindings have no
relevance since onomondo-ipa uses the ASN.1 API bindings. This
patch is currently only relevant for the TTCN3 testsuite, which
requires the presence of the statusCodeData field)
Change-Id: I2d836f7f8d8ced10ba0e9880268079a27c804b04
Related: SYS#8203
---
M src/esipa_json_handler.erl
1 file changed, 149 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-eim refs/changes/19/43819/1
diff --git a/src/esipa_json_handler.erl b/src/esipa_json_handler.erl
index aad3929..4311776 100644
--- a/src/esipa_json_handler.erl
+++ b/src/esipa_json_handler.erl
@@ -123,8 +123,31 @@
maps:get(ctxParams1, InitiateAuthenticationOkEsipa, absent)
)}
]);
+ {initiateAuthenticationResponseEsipa,
+ {initiateAuthenticationErrorEsipa, _InitiateAuthenticationErrorEsipa}} ->
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ]);
_ ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}])
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ])
end;
%GSMA SGP.32, section 6.4.1.2
handle_json({<<"/gsma/rsp2/esipa/authenticateClient">>, EsipaReq}) ->
@@ -178,8 +201,44 @@
maps:get(hashCc, AuthenticateClientOkDPEsipa, absent)
)}
]);
+ {authenticateClientResponseEsipa,
+ {authenticateClientOkDSEsipa, _AuthenticateClientOkDSEsipa}} ->
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ]);
+ {authenticateClientResponseEsipa,
+ {authenticateClientErrorEsipa, _AuthenticateClientErrorEsipa}} ->
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ]);
_ ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}])
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ])
end;
%GSMA SGP.32, section 6.4.1.3
handle_json({<<"/gsma/rsp2/esipa/getBoundProfilePackage">>, EsipaReq}) ->
@@ -214,9 +273,29 @@
]);
{getBoundProfilePackageResponseEsipa,
{getBoundProfilePackageErrorEsipa, _GetBoundProfilePackageErrorEsipa}} ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}]);
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ]);
_ ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}])
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ])
end;
%GSMA SGP.32, section 6.4.1.5
handle_json({<<"/gsma/rsp2/esipa/getEimPackage">>, EsipaReq}) ->
@@ -315,7 +394,17 @@
{eimPackageError, EimPackageErrorInt}
]);
_ ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}])
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ])
end;
%GSMA SGP.32, section 6.4.1.6
handle_json({<<"/gsma/rsp2/esipa/provideEimPackageResult">>, EsipaReq}) ->
@@ -349,9 +438,29 @@
]);
{provideEimPackageResultError,
{provideEimPackageResultError, _ProvideEimPackageResultError}} ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}]);
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ]);
_ ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}])
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ])
end;
%GSMA SGP.32, section 6.4.1.7
handle_json({<<"/gsma/rsp2/esipa/handleNotification">>, EsipaReq}) ->
@@ -381,7 +490,17 @@
}}
]);
_ ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}])
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ])
end;
%GSMA SGP.32, section 6.4.1.8
handle_json({<<"/gsma/rsp2/esipa/cancelSession">>, EsipaReq}) ->
@@ -406,9 +525,29 @@
}}
]);
{cancelSessionResponseEsipa, {cancelSessionError, _CancelSessionError}} ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}]);
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ]);
_ ->
- join([{header, #{<<"functionExecutionStatus">> => #{<<"status">> => <<"Failed">>}}}])
+ %TODO: Return more specific subjectCode and reasonCode
+ join([
+ {header, #{
+ functionExecutionStatus =>
+ #{
+ status => <<"Failed">>,
+ statusCodeData =>
+ #{subjectCode => <<"1">>, reasonCode => <<"1">>}
+ }
+ }}
+ ])
end;
%Unsupported request
handle_json(Request) ->
To view, visit change 43819. To unsubscribe, or for help writing mail filters, visit settings.