<p>merlinchlosta has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/23576">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">SUCI_Calc_Info: avoid repetition of test vectors<br><br>Change-Id: I4d1b5f10a7679387578383b72cb9a30ac74f2a07<br>---<br>M tests/test_utils.py<br>1 file changed, 20 insertions(+), 28 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/76/23576/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/test_utils.py b/tests/test_utils.py</span><br><span>index 9fa2ba0..badde55 100755</span><br><span>--- a/tests/test_utils.py</span><br><span>+++ b/tests/test_utils.py</span><br><span>@@ -5,6 +5,22 @@</span><br><span> from pySim.ts_31_102 import EF_SUCI_Calc_Info</span><br><span> </span><br><span> class DecTestCase(unittest.TestCase):</span><br><span style="color: hsl(120, 100%, 40%);">+  # TS33.501 Annex C.4 test keys</span><br><span style="color: hsl(120, 100%, 40%);">+        hnet_pubkey_profile_b = "0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1" # ID 27 in test file</span><br><span style="color: hsl(120, 100%, 40%);">+   hnet_pubkey_profile_a = "5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650" # ID 30 in test file  </span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ # TS31.121 4.9.4 EF_SUCI_Calc_Info test file</span><br><span style="color: hsl(120, 100%, 40%);">+  testfile_suci_calc_info = "A006020101020000A14B80011B8121" +hnet_pubkey_profile_b +"80011E8120" +hnet_pubkey_profile_a</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  decoded_testfile_suci = {</span><br><span style="color: hsl(120, 100%, 40%);">+             'prot_scheme_id_list': [</span><br><span style="color: hsl(120, 100%, 40%);">+                      {'priority': 0, 'identifier': 2, 'key_index': 1},</span><br><span style="color: hsl(120, 100%, 40%);">+                     {'priority': 1, 'identifier': 1, 'key_index': 2},</span><br><span style="color: hsl(120, 100%, 40%);">+                     {'priority': 2, 'identifier': 0, 'key_index': 0}],</span><br><span style="color: hsl(120, 100%, 40%);">+            'hnet_pubkey_list': [</span><br><span style="color: hsl(120, 100%, 40%);">+                 {'hnet_pubkey_identifier': 27, 'hnet_pubkey': hnet_pubkey_profile_b.lower()}, # because h2b/b2h returns all lower-case</span><br><span style="color: hsl(120, 100%, 40%);">+                        {'hnet_pubkey_identifier': 30, 'hnet_pubkey': hnet_pubkey_profile_a.lower()}]</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span>        def testSplitHexStringToListOf5ByteEntries(self):</span><br><span>            input_str = "ffffff0003ffffff0002ffffff0001"</span><br><span>@@ -84,38 +100,14 @@</span><br><span> </span><br><span> </span><br><span>        def testDecodeSuciCalcInfo(self):</span><br><span style="color: hsl(0, 100%, 40%);">-               # TS31.121 4.9.4 EF_SUCI_Calc_Info test file</span><br><span style="color: hsl(0, 100%, 40%);">-            testfile = "A006020101020000A14B80011B81210272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD180011E81205A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"</span><br><span style="color: hsl(0, 100%, 40%);">-               expected = {</span><br><span style="color: hsl(0, 100%, 40%);">-                    'prot_scheme_id_list': [</span><br><span style="color: hsl(0, 100%, 40%);">-                                {'priority': 0, 'identifier': 2, 'key_index': 1},</span><br><span style="color: hsl(0, 100%, 40%);">-                               {'priority': 1, 'identifier': 1, 'key_index': 2},</span><br><span style="color: hsl(0, 100%, 40%);">-                               {'priority': 2, 'identifier': 0, 'key_index': 0}],</span><br><span style="color: hsl(0, 100%, 40%);">-                      'hnet_pubkey_list': [</span><br><span style="color: hsl(0, 100%, 40%);">-                           {'hnet_pubkey_identifier': 27, 'hnet_pubkey': '0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1'.lower()}, # because h2b/b2h returns all lower-case</span><br><span style="color: hsl(0, 100%, 40%);">-                           {'hnet_pubkey_identifier': 30, 'hnet_pubkey': '5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650'.lower()}]</span><br><span style="color: hsl(0, 100%, 40%);">-                      }</span><br><span>            suci_calc_info = EF_SUCI_Calc_Info()</span><br><span style="color: hsl(0, 100%, 40%);">-            decoded = suci_calc_info._decode_hex(testfile)</span><br><span style="color: hsl(0, 100%, 40%);">-          self.assertDictEqual(expected, decoded)</span><br><span style="color: hsl(120, 100%, 40%);">+               decoded = suci_calc_info._decode_hex(self.testfile_suci_calc_info)</span><br><span style="color: hsl(120, 100%, 40%);">+            self.assertDictEqual(self.decoded_testfile_suci, decoded)</span><br><span> </span><br><span>        def testEncodeSuciCalcInfo(self):</span><br><span style="color: hsl(0, 100%, 40%);">-               # TS31.121 4.9.4 EF_SUCI_Calc_Info test file</span><br><span style="color: hsl(0, 100%, 40%);">-            expected = "A006020101020000A14B80011B81210272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD180011E81205A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-               decoded_testfile = {</span><br><span style="color: hsl(0, 100%, 40%);">-                    'prot_scheme_id_list': [</span><br><span style="color: hsl(0, 100%, 40%);">-                                {'priority': 0, 'identifier': 2, 'key_index': 1},</span><br><span style="color: hsl(0, 100%, 40%);">-                               {'priority': 1, 'identifier': 1, 'key_index': 2},</span><br><span style="color: hsl(0, 100%, 40%);">-                               {'priority': 2, 'identifier': 0, 'key_index': 0}],</span><br><span style="color: hsl(0, 100%, 40%);">-                      'hnet_pubkey_list': [</span><br><span style="color: hsl(0, 100%, 40%);">-                           {'hnet_pubkey_identifier': 27, 'hnet_pubkey': '0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1'.lower()},</span><br><span style="color: hsl(0, 100%, 40%);">-                            {'hnet_pubkey_identifier': 30, 'hnet_pubkey': '5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650'.lower()}]</span><br><span style="color: hsl(0, 100%, 40%);">-                      }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>            suci_calc_info = EF_SUCI_Calc_Info()</span><br><span style="color: hsl(0, 100%, 40%);">-            encoded = suci_calc_info._encode_hex(decoded_testfile)</span><br><span style="color: hsl(0, 100%, 40%);">-          self.assertEqual(encoded.lower(), expected.lower())</span><br><span style="color: hsl(120, 100%, 40%);">+           encoded = suci_calc_info._encode_hex(self.decoded_testfile_suci)</span><br><span style="color: hsl(120, 100%, 40%);">+              self.assertEqual(encoded.lower(), self.testfile_suci_calc_info.lower())</span><br><span> </span><br><span> if __name__ == "__main__":</span><br><span>  unittest.main()</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/23576">change 23576</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/23576"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I4d1b5f10a7679387578383b72cb9a30ac74f2a07 </div>
<div style="display:none"> Gerrit-Change-Number: 23576 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: merlinchlosta <merlin.chlosta@rub.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>