def _1_real_ap_registration(self): apmanager = properties.apmanager_jid utils.add_xmpp_jid(apmanager) apmanager_path = ("%s%s" % (properties.apmanager_jid, properties.xmppdomain)) #Get the ap's jid ap_jid = utils.get_ap_jid(properties.real_ap_ip) print "AP jid return value is: " + ap_jid ap_jid = ap_jid.strip() utils.add_xmpp_jid(ap_jid) ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username='******', password='******') xmpp_client_filepath = os.path.join(properties.xmpp_client_path, "xmpp_client.conf") print ("Configuring AP %s with apmanager %s" % (properties.real_ap_ip, properties.apmanager_jid)) command = ("cd %s;sed -i 's/XMPP_REGISTER=.*/XMPP_REGISTER='%s'/g' %s" % (properties.xmpp_client_path, apmanager_path, xmpp_client_filepath)) ssh.exec_command(command + ' > /dev/null 2>&1 &') time.sleep(20) #Reboot the AP after changing xmpp_client ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username='******', password='******') print "Rebooting AP." reboot_command = "reboot" ssh.exec_command(reboot_command) time.sleep(180) # Verify if the ap entry is made in the database db.search_ap_in_new_ap_collection(ap_jid) #Enabling wifi on both radios ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username='******', password='******') wifi_cmd_0 = 'uci set wireless.@wifi-device[0].disabled=0' wifi_cmd_1 = 'uci set wireless.@wifi-device[1].disabled=0' wifi_commit_cmd = 'uci commit wireless' wifi_cmd = 'wifi' print "Enabling wifi radios" ssh.exec_command(wifi_cmd_0) ssh.exec_command(wifi_cmd_1) ssh.exec_command(wifi_commit_cmd) ssh.exec_command(wifi_cmd) time.sleep(10)
def onboard_ap(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clicking VAR filter dropdown" dropdown = driver.find_element_by_id("varFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][0]: option.click() time.sleep(5) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) print "Clickin Location dropdown" dropdown = driver.find_element_by_id("locationFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][2]: option.click() time.sleep(5) driver.find_element_by_id("menuAccessPoints").click() driver.find_element_by_id("addBtn").click() driver.find_element_by_id("ap_name").clear() driver.find_element_by_id("ap_name").send_keys(properties.ap_name) driver.find_element_by_id("serial_number").clear() ap_jid = utils.get_ap_jid(properties.real_ap_ip) serial_no = db.search_serialno_in_new_ap_collection(ap_jid.strip()) driver.find_element_by_id("serial_number").send_keys(serial_no) driver.find_element_by_id("addBtn").click() #driver.find_element_by_id("cancelBtn").click() time.sleep(3) db.search_ap_in_ap_collection(ap_jid.strip())
def _1_apply_config(self): """This test case verifies whether config is applied to AP successfully. """ columns = utils.get_var_details() driver = self.driver config_name = self.config_name driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns["email"][1]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns["password"][1]) driver.find_element_by_id("btnLogin").click() time.sleep(10) driver.find_element_by_id("menuAccessPoints").click() time.sleep(5) i = 0 for option in driver.find_elements_by_css_selector("#ap_grid_table tbody tr"): client_name_id = "AP_Name_" + str(i) status_id = "Status_" + str(i) select_checkbox_id = "_" + str(i) if ( properties.ap_name == str(driver.find_element_by_css_selector("#" + client_name_id + " a").get_attribute("innerHTML")) and driver.find_element_by_css_selector("#" + status_id + " img").get_attribute("title") == "available" ): # print "pass" driver.find_element_by_css_selector("#" + select_checkbox_id + " div").click() time.sleep(5) driver.find_element_by_id("applyTemplateBtn").click() j = 0 for option1 in driver.find_elements_by_css_selector("#config_list_table tbody tr"): template_name_id = "Template_name_" + str(j) select_radiobutton_id = "__" + str(j) # print select_radiobutton_id if config_name == driver.find_element_by_id(template_name_id).get_attribute("innerHTML"): driver.find_element_by_css_selector("#" + select_radiobutton_id + " input").click() driver.find_element_by_xpath("//html/body/div[2]/div/div/div/div[2]/div[2]/a").click() # driver.find_element_by_id("btnApply").click() j = j + 1 time.sleep(5) ##Checking for API response message which comes up after applying config to AP. try: actual_message = driver.find_element_by_xpath('//*[@id="deleteSuccessMessage"]').get_attribute( "innerHTML" ) expected_message = "Configuration template change initiated for AP(s)." print "Actual message = " + actual_message print "Expected message = " + expected_message # self.assertEqual(actual_message, expected_message, "Appropriate message '%s' is not displayed" % expected_message) except AssertionError as e: self.verificationErrors.append(str(e)) time.sleep(40) ####Checking for the default config running on AP. ssid = config_name expected_running_config_id = db.search_field_in_configuration_collection("_id", config_name) # Get the ap's jid ap_jid = utils.get_ap_jid(properties.real_ap_ip) print "AP jid return value is: " + ap_jid ap_jid = ap_jid.strip() actual_running_config_id = db.search_field_in_ap_collection("running_config_id", ap_jid) print "Actual running config id of AP is:" + str(actual_running_config_id) print "Expected running config id of AP is:" + str(expected_running_config_id) try: self.assertEqual( str(actual_running_config_id), str(expected_running_config_id), "Expected configuration %s is not running on %s AP." % (ssid, ap_jid), ) except AssertionError as e: self.verificationErrors.append(str(e)) # Verify if radios are enabled on the AP ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username="******", password="******") try: stdin, stdout, stderr = ssh.exec_command("uci show | grep disabled") except SSHException, e: print e data = stdout.readlines() for eachLine in data: if "radio0" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio0 state is: " + radio_state expected_radio_state = "wireless.radio" + "0" + ".disabled=0" print "Expected radio state is: " + expected_radio_state try: self.assertEqual( radio_state.strip(), expected_radio_state, "After applying config to AP Radio0 was not disabled", ) except AssertionError as e: self.verificationErrors.append(str(e)) elif "radio1" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio1 state is: " + radio_state expected_radio_state = "wireless.radio" + "1" + ".disabled=0" print "Expected radio state is: " + expected_radio_state try: self.assertEqual( radio_state.strip(), expected_radio_state, "After applying config to AP Radio1 was not disabled", ) except AssertionError as e: self.verificationErrors.append(str(e)) ###Checking for the SSID running on AP ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username="******", password="******") try: # To get the ssids running on AP (stdin, stdout, stderr) = ssh.exec_command("uci show | grep ssid") except SSHException, e: print e ssid_output = stdout.readlines() result = False cnt = 0 for num, each in enumerate(ssid_output): each = each.replace("\n", "") if cnt == 0: expected_ssid = "wireless.@wifi-iface[%s].ssid=%s" % (cnt, ssid) elif cnt == 1: expected_ssid = "wireless.@wifi-iface[%s].ssid=%s" % (cnt, ssid) cnt = cnt + 1 if expected_ssid == each: result = True print "Expected SSID is:" + expected_ssid print "Actual SSID is:" + each else: result = False print "Expected SSID is:" + expected_ssid print "Actual SSID is:" + each try: self.assertEqual(result, True, "Expected SSID %s is not running on AP." % ssid) except AssertionError as e: self.verificationErrors.append(str(e))
def delete_ap(self): columns = utils.get_var_details() driver = self.driver driver.get(self.base_url + "/home/login") driver.find_element_by_id("email").clear() driver.find_element_by_id("email").send_keys(columns['email'][0]) driver.find_element_by_id("password").clear() driver.find_element_by_id("password").send_keys(columns['password'][0]) driver.find_element_by_id("btnLogin").click() time.sleep(10) print "Clickin Customers dropdown" dropdown = driver.find_element_by_id("customerFilter") for option in dropdown.find_elements_by_tag_name("option"): if option.text == columns['var_business_name'][1]: option.click() time.sleep(5) break else: continue driver.find_element_by_id("menuAccessPoints").click() time.sleep(5) i = 0 for option in driver.find_elements_by_css_selector("#ap_grid_table tbody tr"): client_name_id = "AP_Name_" + str(i) select_checkbox_id = "_" + str(i) if properties.ap_name == str(driver.find_element_by_css_selector("#" + client_name_id + " a").get_attribute('innerHTML')): print "AP Name = " + str(driver.find_element_by_css_selector('#' + client_name_id + ' a').get_attribute('innerHTML')) driver.find_element_by_css_selector("#" + select_checkbox_id + " div").click() time.sleep(5) driver.find_element_by_id("deleteApBtn").click() time.sleep(5) alert_text = driver.find_element_by_id("dialog-confirm").get_attribute("innerHTML") dialog_header = driver.find_element_by_id("ui-id-1").get_attribute("innerHTML").strip() self.assertEqual(dialog_header, "Delete the selected APs", "Delete AP Confirmation dialog not present!") driver.find_element_by_xpath("(//button[@type='button'])[1]").click() print "AP " + properties.ap_name + " deleted successfully!" #Verify if AP was deleted from ap collection db.verify_delete_ap(properties.ap_name) time.sleep(130) ap_jid = utils.get_ap_jid(properties.real_ap_ip) ap_jid = ap_jid.strip() #Verify if AP was added to new_ap collection db.search_ap_in_new_ap_collection(ap_jid) time.sleep(2) #Verify if radios are disabled on the AP ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(properties.real_ap_ip, username='******', password='******') stdin, stdout, stderr = ssh.exec_command("uci show | grep disabled") data = stdout.readlines() for eachLine in data: if "radio0" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio0 state is: " + radio_state expected_radio_state = "wireless.radio" + "0" + ".disabled=1" print "Expected radio state is: " + expected_radio_state self.assertEqual(radio_state.strip(), expected_radio_state, "After deleting AP Radio0 was not disabled") for eachLine in data: if "radio1" in eachLine: radio_line = eachLine.split("\n") radio_state = radio_line[0] print "Actual Radio1 state is: " + radio_state expected_radio_state = "wireless.radio" + "1" + ".disabled=1" print "Expected radio state is: " + expected_radio_state self.assertEqual(radio_state.strip(), expected_radio_state, "After deleting AP Radio1 was not disabled") break else: continue i = i+1