def test_broadcast_off(self, setUp): """ Verify disabled SSID broadcast status""" assertion = Assert() network = conn() # select wireless interface and disable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.disable(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_false(radio_page.is_enabled(wireless), "Wireless") # disable primary network network_page = NetworkPage(self.firefox) network_page.disable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_false(network_page.is_enabled(netwrk), 'Primary Network') # Check if ssid shows up on wifi scan wifi_24_ssid = network_page.get_ssid_name() ssid_online = network.ssid_check(ssid=wifi_24_ssid) try: assertion.is_false(ssid_online, "SSID is offline") finally: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default()
def test_ssidbroadcast(self, setUp): """Check 5.0Ghz ssid visibility from client and beacon broadcast """ assertion = Assert() network = conn() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="5.0GHZ") radio_page.enable(radio_page.get_wireless()) radio_page.set_channel('36') radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "5 Ghz") wireless = radio_page.get_wireless() assertion.is_true(radio_page.is_enabled(wireless), "Wireless") # enable primary network -> broadcast ssid network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Check if ssid shows up on wifi scan time.sleep(65) wifi_24_ssid = network_page.get_ssid_name() print(network_page.get_ssid_name()) ssid_online = network.ssid_check(ssid=wifi_24_ssid) try: assertion.is_true(ssid_online, "SSID is online") except WebElementError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() raise
def test_local_ipv6(self, setUp): """Check if a WiFi 5GHz Client can ping gateway's local IPV6 address""" assertion = Assert() network = conn() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="5.0GHZ") radio_page.enable(radio_page.get_wireless()) radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "5 Ghz") wireless = radio_page.get_wireless() assertion.is_true(radio_page.is_enabled(wireless), "Wireless") # enable primary network -> broadcast ssid network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Get DUT local ipv6 address through WebUI time.sleep(2) basic_page = BasicPage(self.firefox) DUT_ipv6_addr = basic_page.get_ipv6_address() # Wifi connection attempt wifi_connection = network.wifi_connection(ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_wificonnected(wifi_connection) except WifiConnError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() 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 to local ipv6 of DUT wifi_iface = network.wifi_iface_name() dut_ping6_attempt = network.ping6_attempt(wifi_iface, DUT_ipv6_addr) try: assertion.is_sucessful(dut_ping6_attempt, "ping attempt") finally: network.connect_iface(eth_iface) self.reset_wifisession(self.firefox, self.SSID)
def test_ping_scan_auto(self, setUp): """Ping (auto channel) nmode off while doing network scan""" assertion = Assert() network = conn() # 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()) # set channel auto, band 20 and disable n mode radio_page.select_bandwidth('20') radio_page.set_channel('0') radio_page.disable(radio_page.get_n_mode()) 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") assertion.is_equal(radio_page.get_bandwidth(), '20') assertion.is_equal(radio_page.get_channel(), '0') assertion.is_false(radio_page.is_nmode_enabled(), "N Mode") # enable primary network network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Wifi connection attempt connection_attempt = network.wifi_connection(ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_sucessful(connection_attempt, 'connection attempt') except NetworkError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() raise # Disconnect wired interface eth_name = network.eth_iface_name() # get name of wired iface eth_disc_attempt = network.disconnect_iface(eth_name) try: assertion.is_sucessful(eth_disc_attempt, "ethernet disconnect") except NetworkError: self.reset_wifisession(self.firefox, self.SSID) raise # Click on scan button time.sleep(3) radio_page = RadioPage(self.firefox) try: radio_page.click_on_scan() except Exception: network.connect_iface(eth_name) self.reset_wifisession(self.firefox, self.SSID) raise # 10 Ping attempt to get 100% of success time.sleep(3) wifi_iface = network.wifi_iface_name() # get wifi iface name DUT_default_IP = '192.168.0.1' ping_attempt = network.ping_attempt_100(wifi_iface, DUT_default_IP, count=10) time.sleep(10) try: assertion.is_sucessful(ping_attempt, 'ping attempt') finally: # reconfigure network interfaces to original settings network.connect_iface(eth_name) self.reset_wifisession(self.firefox, self.SSID)
def test_deny_client(self, setUp): """Check if DUT denies client connection attempt Try to connect to WPA2 and WPA/WPA2 security without providing passkey. """ assertion = Assert() network = conn() self.firefox.get("http://192.168.0.1/wlanRadio.asp") """ select wifi 5.0ghz and set to enabled """ wifi_5_iface = self.firefox.find_element_by_css_selector( "select[name*='WirelessMacAddress']>option[value*='0']") wifi_5_iface.click() ssid_enable = self.firefox.find_element_by_css_selector( "select[name*='WirelessEnable']>option[value*='1']") ssid_enable.click() apply_btn = self.firefox.find_element_by_css_selector( "input[onclick*='commitRadio()']") apply_btn.click() """ assert ssid is enabled """ try: ssid_enable = WebDriverWait(self.firefox, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, "select[name*='WirelessEnable']>option[selected='']"))) finally: assertion.is_equal(ssid_enable.text, 'Enabled') """ assert wifi 5.0ghz interface is selected """ self.firefox.get('http://192.168.0.1/wlanPrimaryNetwork.asp') wifi_5_iface = self.firefox.find_element_by_css_selector( "form[name*='wlanPrimaryNetwork'] > table > tbody > tr:nth-child(1) > td") selected_iface = wifi_5_iface.text assertion.is_equal(selected_iface[:6], 'NET_5G') """ Disable WPA and set network security to WPA2 """ self.firefox.get('http://192.168.0.1/wlanPrimaryNetwork.asp') wpa_disable = self.firefox.find_element_by_css_selector( "select[name*='WpaPskAuth']>option[value*='0']") wpa_disable.click() wpa2_enable = self.firefox.find_element_by_css_selector( "select[name*='Wpa2PskAuth']>option[value*='1']") wpa2_enable.click() apply_btn = self.firefox.find_element_by_css_selector( "input[onclick*='onClickApply()']") apply_btn.click() """ Assert only WPA2 is enabled """ wpa_disabled = self.firefox.find_element_by_css_selector( "select[name*='WpaPskAuth']>option[selected='']") assertion.is_equal(wpa_disabled.text, 'Disabled') wpa2_enabled = self.firefox.find_element_by_css_selector( "select[name*='Wpa2PskAuth']>option[selected='']") assertion.is_equal(wpa2_enabled.text, 'Enabled') """ Try to connect client with no sec to WPA2 network """ try: conn_attempt = network.wifi_connection_nosec(ssid='NET_5GAE287E', timeout=20) assertion.is_false(conn_attempt, "connection attempt to WPA2 failed") except AssertionError: print("Connection was successful") raise ConnectionError finally: network.delete_wifi_profile(ssid='NET_5GAE287E') """ enable WPA and TKIP encryption """ wpa_enable = self.firefox.find_element_by_css_selector( "select[name*='WpaPskAuth']>option[value*='1']") wpa_enable.click() tkip_enable = self.firefox.find_element_by_css_selector( "select[name*='WpaEncryption']>option[value*='3']") tkip_enable.click() apply_btn = self.firefox.find_element_by_css_selector( "input[onclick*='onClickApply()']") apply_btn.click() """ assert tkip is enabled - only possible if wpa is enabled """ assert_tkip = self.firefox.find_element_by_css_selector( "select[name*='WpaEncryption']>option[selected='']") assertion.is_equal(assert_tkip.text, 'TKIP+AES') """ Try to connect client with no sec to WPA2 network """ try: conn_attempt = network.wifi_connection_nosec(ssid='NET_5GAE287E', timeout=20) assertion.is_false(conn_attempt, "connection attempt to WPA/WPA2 - TKIP failed") except AssertionError: print("Connection was successful") raise AssertionError finally: self.reset_wifisession(self.firefox, self.SSID)
def test_ssid_maxchar(self, setUp): assertion = Assert() network = conn() """Check if DUT SSID name max characters allowed is 32 """ # 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") # enable primary network, enable WPA2 and disable WPA network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # Assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Change SSID name to 40 characters then check ssid name length new_ssid = "NET_5G215F640000000000000000000001234567" network_page.set_ssid_name(new_ssid) network_page.apply_changes() # check length of ssid name equals maxlen 32 ssid = network_page.get_ssid_name() try: assertion.is_true(ssid != self.SSID, "SSID was changed") assertion.is_equal(len(ssid), 32) finally: #reset wireless configuration radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default()
def test_wps_isenabled(self, setUp): """Check WPS is enabled by default on wifi 2.4Ghz """ assertion = Assert() # 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") # enable primary network network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network and wps are enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') wps = network_page.get_wps() time.sleep(10) assertion.is_true(network_page.is_wps_enabled(wps), 'WPS') # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="5.0GHZ") radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "5 Ghz") # assert wps is enabled network_page = NetworkPage(self.firefox) wps = network_page.get_wps() assertion.is_true(network_page.is_wps_enabled(wps), 'WPS')
def test_defaultkey(self, setUp): """Connect client to DUT wifi 5.0Ghz network with default key """ assertion = Assert() network = conn() # select wireless interface and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="5.0GHZ") radio_page.enable(radio_page.get_wireless()) radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "5 Ghz") wireless = radio_page.get_wireless() assertion.is_true(radio_page.is_enabled(wireless), "Wireless") # enable primary network -> broadcast ssid network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Wifi connection attempt wifi_connection = network.wifi_connection( ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_wificonnected(wifi_connection) except WifiConnError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() 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 ip = '192.168.0.1' 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_open_sec(self, setUp): """Connect station to open wifi network""" 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") # disable WPA2 network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.disable(network_page.get_wpa2()) network_page.apply_changes() # assert WPA2 (therefore WPA too for 3P Box) is disabled assertion.is_true( network_page.is_enabled(network_page.get_primary_network()), 'Primary Network') 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) 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' 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_nmode_off(self, setUp): """WiFi Client can ping gateway's local addr with 802.11 n-mode off""" assertion = Assert() network = conn() # 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.disable(radio_page.get_n_mode()) radio_page.apply_changes() # assert wireless is enabled and interface is 2.4Ghz assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") assertion.is_false(radio_page.is_nmode_enabled(), 'N MODE') wireless = radio_page.get_wireless() assertion.is_true(radio_page.is_enabled(wireless), "Wireless") # enable primary network network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) current_ssid_name = network_page.get_ssid_name() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Get the DUT serial number soft_page = SoftwarePage(self.firefox) dut_serial_nb = soft_page.get_serial_number() # Compare digits of dut between serial number and ssid name ser_number_id = dut_serial_nb[-6:] # last 6 digits of serial number first_half = current_ssid_name[:6] # first 6 digits of ssid name last_half = current_ssid_name[-6:] # last 6 digits of ssid name try: assertion.is_equal(first_half, "NET_2G") assertion.is_equal(last_half, ser_number_id) except WebElementError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() raise # Wifi connection attempt connection_attempt = network.wifi_connection(ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_sucessful(connection_attempt, 'connection attempt') except NetworkError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() 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' 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_name) self.reset_wifisession(self.firefox, self.SSID)
def test_ssid_newname(self, setUp): """Check DUT disconnects connected client after ssid name change """ 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 network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) 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') # 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 # Change SSID name to 'NET_2G215F64NEWSSIDNAME' new_ssid = "{0}NEWSSIDNAME".format(self.SSID) network_page.set_ssid_name(new_ssid) network_page.apply_changes() # Assert SSID was changed ssid = network_page.get_ssid_name() try: assertion.is_equal(ssid, new_ssid) except WebElementError: # reset wireless configuration self.reset_wifisession(self.firefox, self.SSID) raise # Check if WS still connected time.sleep(20) connection_status = network.ssid_isconnected(ssid=self.SSID) try: assertion.is_false(connection_status, 'client online') except Exception: self.reset_wifisession(self.firefox, self.SSID) raise # Connect to the DUT with new ssid name NET_2G215F64NEWSSIDNAME conn_attempt = network.wifi_connection(ssid=new_ssid, pswd=self.SSID_PASS) try: assertion.is_true(conn_attempt, "connection attempt") finally: network.delete_wifi_profile(ssid=new_ssid) self.reset_wifisession(self.firefox, self.SSID)
def common_channel(self, band=None, channel=None): """Connect client to band and channel provided""" network = conn() assertion = Assert() # select wireless interface and bandwidth and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="5.0GHZ") radio_page.enable(radio_page.get_wireless()) radio_page.select_bandwidth(band) radio_page.set_channel(channel) radio_page.apply_changes() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "5 Ghz") wireless = radio_page.get_wireless() assertion.is_true(radio_page.is_enabled(wireless), "Wireless Enabled") assertion.is_equal(radio_page.get_bandwidth(), band) assertion.is_equal(radio_page.get_channel(), channel) # enable primary network network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Wifi connection attempt time.sleep(120) # DUT needs time to apply channel changes wifi_connection = network.wifi_connection(ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_wificonnected(wifi_connection) except WifiConnError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() 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 ip = '192.168.0.1' 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 common_channel(self, band=None, channel=None, url='192.168.0.1'): """Base test channel test runner""" network = conn() assertion = Assert() # select wireless interface and bandwidth 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.select_bandwidth(band) radio_page.set_channel(channel) 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") assertion.is_equal(radio_page.get_bandwidth(), band) assertion.is_equal(radio_page.get_channel(), channel) # enable primary network network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.apply_changes() # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Wifi connection attempt connection_attempt = network.wifi_connection( ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_sucessful(connection_attempt, 'connection attempt') except NetworkError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() 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 time.sleep(5) wifi_iface = network.wifi_iface_name() # get name of wifi iface ping_attempt = network.ping_attempt(wifi_iface, url) time.sleep(5) 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)
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_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 common_bandwidth(self, band=None): """Test Bandwidth""" assertion = Assert() network = conn() # select wireless interface and bandwidth and enable wireless radio_page = RadioPage(self.firefox) radio_page.select_wifi_interface(iface="2.4GHZ") radio_page.enable_wireless() radio_page.select_bandwidth(band) radio_page.apply_changes() radio_page.refresh_page() # assert wireless and bandwidth assertion.is_equal(radio_page.get_wifi_interface(), "2.4 Ghz") assertion.is_equal(radio_page.wireless_isenabled(), "Enabled") assertion.is_equal(radio_page.get_bandwidth(), band) # enable primary network and wpa2 network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) # check primary network and wpa2 are 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') # wifi connection attempt time.sleep(5) wifi_connection = network.wifi_connection(ssid=self.SSID, pswd=self.SSID_PASS) assertion.is_wificonnected(wifi_connection) # Disconnect wired interface eth_iface = network.eth_iface_name() # get name of 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 wifi_iface = network.wifi_iface_name() # get name of wifi iface 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_iface) self.reset_wifisession(self.firefox, self.SSID)
def test_ping_100(self, setUp): """Wlan host ping Gateway LAN IP with 100% success""" assertion = Assert() network = conn() # 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 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 network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) # assert primary network is enabled netwrk = network_page.get_primary_network() assertion.is_true(network_page.is_enabled(netwrk), 'Primary Network') # Wifi connection attempt connection_attempt = network.wifi_connection(ssid=self.SSID, pswd=self.SSID_PASS, timeout=20) try: assertion.is_sucessful(connection_attempt, 'connection attempt') except NetworkError: # reset changes radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() 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 # 10 Ping attempt to get 100% of success time.sleep(3) wifi_iface = network.wifi_iface_name() # get wifi iface name DUT_default_IP = '192.168.0.1' ping_attempt = network.ping_attempt_100(wifi_iface, DUT_default_IP, count=10) try: assertion.is_sucessful(ping_attempt, 'ping attempt') finally: # reconfigure network interfaces to original settings network.connect_iface(eth_name) 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_open_security(self, setUp): """Connect client to open wifi network""" """ select wifi 5.0ghz and set to enabled """ assertion = Assert() network = conn() self.firefox.get("http://192.168.0.1/wlanRadio.asp") wifi_5_iface = self.firefox.find_element_by_css_selector( "select[name*='WirelessMacAddress']>option[value*='0']") wifi_5_iface.click() ssid_enable = self.firefox.find_element_by_css_selector( "select[name*='WirelessEnable']>option[value*='1']") ssid_enable.click() apply_btn = self.firefox.find_element_by_css_selector( "input[onclick*='commitRadio()']") apply_btn.click() """ assert ssid is enabled """ try: ssid_enable = WebDriverWait(self.firefox, 10).until( EC.presence_of_element_located( (By.CSS_SELECTOR, "select[name*='WirelessEnable']>option[selected='']"))) finally: assertion.is_equal(ssid_enable.text, 'Enabled') """ assert wifi 5.0ghz interface is selected """ self.firefox.get('http://192.168.0.1/wlanPrimaryNetwork.asp') wifi_5_iface = self.firefox.find_element_by_css_selector( "form[name*='wlanPrimaryNetwork'] > table > tbody > tr:nth-child(1) > td" ) selected_iface = wifi_5_iface.text assertion.is_equal(selected_iface[:6], 'NET_5G') """ Disable security """ self.firefox.get('http://192.168.0.1/wlanPrimaryNetwork.asp') wpa2_selector = self.firefox.find_element_by_css_selector( "select[name*='Wpa2PskAuth']>option[value*='0']") wpa2_selector.click() apply_btn = self.firefox.find_element_by_css_selector( "input[value*='Apply']") apply_btn.click() """ handle popup // click ok button """ self.firefox.switch_to.alert.accept() """ Check encryption is disabled """ time.sleep(5) ck_wap2_disabled = self.firefox.find_element_by_css_selector( "select[name*='Wpa2PskAuth']>option[selected='']") encryp_menu = self.firefox.find_element_by_name('WpaEncryption') try: assertion.is_equal(ck_wap2_disabled.text, 'Disabled') assertion.is_equal(encryp_menu.text, 'Disabled') except AssertionError: print("encryption is not set to open") raise AssertionError """ Wifi connection attempt """ time.sleep(65) network.reset_network_mngr() try: connection_attempt = network.wifi_connection_nosec(ssid=self.SSID, timeout='90') assertion.is_true(connection_attempt, "connection succesful") print("wifi connection established") except AssertionError: print("Connection failed") self.reset_wifisession(self.firefox, self.SSID) raise """ Disconnect wired interface(ethernet) """ eth_name = network.eth_iface_name() disc_wiredconn = network.disconnect_iface(eth_name) assertion.is_true(disc_wiredconn, "disconnection succesful") """ Ping attempt """ print('Ping google.com') wifi_iface = network.wifi_iface_name() try: ping_attempt = network.ping_attempt(wifi_iface, 'www.google.com') assertion.is_true(ping_attempt, "ping succesful") except AssertionError: print("ping failed") raise finally: """ reconnect ethernet and delete wifi profile """ network.connect_iface(eth_name) self.reset_wifisession(self.firefox, self.SSID) time.sleep(60)
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_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_special_pass(self, setUp): """Set custom key with special characters and connect WS to DUT """ assertion = Assert() network = conn() # 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") # enable primary network network_page = NetworkPage(self.firefox) network_page.enable(network_page.get_primary_network()) network_page.enable(network_page.get_wpa2()) network_page.apply_changes() # assert primary network is enabled 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') # set new passphrase "'?/#$%"&*()-+[]}{;:><,.|@ new_pass = """"'?/#$%"&*()-+[]}{;:><,.|@""" network_page.set_password(new_pass) network_page.apply_changes() # assert passphrase was changed time.sleep(2) current_pass = network_page.get_password() assertion.is_equal(current_pass, new_pass) # connect using new passphrase connection_attempt = network.wifi_connection(ssid=self.SSID, pswd=new_pass, timeout=20) try: assertion.is_sucessful(connection_attempt, 'connection attempt') finally: self.reset_wifisession(self.firefox, self.SSID) # set new passphrase çáÁéÉ¡¿ñÑüÅåÄäÖğĞşŞÿóÓíÍúÜ network_page = NetworkPage(self.firefox) new_pass = """çáÁéÉ¡¿ñÑüÅåÄäÖğĞşŞÿóÓíÍúÜ""" network_page.set_password(new_pass) network_page.apply_changes() current_pass = network_page.get_password() try: assertion.not_equal(new_pass, current_pass) except ElementMatchError: radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default() # set new passphrase ÚâÂêÊöØøßÆëËãÃõÕæ network_page = NetworkPage(self.firefox) new_pass = """ÚâÂêÊöØøßÆëËãÃõÕæ""" network_page.set_password(new_pass) network_page.apply_changes() current_pass = network_page.get_password() try: assertion.not_equal(new_pass, current_pass) except ElementMatchError: radio_page = RadioPage(self.firefox) radio_page.reset_wireless_default()