pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36871?usp=email )

Change subject: asterisk: AMI: Implement AuthReq procedure
......................................................................

asterisk: AMI: Implement AuthReq procedure

Test Auth over AMI interface.

Change-Id: I77aeeb79cbddfc515e1626385f1b176da7319ba0
---
M asterisk/AMI_Functions.ttcn
M asterisk/Asterisk_Tests.ttcn
2 files changed, 129 insertions(+), 3 deletions(-)

Approvals:
  pespin: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/asterisk/AMI_Functions.ttcn b/asterisk/AMI_Functions.ttcn
index 4969905..be1be70 100644
--- a/asterisk/AMI_Functions.ttcn
+++ b/asterisk/AMI_Functions.ttcn
@@ -34,6 +34,13 @@
 const charstring AMI_FIELD_RESPONSE := "Response";

 /* Extensions: */
+const charstring AMI_FIELD_ALGORITHM := "Algorithm";
+const charstring AMI_FIELD_AUTN := "AUTN";
+const charstring AMI_FIELD_AUTS := "AUTS";
+const charstring AMI_FIELD_CK := "CK";
+const charstring AMI_FIELD_IK := "IK";
+const charstring AMI_FIELD_RAND := "RAND";
+const charstring AMI_FIELD_RES := "RES";
 const charstring AMI_FIELD_REGISTRATION := "Registration";

 type record AMI_Field {
@@ -87,6 +94,20 @@
 ts_AMI_Field_Secret(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_SECRET, val);
 /* Extensions: */
 template (value) AMI_Field
+ts_AMI_Field_Algorithm(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_ALGORITHM, val);
+template (value) AMI_Field
+ts_AMI_Field_AUTN(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_AUTN, val);
+template (value) AMI_Field
+ts_AMI_Field_AUTS(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_AUTS, val);
+template (value) AMI_Field
+ts_AMI_Field_CK(template (value) charstring val) := ts_AMI_Field(AMI_FIELD_CK, 
val);
+template (value) AMI_Field
+ts_AMI_Field_IK(template (value) charstring val) := ts_AMI_Field(AMI_FIELD_IK, 
val);
+template (value) AMI_Field
+ts_AMI_Field_RAND(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_RAND, val);
+template (value) AMI_Field
+ts_AMI_Field_RES(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_RES, val);
+template (value) AMI_Field
 ts_AMI_Field_Registration(template (value) charstring val) := 
ts_AMI_Field(AMI_FIELD_REGISTRATION, val);

 template (present) AMI_Field
@@ -105,6 +126,20 @@
 tr_AMI_Field_Response(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_RESPONSE, val);
 /* Extensions: */
 template (present) AMI_Field
+tr_AMI_Field_Algorithm(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_ALGORITHM, val);
+template (present) AMI_Field
+tr_AMI_Field_AUTN(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_AUTN, val);
+template (present) AMI_Field
+tr_AMI_Field_AUTS(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_AUTS, val);
+template (present) AMI_Field
+tr_AMI_Field_CK(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_CK, val);
+template (present) AMI_Field
+tr_AMI_Field_IK(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_IK, val);
+template (present) AMI_Field
+tr_AMI_Field_RAND(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_RAND, val);
+template (present) AMI_Field
+tr_AMI_Field_RES(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_RES, val);
+template (present) AMI_Field
 tr_AMI_Field_Registration(template (present) charstring val := ?) := 
tr_AMI_Field(pattern @nocase AMI_FIELD_REGISTRATION, val);


@@ -120,6 +155,39 @@
  * ACTIONS
  */

+/* Action: AuthResponse
+ * Registration: volte_ims
+ * AUTS: <value>
+ */
+template (value) AMI_Msg
+ts_AMI_Action_AuthResponse_AUTS(template (value) charstring registration,
+                               template (value) charstring auts,
+                               template (value) charstring action_id := 
"0001") := {
+       ts_AMI_Field_Action("AuthResponse"),
+       ts_AMI_Field_ActionId(action_id),
+       ts_AMI_Field_Registration(registration),
+       ts_AMI_Field_AUTS(auts)
+};
+/* Action: AuthResponse
+ * Registration: volte_ims
+ * RES: <value>
+ * CK: <value>
+ * IK: <value>
+ */
+template (value) AMI_Msg
+ts_AMI_Action_AuthResponse_RES(template (value) charstring registration,
+                              template (value) charstring res,
+                              template (value) charstring ck,
+                              template (value) charstring ik,
+                              template (value) charstring action_id := "0001") 
:= {
+       ts_AMI_Field_Action("AuthResponse"),
+       ts_AMI_Field_ActionId(action_id),
+       ts_AMI_Field_Registration(registration),
+       ts_AMI_Field_RES(res),
+       ts_AMI_Field_CK(ck),
+       ts_AMI_Field_IK(ik)
+};
+
 /* Action: Login
  * Username: <value>
  * Secret: <value>
@@ -217,6 +285,25 @@
 template (present) AMI_Msg
 tr_AMI_Event_FullyBooted := tr_AMI_Event("FullyBooted");

+/* Event: AuthRequest
+ * Privilege: <none>
+ * Registration: volte_ims
+ * Algorithm: AKAv1-MD5
+ * RAND: 14987631f65f8e3788a0798b6ebcd08e
+ * AUTN: f6e19a7ccb028000a06b19c9544516e5
+ */
+template (present) AMI_Msg
+tr_AMI_Event_AuthRequest(template (present) charstring registration := ?,
+                        template (present) charstring algorithm := "AKAv1-MD5",
+                        template (present) charstring rand := ?,
+                        template (present) charstring autn := ?) := superset(
+       tr_AMI_Field_Event("AuthRequest"),
+       tr_AMI_Field_Registration(registration),
+       tr_AMI_Field_Algorithm(algorithm),
+       tr_AMI_Field_RAND(rand),
+       tr_AMI_Field_AUTN(autn)
+);
+
 /***********************
  * Adapter:
  ***********************/
@@ -542,6 +629,21 @@
        f_ami_transceive_match_response_success(pt, 
ts_AMI_Action_PJSIPRegister(register, reg_action_id));
 }

+function f_ami_action_AuthResponse_AUTS(AMI_Msg_PT pt,
+                                       template (value) charstring 
registration,
+                                       template (value) charstring auts) {
+       var charstring reg_action_id := f_gen_action_id();
+       f_ami_transceive_match_response_success(pt, 
ts_AMI_Action_AuthResponse_AUTS(registration, auts, reg_action_id));
+}
+function f_ami_action_AuthResponse_RES(AMI_Msg_PT pt,
+                                      template (value) charstring registration,
+                                      template (value) charstring res,
+                                      template (value) charstring ck,
+                                      template (value) charstring ik) {
+       var charstring reg_action_id := f_gen_action_id();
+       f_ami_transceive_match_response_success(pt, 
ts_AMI_Action_AuthResponse_RES(registration, res, ck, ik, reg_action_id));
+}
+
 private function f_ami_selftest_decode(charstring txt) {
        log("Text to decode: '", txt, "'");
        var AMI_Msg msg := dec_AMI_Msg(txt);
diff --git a/asterisk/Asterisk_Tests.ttcn b/asterisk/Asterisk_Tests.ttcn
index df5904b..6852a57 100644
--- a/asterisk/Asterisk_Tests.ttcn
+++ b/asterisk/Asterisk_Tests.ttcn
@@ -384,9 +384,22 @@

        /* Trigger registration: */
        f_ami_action_PJSIPRegister(AMI_CLIENT, 
mp_volte_ims_outbound_registration);
-       /* TODO: Rx "Event: AuthRequest" */
-       /* TODO: Tx "Action: AuthResponse" */
-       /* TODO: Rx "Response: Success" */
+
+       var charstring rand_str := oct2str(pars.rand);
+       var charstring autn_str := oct2str(pars.autn);
+       
AMI_CLIENT.receive(tr_AMI_Event_AuthRequest(mp_volte_ims_outbound_registration,
+                                                   rand := pattern @nocase 
rand_str,
+                                                   autn := pattern @nocase 
autn_str));
+       /* TODO: need to find correct RES, CK, IK, values for:
+        * Response: "a19de225d030e6e0ec20f6de5f9dd80d"
+        * CNonce Value: "9a6460bcc3c84a3eac69455a93b67a77"
+        */
+       f_ami_action_AuthResponse_RES(AMI_CLIENT,
+                                 mp_volte_ims_outbound_registration,
+                                 res := "a19de225d030e6e0",
+                                 ck := "9a6460bcc3c84a3eac69455a93b67a77",
+                                 ik := "5238297dfcca759bd05d48ff49bc63fa");
+
        /* TODO: once registration is successful, rx:
         * Event: Registry
         * ChannelType: pjsip

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36871?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I77aeeb79cbddfc515e1626385f1b176da7319ba0
Gerrit-Change-Number: 36871
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: jolly <andr...@eversberg.eu>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-CC: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to