How to use remove_checksum method in autotest

Best Python code snippet using autotest_python

reflector.py

Source:reflector.py Github

copy

Full Screen

...24 group.add_argument("-v", "--verbose", action="store_true")25 group.add_argument("-q", "--quiet", action="store_true")26 args = parser.parse_args()27 return args28def remove_checksum(pkt):29 del pkt.chksum30 if pkt.haslayer(TCP):31 del pkt[TCP].chksum32 if pkt.haslayer(UDP):33 del pkt[UDP].chksum34 if pkt.haslayer(ICMP):35 del pkt[ICMP].chksum36 return pkt37class Reflector:38 def __init__(self, int_face, v_ip, v_eth, r_ip, r_eth):39 self.int_face = int_face40 self.v_ip = v_ip41 self.v_eth = v_eth42 self.r_ip = r_ip43 self.r_eth = r_eth44 sniff(prn=self.main_pkt_checker, iface=self.int_face)45 def main_pkt_checker(self, pkt):46 print(pkt.summary())47 new_pkt = None48 # # Handle APR49 if ARP in pkt and pkt[ARP].pdst == self.v_ip:50 new_pkt = self.send_arp_from_victim(pkt)51 if ARP in pkt and pkt[ARP].pdst == self.r_ip:52 new_pkt = self.send_arp_from_reflector(pkt)53 if IP in pkt and pkt[IP].dst == self.v_ip:54 new_pkt = self.send_from_reflector(pkt)55 if IP in pkt and pkt[IP].dst == self.r_ip:56 new_pkt = self.send_from_victim(pkt)57 if new_pkt is not None:58 sendp(new_pkt, iface=self.int_face)59 def send_arp_from_victim(self, pkt):60 # set pkt src as reflector61 # print("---------ORIGINAL PKT------------")62 # pkt.show()63 # print("----------send_arp_from_victim-----------")64 p = pkt.copy()65 p[ARP].op = 2 # casue we are saying is at.66 p[Ether].dst = pkt[ARP].hwsrc67 p[ARP].pdst = pkt[ARP].psrc # attack was the src68 p[ARP].hwdst = pkt[ARP].hwsrc # attack was the src69 p[Ether].src = self.v_eth70 p[ARP].psrc = self.v_ip71 p[ARP].hwsrc = self.v_eth72 # p.show2()73 return p74 def send_arp_from_reflector(self, pkt):75 # set pkt src as reflector76 # print("---------ORIGINAL PKT------------")77 # pkt.show()78 # print("----------send_arp_from_victim-----------")79 p = pkt.copy()80 p.op = 2 # casue we are saying is at.81 p[Ether].dst = pkt[ARP].hwsrc82 p[ARP].pdst = pkt[ARP].psrc # attack was the src83 p[ARP].hwdst = pkt[ARP].hwsrc # attack was the src84 p[Ether].src = self.r_eth85 p[ARP].psrc = self.r_ip86 p[ARP].hwsrc = self.r_eth87 # p.show2()88 return p89 def send_from_reflector(self, pkt):90 p = pkt.copy()91 print("Check sum : ", p.chksum)92 p = remove_checksum(p)93 p[IP].src = self.r_ip94 p[Ether].src = self.r_eth95 p[IP].dst = pkt[IP].src96 p[Ether].dst = pkt[Ether].src # attack was the src97 p.show2()98 return p99 def send_from_victim(self, pkt):100 p = pkt.copy()101 print("Check sum : ", p.chksum)102 p = remove_checksum(p)103 # set src and dst104 p[IP].src = self.v_ip105 p[Ether].src = self.v_eth106 p[IP].dst = pkt[IP].src107 p[Ether].dst = pkt[Ether].src # attack was the src108 p.show2()109 return p110# def arp_monitor_callback(pkt):111# if ARP in pkt and pkt[ARP].op in (1,2): #who-has or is-at112# return pkt.sprintf("%ARP.hwsrc% %ARP.psrc%")113def main():114 my_args = get_input_args()115 my_reflector = Reflector(116 my_args.interface,...

Full Screen

Full Screen

test_only_keep_recent_boxes.py

Source:test_only_keep_recent_boxes.py Github

copy

Full Screen

1from mock import call2from vagrant_catalog_generator.manage_boxfiles import only_keep_recent_boxes3from vagrant_catalog_generator.tests.testcase import TestCase4class TestOnlyKeepRecentBoxes(TestCase):5 def setUp(self):6 self.remove_boxfile = self.set_up_patch('vagrant_catalog_generator.manage_boxfiles.remove_boxfile')7 self.remove_checksum = self.set_up_patch('vagrant_catalog_generator.manage_boxfiles.remove_checksum')8 self.recent_box_amount = self.set_up_patch('vagrant_catalog_generator.manage_boxfiles.RECENT_BOX_AMOUNT')9 self.boxes = [10 'hypernode.release-latest.box',11 'hypernode.virtualbox.release-1.box',12 'hypernode.lxc.release-1.box',13 'hypernode.virtualbox.release-2635.box',14 'hypernode.lxc.release-2635.box',15 'hypernode.virtualbox.release-2638.box',16 'hypernode.lxc.release-2638.box',17 'hypernode.virtualbox.release-2653.box',18 'hypernode.lxc.release-2653.box',19 'hypernode.virtualbox.release-2659.box',20 'hypernode.lxc.release-2659.box',21 'hypernode.virtualbox.release-2674.box',22 'hypernode.lxc.release-2674.box'23 ]24 def test_only_keep_recent_boxes_removes_boxfiles(self):25 only_keep_recent_boxes('/some/dir', self.boxes, amount=6)26 expected_calls = [call('/some/dir', box) for box in [27 'hypernode.virtualbox.release-2635.box',28 'hypernode.lxc.release-2635.box',29 'hypernode.virtualbox.release-2638.box',30 'hypernode.lxc.release-2638.box',31 ]]32 self.assertEqual(expected_calls, self.remove_boxfile.mock_calls)33 def test_only_keep_recent_boxes_removes_checksum(self):34 only_keep_recent_boxes('/some/dir', self.boxes, amount=6)35 expected_calls = [call('/some/dir', box) for box in [36 'hypernode.virtualbox.release-2635.box',37 'hypernode.lxc.release-2635.box',38 'hypernode.virtualbox.release-2638.box',39 'hypernode.lxc.release-2638.box',40 ]]41 self.assertEqual(expected_calls, self.remove_checksum.mock_calls)42 def test_only_keep_recent_boxes_doesnt_remove_latest_link(self):43 only_keep_recent_boxes('/some/dir', self.boxes, amount=0)44 self.assertNotIn(call('/some/dir', 'hypernode.release-latest.box'), self.remove_boxfile.mock_calls)45 def test_only_keep_recent_boxes_doesnt_remove_latest_checksum(self):46 only_keep_recent_boxes('/some/dir', self.boxes, amount=0)...

Full Screen

Full Screen

test_remove_checksum.py

Source:test_remove_checksum.py Github

copy

Full Screen

...5 self.path = self.set_up_patch('vagrant_catalog_generator.manage_boxfiles.path')6 self.path.join.return_value = '/some/dir/hypernode.vagrant.release-2638.box'7 self.remove = self.set_up_patch('vagrant_catalog_generator.manage_boxfiles.remove')8 def test_remove_checksum_gets_box_abspath(self):9 remove_checksum('/some/dir', 'hypernode.vagrant.release-2638.box')10 self.path.join.assert_called_once_with('/some/dir', 'hypernode.vagrant.release-2638.box')11 def test_remove_checksum_removes_checksum_path(self):12 remove_checksum('/some/dir', 'hypernode.vagrant.release-2638.box')13 self.remove.assert_called_once_with(14 self.path.join.return_value + '.sha256'15 )16 def test_remove_checksum_catches_gone_files_and_other_oserrors(self):17 self.remove.side_effect = OSError...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful