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)
Example #3
0
    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_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()