Beispiel #1
0
    def _test_trans_as_path(self, input_as_path, expected_as_path,
                            expected_as4_path):
        # Prepare input data
        _peer = peer.Peer(None, None, None, None, None)

        # TEST
        output_as_path, output_as4_path = _peer._trans_as_path(input_as_path)

        eq_(expected_as_path, output_as_path)
        eq_(expected_as4_path, output_as4_path)
Beispiel #2
0
    def _test_construct_as_path_attr(self, input_as_path, input_as4_path,
                                     expected_as_path):
        # Prepare input data
        input_as_path_attr = bgp.BGPPathAttributeAsPath(input_as_path)
        input_as4_path_attr = bgp.BGPPathAttributeAs4Path(input_as4_path)
        _peer = peer.Peer(None, None, None, None, None)

        # TEST
        output_as_path_attr = _peer._construct_as_path_attr(
            input_as_path_attr, input_as4_path_attr)

        eq_(bgp.BGP_ATTR_TYPE_AS_PATH, output_as_path_attr.type)
        eq_(expected_as_path, output_as_path_attr.path_seg_list)
Beispiel #3
0
    def test_construct_as_path_attr_as4_path_None(self):
        # Test Data
        # Input:
        input_as_path = [[65000, 4000, 23456, 23456, 40001]]
        # input_as4_path = None
        # Expected:
        expected_as_path = [[65000, 4000, 23456, 23456, 40001]]

        # Prepare input data
        input_as_path_attr = bgp.BGPPathAttributeAsPath(input_as_path)
        input_as4_path_attr = None
        _peer = peer.Peer(None, None, None, None, None)

        # TEST
        output_as_path_attr = _peer._construct_as_path_attr(
            input_as_path_attr, input_as4_path_attr)

        eq_(bgp.BGP_ATTR_TYPE_AS_PATH, output_as_path_attr.type)
        eq_(expected_as_path, output_as_path_attr.path_seg_list)
Beispiel #4
0
    def _test_extract_and_reconstruct_as_path(self, path_attributes,
                                              ex_as_path_value,
                                              ex_aggregator_as_number,
                                              ex_aggregator_addr):
        # Prepare test data
        update_msg = bgp.BGPUpdate(path_attributes=path_attributes)
        _peer = peer.Peer(None, None, None, None, None)

        # Test
        _peer._extract_and_reconstruct_as_path(update_msg)

        umsg_pattrs = update_msg.pathattr_map
        as_path_attr = umsg_pattrs.get(bgp.BGP_ATTR_TYPE_AS_PATH, None)
        as4_path_attr = umsg_pattrs.get(bgp.BGP_ATTR_TYPE_AS4_PATH, None)
        aggregator_attr = umsg_pattrs.get(bgp.BGP_ATTR_TYPE_AGGREGATOR, None)
        as4_aggregator_attr = umsg_pattrs.get(bgp.BGP_ATTR_TYPE_AS4_AGGREGATOR,
                                              None)

        eq_(ex_as_path_value, as_path_attr.value)
        eq_(None, as4_path_attr)
        eq_(ex_aggregator_as_number, aggregator_attr.as_number)
        eq_(ex_aggregator_addr, aggregator_attr.addr)
        eq_(None, as4_aggregator_attr)