def test_teacher_can_host(self): helpers.entete("Ensure that an teacher can host a service") output = execute("sudo ip netns exec ADM2 nmap -6 -Pn T:22 %s" % (TCH1)) list_results = output.split("\n") self.deleteUselessLines(list_results) result = self.checkStatus(list_results[0].split(" ")) self.assertFalse(result)
def test_guest_not_ssh(self): helpers.entete("Ensure that a guest can't use ssh over our network") output = execute("sudo ip netns exec GST1 nmap -6 -Pn T:22 %s" % (ADM1)) list_results = output.split("\n") self.deleteUselessLines(list_results) result = self.checkStatus(list_results[0].split(" ")) self.assertFalse(result)
def test_guest_not_host(self): helpers.entete("Ensure that a guest can't host a service") output = execute("sudo ip netns exec ADM1 nmap -6 -Pn T:22 %s" % (GST1)) list_results = output.split("\n") self.deleteUselessLines(list_results) result = self.checkStatus(list_results[0].split(" ")) self.assertFalse(result)
def test_router_not_reachable_from_student(self): helpers.entete( "Ensure that a student can't send traffic towards a router") output = execute("sudo ip netns exec STUD1 nmap -6 -Pn -p T:80 %s" % (MICH)) list_results = output.split("\n") self.deleteUselessLines(list_results) result = self.checkStatus(list_results[0].split(" ")) self.assertFalse(result)
def test_tunnel(self): helpers.entete("Set inteface HALL-eth1 down") output = execute("sudo ip netns exec HALL ip link set HALL-eth1 down") helpers.entete( "We wait 30 secondes to let OSPF modify the routing's tables") time.sleep(30) helpers.entete("We ping every routers and pop from every routers") output = execute("sudo ip netns exec CARN /etc/script/script.sh ") self.assertEqual( output.count('\n'), 0 ) #2 because they will be 2 error to ping the 2 addresses of HALL-eth1 output = execute("sudo ip netns exec HALL /etc/script/script.sh ") self.assertEqual(output.count('\n'), 0) output = execute("sudo ip netns exec MICH /etc/script/script.sh") self.assertEqual(output.count('\n'), 0) output = execute("sudo ip netns exec PYTH /etc/script/script.sh ") self.assertEqual(output.count('\n'), 0) output = execute("sudo ip netns exec SH1C /etc/script/script.sh") self.assertEqual(output.count('\n'), 0) output = execute("sudo ip netns exec STEV /etc/script/script.sh ") self.assertEqual(output.count('\n'), 0) helpers.entete("Set inteface HALL-eth1 up") output = execute( "sudo ip netns exec HALL /etc/static_routes/static_routes.sh 2> /dev/null" )
def test_open_TCP_ports_student(self): helpers.entete( "Test tcp ports 80, 443 from a student towards an external server") count = 0 output = execute("sudo ip netns exec STUD1 nmap -6 -Pn T:80,443 %s" % (google)) list_results = output.split("\n") self.deleteUselessLines(list_results) for port in list_results: getStatus = port.split(" ") if self.checkStatus(getStatus): count += 1 self.assertEqual(count, 2)
def test_servail(self): helpers.entete('Check if a dig return a servail error') output = execute('../../monit_tests/dns_test.sh') self.assertEquals(-1, output.find('SERVFAIL'))
def test_nxdomain(self): helpers.entete('Check if a dig return a nxdomain error') output = execute('../../monit_tests/dns_test.sh') self.assertEquals(-1, output.find('NXDOMAIN'))
def test_ping_everything_from_STEV(self): helpers.entete("Ping toutes les interfaces depuis STEV") output = execute("sudo ip netns exec STEV /etc/script/script.sh") self.assertFalse(output != "")