예제 #1
0
    def test_update4(self):
        """Check the abstraction of an UPDATE JSON document containing withdraws & announces"""

        # Get the abstract BGP message
        abstracted = MaboUpdateDocument("collector", json_update4)

        # Check announces
        assert list(abstracted.announces()) == [
            InternalMessage(timestamp=0,
                            collector="collector",
                            peer_as=1234,
                            peer_ip="1.2.3.4",
                            prefix="1.1.1.1/32",
                            asn=5678,
                            as_path="1234 5678")
        ]

        # Check withdraws
        assert list(abstracted.withdraws()) == [
            InternalMessage(timestamp=0,
                            collector="collector",
                            peer_as=1234,
                            peer_ip="1.2.3.4",
                            prefix="2.2.2.2/32",
                            asn=None,
                            as_path=None)
        ]
예제 #2
0
    def test_update3(self):
        """Check the abstraction of an UPDATE JSON document containing withdraws"""

        # Get the abstract BGP message
        abstracted = MaboUpdateDocument("collector", json_update3)

        # There is no announces
        assert list(abstracted.announces()) == []

        # Check each withdraw
        messages = list(abstracted.withdraws())
        assert len(messages) == 2
        assert messages.pop(0) == InternalMessage(timestamp=0,
                                                  collector="collector",
                                                  peer_as=1234,
                                                  peer_ip="1.2.3.4",
                                                  prefix="0.0.0.0/0",
                                                  asn=None,
                                                  as_path=None)
        assert messages.pop(0) == InternalMessage(timestamp=0,
                                                  collector="collector",
                                                  peer_as=1234,
                                                  peer_ip="1.2.3.4",
                                                  prefix="::/0",
                                                  asn=None,
                                                  as_path=None)
예제 #3
0
    def test_update2(self):
        """Check the abstraction of an UPDATE JSON document containing an AS_SET."""

        # Get the abstract BGP message
        abstracted = MaboUpdateDocument("collector", json_update2)

        # Check each announces
        messages = list(abstracted.announces())
        assert len(messages) == 2
        assert messages.pop(0) == InternalMessage(timestamp=0,
                                                  collector="collector",
                                                  peer_as=1234,
                                                  peer_ip="1.2.3.4",
                                                  prefix="::/0",
                                                  asn=5678,
                                                  as_path="1234 {5678,91011}")
        assert messages.pop(0) == InternalMessage(timestamp=0,
                                                  collector="collector",
                                                  peer_as=1234,
                                                  peer_ip="1.2.3.4",
                                                  prefix="::/0",
                                                  asn=91011,
                                                  as_path="1234 {5678,91011}")

        # There is no withraws
        assert list(abstracted.withdraws()) == []
예제 #4
0
  def test_update4(self):
    """Check the abstraction of an UPDATE JSON document containing withdraws & announces"""

    # Get the abstract BGP message
    abstracted = MaboUpdateDocument("collector", json_update4)

    # Check announces
    assert list(abstracted.announces()) == [ InternalMessage(timestamp=0, collector="collector",
                                               peer_as=1234, peer_ip="1.2.3.4",
                                               prefix="1.1.1.1/32", asn=5678, as_path="1234 5678") ]

    # Check withdraws
    assert list(abstracted.withdraws()) == [ InternalMessage(timestamp=0, collector="collector",
                                               peer_as=1234, peer_ip="1.2.3.4",
                                               prefix="2.2.2.2/32", asn=None, as_path=None) ]
예제 #5
0
  def test_update2(self):
    """Check the abstraction of an UPDATE JSON document containing an AS_SET."""

    # Get the abstract BGP message
    abstracted = MaboUpdateDocument("collector", json_update2)

    # Check each announces
    messages = list(abstracted.announces())
    assert len(messages) == 2
    assert messages.pop(0)== InternalMessage(timestamp=0, collector="collector",
                                             peer_as=1234, peer_ip="1.2.3.4",
                                             prefix="::/0", asn=5678, as_path="1234 {5678,91011}")
    assert messages.pop(0)== InternalMessage(timestamp=0, collector="collector",
                                             peer_as=1234, peer_ip="1.2.3.4",
                                             prefix="::/0", asn=91011, as_path="1234 {5678,91011}")

    # There is no withraws
    assert list(abstracted.withdraws()) == []
예제 #6
0
  def test_update3(self):
    """Check the abstraction of an UPDATE JSON document containing withdraws"""

    # Get the abstract BGP message
    abstracted = MaboUpdateDocument("collector", json_update3)

    # There is no announces
    assert list(abstracted.announces()) == []

    # Check each withdraw
    messages = list(abstracted.withdraws())
    assert len(messages) == 2
    assert messages.pop(0)== InternalMessage(timestamp=0, collector="collector",
                                             peer_as=1234, peer_ip="1.2.3.4",
                                             prefix="0.0.0.0/0", asn=None, as_path=None)
    assert messages.pop(0)== InternalMessage(timestamp=0, collector="collector",
                                             peer_as=1234, peer_ip="1.2.3.4",
                                             prefix="::/0", asn=None, as_path=None)