Beispiel #1
0
class GasketSingleTwoHostsTest(GasketMultiHostsBase):
    N_UNTAGGED = 4
    max_hosts = N_UNTAGGED - 2

    CONFIG = faucet_mininet_test_util.gen_config(max_hosts)
    CONFIG_GLOBAL = faucet_mininet_test_util.gen_config_global(max_hosts)
    CONFIG_BASE_ACL = faucet_mininet_test_util.gen_base_config(max_hosts)

    port_map = faucet_mininet_test_util.gen_port_map(N_UNTAGGED)

    LOGON_RETRIES = 5
    LOGOFF_RETRIES = 10
Beispiel #2
0
class GasketSingleTenHostsPerPortTest(GasketMultiHostPerPortTest):

    max_vlan_hosts = 10

    N_UNTAGGED = 4
    max_hosts = N_UNTAGGED - 2

    CONFIG = faucet_mininet_test_util.gen_config(max_hosts)
    CONFIG_GLOBAL = faucet_mininet_test_util.gen_config_global(max_hosts)
    CONFIG_BASE_ACL = faucet_mininet_test_util.gen_base_config(max_hosts)

    port_map = faucet_mininet_test_util.gen_port_map(N_UNTAGGED)

    def test_10_hosts_1_port_seq(self):
        """Log 10 different users on on the same port (using macvlans) sequentially (each should complete before the next starts).
        Then Log them all off. Then back on again. This takes a VERY LONG time to complete >15mins. 
        """
        h0 = self.clients[0]
        h1 = self.clients[1]
        #        h2 = self.clients[2]
        interweb = self.net.hosts[1]
        #        self.logon_dot1x(h2)
        self.logon_dot1x(h1)
        self.logon_dot1x(h0)
        self.one_ipv4_ping(h0, interweb.IP(), retries=5)
        self.one_ipv4_ping(h1, interweb.IP(), retries=5)
        h1.intf().updateIP()
        self.one_ipv4_ping(h0, h1.IP(), retries=10)
        mac_intfs = {mac: mac + 'ns' for mac in self.mac_interfaces.values()}

        # get each intf going.
        for intf, netns in mac_intfs.items():
            self.logon_dot1x(h0, intf=intf)
            self.one_ipv4_ping(h0, interweb.IP(), intf=intf, retries=10)
        print('first logons complete')

        for intf, netns in mac_intfs.items():
            self.logoff_dot1x(h0, intf=intf)
            self.fail_ping_ipv4(h0, h1.IP(), intf=intf)

        print('logoffs complete')
        self.one_ipv4_ping(h0, interweb.IP())

        for intf, netns in mac_intfs.items():
            self.relogon_dot1x(h0, intf=intf)

        print('relogons complete')
        self.one_ipv4_ping(h0, interweb.IP())
        passed = False
        for i in range(9):
            try:
                for intf, netns in mac_intfs.items():
                    print('ping after relogin')
                    self.one_ipv4_ping(h0, interweb.IP(), intf=intf, retries=1)
                # if it makes it to here all pings have succeeded.
                passed = True
                break
            except AssertionError as e:
                print(e)
                print('try ping again')
        self.assertTrue(passed)
        # TODO remove. this is just here to check no exceptions occured before the teardown
        self.verify_no_exception(self.env['faucet']['FAUCET_EXCEPTION_LOG'])
Beispiel #3
0
class GasketSingleSwitchTest(GasketTest):
    """Base Test class for single switch topology
    """
    ws_port = 0
    clients = []

    N_UNTAGGED = 5
    N_TAGGED = 0
    max_hosts = 3
    CONFIG_GLOBAL = faucet_mininet_test_util.gen_config_global(max_hosts)
    CONFIG_BASE_ACL = faucet_mininet_test_util.gen_base_config(max_hosts)
    CONFIG = faucet_mininet_test_util.gen_config(max_hosts)
    port_map = faucet_mininet_test_util.gen_port_map(N_UNTAGGED + N_TAGGED)

    def setUp(self):
        super(GasketSingleSwitchTest, self).setUp()

        self.topo = self.topo_class(self.ports_sock,
                                    self._test_name(),
                                    dpids=[self.dpid],
                                    n_tagged=self.N_TAGGED,
                                    n_untagged=self.N_UNTAGGED)

        # do the base config thing here.
        open(self.tmpdir + '/faucet-acl.yaml', 'w').write(
            faucet_mininet_test_util.gen_faucet_acl(self.max_hosts) %
            self.port_map)
        shutil.copytree('/gasket-src/', '%s/gasket-src' % self.tmpdir)
        self.start_net()
        print('network started')
        self.start_programs()
        print('programs started')

    def start_programs(self):
        """Start the authentication controller app, hostapd, dhcp server, 'internet' webserver
        """
        # pylint: disable=unbalanced-tuple-unpacking
        portal, interweb = self.net.hosts[:2]
        gasket_host = Node('gasket', inNamespace=False)

        # pylint: disable=no-member
        contr_num = self.get_controller_number()
        self.net.addLink(portal,
                         gasket_host,
                         params1={'ip': '192.168.%s.2/29' % contr_num},
                         params2={'ip': '192.168.%s.3/29' % contr_num})
        self.one_ipv4_ping(portal,
                           '192.168.%s.3' % contr_num,
                           intf=('%s-eth1' % portal.name),
                           require_host_learned=False)
        portal.setMAC('70:6f:72:74:61:6c', portal.defaultIntf())
        # do not allow the portal to forward ip packets. Otherwise packets redirected to the portal will be forwarded,
        # and effectivley bypass the ACLs.
        portal.cmdPrint("echo '0' > /proc/sys/net/ipv4/ip_forward")

        contr_num = int(contr_num) + 1

        self.start_tcpdump(self.net.controller)

        self.start_tcpdump(portal, interface='%s-eth0' % portal.name)
        self.start_tcpdump(portal, interface='%s-eth1' % portal.name)
        self.start_tcpdump(portal,
                           interface='lo',
                           expr='udp port 1812 or udp port 1813')
        self.start_tcpdump(interweb)

        self.start_tcpdump(gasket_host, interface='%s-eth0' % gasket_host.name)

        self.init_gasket(gasket_host)
        self.run_hostapd(portal)
        self.run_freeradius(portal)

        self.run_internet(interweb)

        self.clients = self.net.hosts[2:]
        self.setup_hosts(self.clients)