コード例 #1
0
 def test_match_buffer_context_propagation_exception(self):
     try:
         context_propagation.match_buffer_context_propagation(
             device=self.mocked_obj)
     except Exception as err:
         self.assertEqual(
             err.args[0],
             "context_id,initial_bytes and last_bytes are mandatory argument"
         )
コード例 #2
0
    def test_match_buffer_context_propagation_failure_init_cont_not_match(
            self):
        lst = [
            Response(
                "pctxt_id : smtp byte_array total len to print => [514=>49] \r pctxt_id : smtp byte_array partial info => [514=>0x74 0x65 0x73 0x74 0x20 0x6d 0x61 0x69 0x6c 0x20 0x62 (125))] \r pctxt_id : smtp byte_array final info => [514=>0x6c 0x64 0x20 0x61 0x6c 0x73 0x65 0x65 0x20 0x61 0x74 0x74 0x61 0x63 0x68 0x6d 0x65 0x6e 0x74 0x0d 0x0a (120/49/49))]"
            )
        ]

        self.mocked_obj.get_srx_pfe_names = MagicMock(return_value=["fpc0"])
        self.mocked_obj.vty = MagicMock(side_effect=lst)
        first_byte = "ISMAIL"
        last_byte = "68 6d 65 6e 74 0d 0a"
        try:
            context_propagation.match_buffer_context_propagation(
                device=self.mocked_obj,
                cntx_id="514",
                initial_bytes=first_byte,
                last_bytes=last_byte)
        except Exception as err:
            self.assertEqual(err.args[0], "Starting contents not matched")
コード例 #3
0
    def test_match_buffer_context_propagation_failure_only_final_info_last_cont_not_matched(
            self):
        lst = [
            Response(
                "pctxt_id : smtp byte_array total len to print => [514=>49] \r pctxt_id : smtp byte_array final info => [514=>0x6c 0x64 0x20 0x61 0x6c 0x73 0x65 0x65 0x20 0x61 0x74 0x74 0x61 0x63 0x68 0x6d 0x65 0x6e 0x74 0x0d 0x0a (120/49/49))]"
            )
        ]

        self.mocked_obj.get_srx_pfe_names = MagicMock(return_value=["fpc0"])
        self.mocked_obj.vty = MagicMock(side_effect=lst)
        first_byte = "6c 64 20 61 6c 73 65 65 20 61"
        last_byte = "68 6d 65 6e 74 0d 0a 23 45 66"
        try:
            context_propagation.match_buffer_context_propagation(
                device=self.mocked_obj,
                cntx_id="514",
                initial_bytes=first_byte,
                last_bytes=last_byte,
                length="49")
        except Exception as err:
            self.assertEqual(err.args[0], "Contents not matched fully")
コード例 #4
0
    def test_match_buffer_context_propagation_success_with_trace(self):
        trace = "pctxt_id : smtp byte_array total len to print => [514=>49] \r pctxt_id : smtp byte_array partial info => [514=>0x74 0x65 0x73 0x74 0x20 0x6d 0x61 0x69 0x6c 0x20 0x62 (125))] \r pctxt_id : smtp byte_array final info => [514=>0x6c 0x64 0x20 0x61 0x6c 0x73 0x65 0x65 0x20 0x61 0x74 0x74 0x61 0x63 0x68 0x6d 0x65 0x6e 0x74 0x0d 0x0a (120/49/49))]"

        first_byte = "74 65 73 74 20 6d 61 69"
        last_byte = "68 6d 65 6e 74 0d 0a"
        self.assertEqual(
            context_propagation.match_buffer_context_propagation(
                device=self.mocked_obj,
                cntx_id="514",
                initial_bytes=first_byte,
                last_bytes=last_byte,
                trace=trace,
                length="49"), True)
コード例 #5
0
    def test_match_buffer_context_propagation_exception_final_trace_not_found(
            self):
        lst = [
            Response(
                "pctxt_id : smtp byte_array total len to print => [514=>49] \r pctxt_id : smtp byte_array partial info => [514=>0x74 0x65 0x73 0x74 0x20 0x6d 0x61 0x69 0x6c 0x20 0x62 (125))] \r pctxt_id : smtp byte_array partial info => [514=>0x6c 0x64 0x20 0x61 0x6c 0x73 0x65 0x65 0x20 0x61 0x74 0x74 0x61 0x63 0x68 0x6d 0x65 0x6e 0x74 0x0d 0x0a (120/49/49))]"
            )
        ]

        self.mocked_obj.get_srx_pfe_names = MagicMock(return_value=["fpc0"])
        self.mocked_obj.vty = MagicMock(side_effect=lst)
        first_byte = "74 65 73 74 20 6d 61 69"
        last_byte = "68 6d 65 6e 74 0d 0a"
        try:
            context_propagation.match_buffer_context_propagation(
                device=self.mocked_obj,
                cntx_id="514",
                initial_bytes=first_byte,
                last_bytes=last_byte)
        except Exception as err:
            self.assertEqual(
                err.args[0],
                "Final/Last trace of content not found,match cannot take place"
            )
コード例 #6
0
    def test_match_buffer_context_propagation_success_only_final_info(self):
        lst = [
            Response(
                "pctxt_id : smtp byte_array total len to print => [514=>49] \r pctxt_id : smtp byte_array final info => [514=>0x6c 0x64 0x20 0x61 0x6c 0x73 0x65 0x65 0x20 0x61 0x74 0x74 0x61 0x63 0x68 0x6d 0x65 0x6e 0x74 0x0d 0x0a (120/49/49))]"
            )
        ]

        self.mocked_obj.get_srx_pfe_names = MagicMock(return_value=["fpc0"])
        self.mocked_obj.vty = MagicMock(side_effect=lst)
        first_byte = "6c 64 20 61 6c 73 65 65 20 61"
        last_byte = "68 6d 65 6e 74 0d 0a"
        self.assertEqual(
            context_propagation.match_buffer_context_propagation(
                device=self.mocked_obj,
                cntx_id="514",
                initial_bytes=first_byte,
                last_bytes=last_byte,
                length="49"), True)
コード例 #7
0
 def test_match_buffer_context_propagation_exception_no_device(self):
     try:
         context_propagation.match_buffer_context_propagation()
     except Exception as err:
         self.assertEqual(err.args[0], "device is mandatory argument")