Beispiel #1
0
 def test_tcpreplay_l3mode_execution_3(self, patched_get_linux_int_mac):
     patched_get_linux_int_mac.return_value = "00:50:56:A6:32:31"
     lst = [
         Response("abcd"),
         Response("m"),
         Response("n"),
         Response("o"),
         Response("p")
     ]
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     self.assertEqual(
         tcpreplay_l3mode(device=self.mocked_obj,
                          pcap_file="test.pcap",
                          client_ip="4.0.0.1",
                          server_ip="5.0.0.1",
                          split_ip="10.0.0.1",
                          device_ingress_mac="ge1",
                          device_egress_mac="ge2",
                          client_mac="abc",
                          server_mac="def",
                          mbps="3"), "o")
Beispiel #2
0
 def test_tcpreplay_l3mode_execution_4(self, patched_get_linux_int_mac):
     patched_get_linux_int_mac.return_value = "00:50:56:A6:32:30"
     lst = [
         Response("abcd"),
         Response("m"),
         Response("n"),
         Response("o"),
         Response("p")
     ]
     self.mocked_obj.shell = MagicMock(side_effect=lst)
     self.assertEqual(
         tcpreplay_l3mode(device=self.mocked_obj,
                          pcap_file="test.pcap",
                          client_ip="2004::1",
                          server_ip="2005::1",
                          split_ip="2010::1",
                          device_ingress_mac="ge1",
                          device_egress_mac="ge2",
                          client_mac="abc",
                          server_mac="def",
                          topspeed="yes",
                          ipproto="ipv6"), "o")
Beispiel #3
0
    def test_tcpreplay_l3mode_exception(self, patched_get_linux_int_mac):
        patched_get_linux_int_mac.return_value = "00:50:56:A6:32:34"
        try:
            tcpreplay_l3mode()
        except Exception as err:
            self.assertEqual(err.args[0],
                             "linux handle is the mandatory argument")

        try:
            tcpreplay_l3mode(device=self.mocked_obj)
        except Exception as err:
            self.assertEqual(err.args[0],
                             "To replay pcap, pcap file name is mandatory")

        try:
            tcpreplay_l3mode(device=self.mocked_obj, pcap_file="test.pcap")
        except Exception as err:
            self.assertEqual(
                err.args[0],
                "Mandatory arguments are client_ip, server_ip and split_ip")

        try:
            tcpreplay_l3mode(device=self.mocked_obj,
                             pcap_file="test.pcap",
                             client_ip="4.0.0.1",
                             server_ip="5.0.0.1",
                             split_ip="10.0.0.1")
        except Exception as err:
            self.assertEqual(
                err.args[0],
                "Mandatory arguments are device_ingress_mac and device_egress_mac"
            )

        lst = [Response("a"), Response("b")]
        self.mocked_obj.shell = MagicMock(side_effect=lst)
        try:
            tcpreplay_l3mode(device=self.mocked_obj,
                             pcap_file="test.pcap",
                             client_ip="4.0.0.1",
                             server_ip="5.0.0.1",
                             split_ip="10.0.0.1",
                             device_ingress_mac="ge1",
                             device_egress_mac="ge2",
                             client_mac="abc",
                             server_mac="def",
                             multiplier="2",
                             pps="3")
        except Exception as err:
            self.assertEqual(
                err.args[0],
                "Only one argument can be passed out of multiplier, pps, mbps and topspeed"
            )

        lst = [Response("c"), Response("d")]
        self.mocked_obj.shell = MagicMock(side_effect=lst)
        try:
            tcpreplay_l3mode(device=self.mocked_obj,
                             pcap_file="test.pcap",
                             client_ip="4.0.0.1",
                             server_ip="5.0.0.1",
                             split_ip="10.0.0.1",
                             device_ingress_mac="ge1",
                             device_egress_mac="ge2",
                             client_mac="abc",
                             server_mac="def",
                             pps="3",
                             mbps="4")
        except Exception as err:
            self.assertEqual(
                err.args[0],
                "Only one argument can be passed out of multiplier, pps, mbps and topspeed"
            )

        lst = [Response("e"), Response("f")]
        self.mocked_obj.shell = MagicMock(side_effect=lst)
        try:
            tcpreplay_l3mode(device=self.mocked_obj,
                             pcap_file="test.pcap",
                             client_ip="4.0.0.1",
                             server_ip="5.0.0.1",
                             split_ip="10.0.0.1",
                             device_ingress_mac="ge1",
                             device_egress_mac="ge2",
                             client_mac="abc",
                             server_mac="def",
                             mbps="4",
                             topspeed="yes")
        except Exception as err:
            self.assertEqual(
                err.args[0],
                "Only one argument can be passed out of multiplier, pps, mbps and topspeed"
            )

        lst = [Response("g"), Response("h")]
        self.mocked_obj.shell = MagicMock(side_effect=lst)
        try:
            tcpreplay_l3mode(device=self.mocked_obj,
                             pcap_file="test.pcap",
                             client_ip="4.0.0.1",
                             server_ip="5.0.0.1",
                             split_ip="10.0.0.1",
                             device_ingress_mac="ge1",
                             device_egress_mac="ge2",
                             client_mac="abc",
                             server_mac="def",
                             topspeed="yes",
                             pps="5")
        except Exception as err:
            self.assertEqual(
                err.args[0],
                "Only one argument can be passed out of multiplier, pps, mbps and topspeed"
            )