def test_wpa_wrongpass(self, setUp): """Attempt to connect to Wifi-WPA with wrong password""" network = conn() assertion = Assert() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.enable_wireless() radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") assertion.is_equal(radio_page.wireless_isenabled(), "Enabled") # enable primary network and both wpa2 and wpa network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) network_page.enable(network_page.get_wpa()) # Set encryption to TKIP network_page.set_encryption("TKIP") # Change WiFi password new_pass = '******' network_page.set_password(new_pass) network_page.apply_changes() # check wpa-psk is enabled and encryption is TKIP assertion.is_true(network_page.is_enabled( network_page.get_primary_network()), 'Primary Network') assertion.is_true(network_page.is_enabled( network_page.get_wpa()), 'WPA enabled') assertion.is_equal(network_page.get_encryption(), 'TKIP+AES') # check password is 'WpaPskChange' assertion.is_equal(network_page.get_password(), new_pass) # Wifi connection attempt time.sleep(20) connection_attempt = network.wifi_connection(ssid=self.SSID, pswd='WrongPass') try: assertion.is_unsucessful(connection_attempt, 'connection attempt') finally: self.reset_wifisession(self.firefox, self.SSID)
def test_default_encryp(self, setUp): """ Test default Encryption WPA2-PSK/AES - Transfer data""" assertion = Assert() network = conn() # factory reset security_page = SecurityPage(self.firefox) security_page.factory_reset() time.sleep(60) # log in login_page = LoginPage(self.firefox) login_page.enter_credentials(self.USERNAME, self.PASSWORD) # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.enable(radio_page.get_wireless()) radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") wireless = radio_page.get_wireless() assertion.is_true(radio_page.is_enabled(wireless), "Wireless") # Assert if WPA is disabled as default network_page = NetworkPage(self.firefox) wpa = network_page.get_wpa() assertion.is_false(network_page.is_enabled(wpa), "WPA disabled") # Assert if WPA2 is enabled as defaul wpa2 = network_page.get_wpa2() assertion.is_true(network_page.is_enabled(wpa2), "WPA2 enabled") # Assert if AES encryption mode is enabled as default encrypt = network_page.get_encryption() assertion.is_equal(encrypt, 'AES') # wifi connection attempt wifi_conn_attempt = network.wifi_connection( ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) assertion.is_wificonnected(wifi_conn_attempt) # disconnect ethernet interface try: eth_iface = network.eth_iface_name() eth_disc_attempt = network.disconnect_iface(eth_iface) assertion.is_true(eth_disc_attempt, "Disconnect ethernet") except Exception: self.reset_wifisession(self.firefox, self.SSID) raise # Transfer data between Wlan client and DUT time.sleep(3) url = '192.168.0.1' try: data_transf = network.transfer_data(url) assertion.is_true(data_transf, 'Data Transfer') finally: # reconfigure network interfaces to original settings network.connect_iface(eth_iface) self.reset_wifisession(self.firefox, self.SSID)
def test_wpa_validpass(self, setUp): """Attempt to connect to Wifi-WPA with valid password""" network = conn() assertion = Assert() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.enable_wireless() radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") assertion.is_equal(radio_page.wireless_isenabled(), "Enabled") # enable primary network and both wpa2 and wpa network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) network_page.enable(network_page.get_wpa()) # Set encryption to TKIP network_page.set_encryption("TKIP") # Change WiFi password new_pass = '******' network_page.set_password(new_pass) network_page.apply_changes() # check wpa-psk is enabled and encryption is TKIP assertion.is_true( network_page.is_enabled(network_page.get_primary_network()), 'Primary Network') assertion.is_true(network_page.is_enabled(network_page.get_wpa()), 'WPA enabled') assertion.is_equal(network_page.get_encryption(), 'TKIP+AES') # check password is 'WpaPskChange' print(network_page.get_password()) assertion.is_equal(network_page.get_password(), new_pass) # Wifi connection attempt time.sleep(20) connection_attempt = network.wifi_connection(ssid=self.SSID, pswd=new_pass) try: assertion.is_sucessful(connection_attempt, 'connection attempt') except NetworkError: self.reset_wifisession(self.firefox, self.SSID_PASS) raise # Disconnect wired interface eth_name = network.eth_iface_name() eth_disc_attempt = network.disconnect_iface(eth_name) try: assertion.is_sucessful(eth_disc_attempt, 'wired disconnection') except NetworkError: self.reset_wifisession(self.firefox, self.SSID) raise # Ping attempt wifi_iface = network.wifi_iface_name() ip = '192.168.0.1' ping_attempt = network.ping_attempt(wifi_iface, ip) try: assertion.is_sucessful(ping_attempt, 'ping attempt') finally: network.connect_iface(eth_name) self.reset_wifisession(self.firefox, self.SSID)
def test_wpa2_to_wpa(self, setUp): """Connect WS to DUT then change sec wpa2 to wpa/wpa2 """ network = conn() assertion = Assert() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.enable(radio_page.get_wireless()) radio_page.apply_changes() # assert wireless is enabled and wifi interface is 2.4Ghz assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") wireless = radio_page.get_wireless() assertion.is_true(radio_page.is_enabled(wireless), "Wireless") # enable primary network and wpa2 and disable wpa network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) network_page.disable(network_page.get_wpa()) network_page.apply_changes() # check primary network and wpa2 are enabled and encryption is AES netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') wpa2 = network_page.get_wpa2() assertion.is_true(network_page.is_enabled(wpa2), 'WPA2 enabled') wpa = network_page.get_wpa() assertion.is_false(network_page.is_enabled(wpa), 'WPA disabled') # Wifi connection attempt network.reset_network_mngr() wifi_connection = network.wifi_connection(ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_wificonnected(wifi_connection) except WifiConnError: self.reset_wifisession(self.firefox, self.SSID) raise # enable wpa time.sleep(30) network_page.enable(network_page.get_wpa()) # Set encryption to TKIP network_page.set_encryption("TKIP") network_page.apply_changes() # check wpa-psk is enabled and encryption is TKIP print(network_page.is_enabled(network_page.get_wpa())) assertion.is_true(network_page.is_enabled(network_page.get_wpa()), 'WPA is enabled') assertion.is_equal(network_page.get_encryption(), 'TKIP+AES') # Disconnect wired interface eth_iface = network.eth_iface_name() # get name of wired iface eth_disc_attempt = network.disconnect_iface(eth_iface) try: assertion.is_sucessful(eth_disc_attempt, "ethernet disconnect") except NetworkError: self.reset_wifisession(self.firefox, self.SSID) raise # ping attempt ip = 'www.google.com' wifi_iface = network.wifi_iface_name() # get name of wifi iface ping_attempt = network.ping_attempt(wifi_iface, ip) try: assertion.is_sucessful(ping_attempt, "ping attempt") finally: network.connect_iface(eth_iface) self.reset_wifisession(self.firefox, self.SSID)
def test_custom_key(self, setUp): """Set new key passphrase then connect WS to DUT. """ network = conn() assertion = Assert() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.enable_wireless() radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") assertion.is_equal(radio_page.wireless_isenabled(), "Enabled") # enable primary network, enable WPA2 and disable WPA network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) network_page.disable(network_page.get_wpa()) network_page.apply_changes() # Assert only WPA2 is enabled assertion.is_true( network_page.is_enabled(network_page.get_primary_network()), 'Primary Network') assertion.is_true(network_page.is_enabled(network_page.get_wpa2()), 'WPA 2') assertion.is_false(network_page.is_enabled(network_page.get_wpa()), 'WPA') # change key passphrase to '1234567890' password = '******' network_page.set_password(password) network_page.apply_changes() # assert password was changed print(network_page.get_password()) assertion.is_equal(network_page.get_password(), password) # Wifi connection attempt network.reset_network_mngr() wifi_connection = network.wifi_connection(ssid=self.SSID, pswd=password, timeout=20) try: assertion.is_wificonnected(wifi_connection) except WifiConnError: self.reset_wifisession(self.firefox, self.SSID) raise # Disconnect wired interface eth_iface = network.eth_iface_name() # get name of wired iface eth_disc_attempt = network.disconnect_iface(eth_iface) try: assertion.is_sucessful(eth_disc_attempt, "ethernet disconnect") except NetworkError: self.reset_wifisession(self.firefox, self.SSID) raise # ping attempt wifi_iface = network.wifi_iface_name() # get name of wifi iface ip = 'www.google.com' time.sleep(10) ping_attempt = network.ping_attempt(wifi_iface, ip) time.sleep(10) try: assertion.is_sucessful(ping_attempt, "ping attempt") finally: network.connect_iface(eth_iface) self.reset_wifisession(self.firefox, self.SSID) # enable wpa network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_wpa()) # Set encryption to TKIP network_page.set_encryption("TKIP") # Change WiFi password new_pass = '******' network_page.set_password(new_pass) network_page.apply_changes() # check wpa-psk is enabled and encryption is TKIP assertion.is_true(network_page.is_enabled(network_page.get_wpa()), 'WPA is enabled') assertion.is_equal(network_page.get_encryption(), 'TKIP+AES') # check password is 'WpaPskChange' assertion.is_equal(network_page.get_password(), new_pass) # Wifi connection attempt network.reset_network_mngr() wifi_connection = network.wifi_connection(ssid=self.SSID, pswd=new_pass, timeout=20) try: assertion.is_wificonnected(wifi_connection) except WifiConnError: self.reset_wifisession(self.firefox, self.SSID) raise # Disconnect wired interface eth_disc_attempt = network.disconnect_iface(eth_iface) try: assertion.is_sucessful(eth_disc_attempt, "ethernet disconnect") except NetworkError: self.reset_wifisession(self.firefox, self.SSID) raise # ping attempt ip = 'www.google.com' ping_attempt = network.ping_attempt(wifi_iface, ip) try: assertion.is_sucessful(ping_attempt, "ping attempt") finally: network.connect_iface(eth_iface) self.reset_wifisession(self.firefox, self.SSID)
def test_deny_opensec(self, setUp): """DUT denies access to client without password""" network = conn() assertion = Assert() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.enable_wireless() radio_page.apply_changes() # assert wireless is enabled and bandwidth is 2.4Ghz assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") assertion.is_equal(radio_page.wireless_isenabled(), "Enabled") # enable Primary Network and WPA2 and disable WPA network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) network_page.disable(network_page.get_wpa()) network_page.apply_changes() # Assert only WPA2 is enabled assertion.is_true( network_page.is_enabled(network_page.get_primary_network()), 'Primary Network') assertion.is_true(network_page.is_enabled(network_page.get_wpa2()), 'WPA 2') assertion.is_false(network_page.is_enabled(network_page.get_wpa()), 'WPA') # Wifi connection attempt network.reset_network_mngr() wifi_connection = network.wifi_connection_nosec(ssid=self.SSID) try: assertion.is_false(wifi_connection, 'wifi connection') finally: self.reset_wifisession(self.firefox, self.SSID) # enable wpa and set encryption to TKIP network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_wpa()) network_page.set_encryption("TKIP") network_page.apply_changes() # check wpa-psk is enabled and encryption is TKIP assertion.is_true(network_page.is_enabled(network_page.get_wpa()), 'WPA is enabled') assertion.is_equal(network_page.get_encryption(), 'TKIP+AES') # Wifi connection attempt network.reset_network_mngr() wifi_connection = network.wifi_connection_nosec(ssid=self.SSID) try: assertion.is_false(wifi_connection, 'wifi connection') finally: self.reset_wifisession(self.firefox, self.SSID) # disable WPA2 network_page = NetworkPage(self.firefox) network_page.disable(network_page.get_wpa2()) network_page.apply_changes() # assert WPA2 (therefore WPA too for 3P Box) is disabled assertion.is_false(network_page.is_enabled(network_page.get_wpa2()), 'WPA 2') # Wifi connection attempt network.reset_network_mngr() time.sleep(5) wifi_connection = network.wifi_connection_nosec(ssid=self.SSID) try: assertion.is_wificonnected(wifi_connection) finally: self.reset_wifisession(self.firefox, self.SSID)