#NEWLINE# def test_isolated_host( self ) : #NEWLINE# #INDENT# self . flags ( fake_network = False , share_dhcp_address = True ) #NEWLINE# self . stubs . Set ( linux_net , 'iptables_manager' , linux_net . IptablesManager ( ) ) #NEWLINE# self . stubs . Set ( linux_net , 'binary_name' , 'test' ) #NEWLINE# executes = [ ] #NEWLINE# def fake_execute( * args , **kwargs ) : #NEWLINE# #INDENT# executes . append ( args ) #NEWLINE# return ( '' , '' ) #NEWLINE# #UNINDENT# self . stubs . Set ( utils , 'execute' , fake_execute ) #NEWLINE# driver = linux_net . LinuxBridgeInterfaceDriver ( ) #NEWLINE# @ staticmethod #NEWLINE# def fake_ensure( bridge , interface , network , gateway ) : #NEWLINE# #INDENT# return bridge #NEWLINE# #UNINDENT# self . stubs . Set ( linux_net . LinuxBridgeInterfaceDriver , 'ensure_bridge' , fake_ensure ) #NEWLINE# iface = 'eth0' #NEWLINE# dhcp = '192.168.1.1' #NEWLINE# network = { #NEWLINE# #INDENT# 'dhcp_server' : dhcp , #NEWLINE# 'share_address' : False , #NEWLINE# 'bridge' : 'br100' , #NEWLINE# 'bridge_interface' : iface , #NEWLINE# #UNINDENT# } #NEWLINE# driver . plug ( network , 'fakemac' ) #NEWLINE# expected = [ ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'INPUT' , '-p' , 'ARP' , '-i' , iface , '--arp-ip-dst' , dhcp , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-I' , 'INPUT' , '-p' , 'ARP' , '-i' , iface , '--arp-ip-dst' , dhcp , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'OUTPUT' , '-p' , 'ARP' , '-o' , iface , '--arp-ip-src' , dhcp , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-I' , 'OUTPUT' , '-p' , 'ARP' , '-o' , iface , '--arp-ip-src' , dhcp , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'FORWARD' , '-p' , 'IPv4' , '-i' , iface , '--ip-protocol' , 'udp' , '--ip-destination-port' , '67:68' , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-I' , 'FORWARD' , '-p' , 'IPv4' , '-i' , iface , '--ip-protocol' , 'udp' , '--ip-destination-port' , '67:68' , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'FORWARD' , '-p' , 'IPv4' , '-o' , iface , '--ip-protocol' , 'udp' , '--ip-destination-port' , '67:68' , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-I' , 'FORWARD' , '-p' , 'IPv4' , '-o' , iface , '--ip-protocol' , 'udp' , '--ip-destination-port' , '67:68' , '-j' , 'DROP' ) , ( 'iptables-save' , '-c' ) , ( 'iptables-restore' , '-c' ) , ( 'ip6tables-save' , '-c' ) , ( 'ip6tables-restore' , '-c' ) ] #NEWLINE# self . assertEqual ( expected , executes ) #NEWLINE# executes = [ ] #NEWLINE# @ staticmethod #NEWLINE# def fake_remove( bridge , gateway ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# self . stubs . Set ( linux_net . LinuxBridgeInterfaceDriver , 'remove_bridge' , fake_remove ) #NEWLINE# driver . unplug ( network ) #NEWLINE# expected = [ ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'INPUT' , '-p' , 'ARP' , '-i' , fake_remove , '--arp-ip-dst' , dhcp , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'OUTPUT' , '-p' , 'ARP' , '-o' , iface , '--arp-ip-src' , dhcp , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'FORWARD' , '-p' , 'IPv4' , '-i' , iface , '--ip-protocol' , 'udp' , '--ip-destination-port' , '67:68' , '-j' , 'DROP' ) , ( 'ebtables' , '--concurrent' , '-t' , 'filter' , '-D' , 'FORWARD' , '-p' , 'IPv4' , '-o' , iface , '--ip-protocol' , 'udp' , '--ip-destination-port' , '67:68' , '-j' , 'DROP' ) ] #NEWLINE# self . assertEqual ( expected , executes )