def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % case_name) try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") self.sub_register(username, password) # list the designated service level servicelevel = RHSMConstants().get_constant("servicelevel") cmd = "subscription-manager service-level --list" (ret, output) = self.runcmd(cmd, "list service level") if ret == 0 and servicelevel.lower() in output.lower(): logger.info("It's successful to list the service level %s." % servicelevel) # set correct service level cmd = "subscription-manager service-level --set=%s" % servicelevel (ret, output) = self.runcmd(cmd, "set correct service level") if ret == 0 and "Service level set to: %s" % servicelevel in output: logger.info("It's successful to set correct service level %s." % servicelevel) else: raise FailException("Test Failed - Failed to set correct service level %s." % servicelevel) else: raise FailException("Test Failed - Failed to list the service level %s." % servicelevel) self.assert_(True, case_name) except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name)
"It's successful to verify that system cannot access CDN contents through thumbslug by using plain http" ) else: raise FailException( "Test Failed - failed to verify that system cannot access CDN contents through thumbslug by using plain http" ) # restore rhsm.conf file self.assert_(True, case_name) except Exception, e: logger.error(str(e)) self.assert_(False, case_name) finally: self.uninstall_givenpkg(pkgtoinstall) self.restore_repos() self.restore_conf(RHSMConstants().samhostip) self.restore_environment() logger.info( "=========== End of Running Test Case: %s ===========" % case_name) def register_and_autosubscribe(self, username, password, autosubprod): cmd = "subscription-manager register --username=%s --password=%s --auto-attach" % ( username, password) (ret, output) = self.runcmd(cmd, "register_and_autosubscribe") if (ret == 0) and ("The system has been registered with ID:" in output) and (autosubprod in output) and ("Subscribed" in output): logger.info("It's successful to register and auto-attach") else:
def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % case_name) try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") self.sub_register(username, password) # list availalbe entitlement pools productid = RHSMConstants().get_constant("productid") availpoollist = self.sub_listavailpools(productid) # get an available entitlement pool to subscribe with random.sample availpool = random.sample(availpoollist, 1)[0] if "SubscriptionName" in availpool: poolid = availpool["PoolID"] subscriptionname = availpool["SubscriptionName"] productid = availpool["SKU"] # subscribe the product with poolid cmd = "subscription-manager subscribe --pool=%s" % poolid (ret, output) = self.runcmd(cmd, "subscribe with poolid") expectout = "Successfully consumed a subscription for: %s" % subscriptionname # expectoutnew is for rhel new feature output expectoutnew = "Successfully attached a subscription for: %s" % subscriptionname if 0 == ret and ((expectout in output) or (expectoutnew in output)): logger.info("It's successful to do subscribe to a pool") else: logger.error( "Test Failed - error happened when do subscribe to a pool") # get the entitlement cert name cmd = "ls /etc/pki/entitlement/*.pem | grep -v key.pem" (ret, certname0) = self.runcmd(cmd, "get the entitlement cert name") if (ret == 0) and (certname0 != None): logger.info("It's successful to get the entitlement cert name") certname = certname0.strip('\n') else: raise FailException( "Test Failed - Failed to get the entitlement cert name") # check the syslog for subscribe info cmd = "tail -100 /var/log/rhsm/rhsm.log | grep Deleted -B10 |grep Added -A10 | grep '%s'" % certname (ret, loginfo) = self.runcmd(cmd, "check the syslog for subscribe info") if ret == 0 and loginfo != None: logger.info( "It's successful to check the syslog for subscribe info") else: raise FailException( "Test Failed - Failed to check the syslog for subscribe info" ) # unsubscribe self.sub_unsubscribe() # check the syslog for unsubscribe info cmd = "tail -100 /var/log/rhsm/rhsm.log | grep Deleted -A10 | grep '%s'" % certname (ret, loginfo) = self.runcmd(cmd, "check the syslog for subscribe info") if ret == 0 and loginfo != None: logger.info( "It's successful to check the syslog for unsubscribe info") else: raise FailException( "Test Failed - Failed to check the syslog for unsubscribe info" ) self.assert_(True, case_name) except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name)
def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % case_name) try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") baseurl = RHSMConstants().get_constant("baseurl") prefix = RHSMConstants().get_constant("prefix") baseurl = baseurl + prefix # remove the consumer related files cmd = "rm -rf /etc/pki/consumer*" (ret, output) = self.runcmd( cmd, "remove the consumer related files before testing") if ret == 0: logger.info( "It's successful to remove the consumer related files before testing" ) else: raise FailException( "Test Failed - Failed to remove the consumer related files before testing." ) # register the client self.sub_register(username, password) # check the consumer folder cmd = "ls /etc/pki | grep 'consumer'" (ret, output) = self.runcmd( cmd, "check the consumer folder after registration") if ret == 0 and 'consumer' in output and 'consumer.old' not in output: logger.info( "It's successful to check the consumer folder after registration" ) else: raise FailException( "Test Failed - Failed to check the consumer folder after registration." ) # get consumerid of the client consumerid = self.sub_get_consumerid() # delete the consumer from server side. cmd = "curl -k -u %s:%s --request DELETE %s/consumers/%s" % ( username, password, baseurl, consumerid) (ret, output) = self.runcmd(cmd, "check dependency on python-simplejson") # if ret == 0 and output == '': if ret == 0: logger.info( "It's successful to delete the consumer from server side") else: raise FailException( "Test Failed - Failed to delete the consumer from server side." ) # restart rhsmcert service self.restart_rhsmcertd() # wait 2 mins time.sleep(125) # check if consumer.old exists cmd = "ls /etc/pki/consumer.old" (ret, output) = self.runcmd(cmd, "check if consumer.old exists") if ret == 0 and output != '': logger.info( "It's successful to check that consumer.old exists") else: raise FailException( "Test Failed - Failed to check that consumer.old exists.") # check if consumer folder exists cmd = "ls /etc/pki/consumer" (ret, output) = self.runcmd(cmd, "check if consumer exists") if ret == 0 and output == '': logger.info( "It's successful to check that empty consumer folder exists" ) elif ret != 0 and "ls: cannot access consumer: No such file or directory" in output: logger.info( "It's successful to check that consumer folder does not exist" ) else: raise FailException( "Test Failed - Failed to check that consumer exists.") self.assert_(True, case_name) except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name)
def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % case_name) try: try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") self.open_subscription_manager() self.register_and_autosubscribe_in_gui(username, password) self.click_my_subscriptions_tab() subscribed = self.get_table_cell('main-window', 'my-subscription-table', 0, 0) cert = self.generate_cert() self.sub_unregister() self.close_rhsm_gui() self.open_subscription_manager() self.click_register_button() self.click_dialog_next_button() self.input_username(username) self.input_password(password) self.click_dialog_register_button() self.click_dialog_cancel_button() #import certificate using new interface. RHEL 7 changed it's search dlg and #the search txt box is buggy with ldtp. We will use a system of clicks in finder #to search for new certificate self.click_import_cert_menu() self.select_row_by_name('import-cert-dialog', 'table-places', 'File System') self.select_row_by_name('import-cert-dialog', 'table-files', 'tmp') self.click_button('import-cert-dialog', 'import-file-button') self.select_row_by_name('import-cert-dialog', 'table-files', 'test.pem') self.click_button('import-cert-dialog', 'import-file-button') if self.check_window_open( "information-dialog") and self.check_object_exist( "information-dialog", "import-cert-success-label"): logger.info("SUCCES: Import success prompt displayed!") else: raise FailException("FAILED: Success prompt not found!") #check whether imported certificate has proper productid productid = RHSMConstants().get_constant("productid") self.check_entitlement_cert(productid) self.click_button('information-dialog', 'ok-button') self.click_my_subscriptions_tab() if self.get_my_subscriptions_table_my_subscriptions( ) == subscribed: logger.info( "SUCCESS: My subscription tab matches previous subscription!" ) else: raise FailException( "FAILED: Unable to check subscriptions under my_subscriptions tab!" ) self.assert_(True, case_name) except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name) finally: self.capture_image(case_name) self.restore_gui_environment() logger.info("========== End of Running Test Case: %s ==========" % case_name)
def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % case_name) try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") name249 = 'qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert1234' name250 = 'qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345qwert12345' # register use system name with max characters(249) cmd_register = "subscription-manager register --username=%s --password='******' --name=%s" % ( username, password, name249) (ret, output) = self.runcmd(cmd_register, "register with max system name") if ret == 0 and 'The system has been registered with ID' in output: logger.info("It's successful to register with max system name") else: raise FailException( "Test Failed - error happened when register with max system name" ) # unregister when system has registered using system name with max characters(249) cmd_unregister = "subscription-manager unregister" (ret, output) = self.runcmd( cmd_unregister, "unregister when system has registered using system name with max characters(249)" ) if ret == 0 and 'System has been unregistered' in output: logger.info( "It's successful to unregister after system has registered using system name with max system name" ) else: raise FailException( "Test Failed - error happened when unregister system") # clean client data cmd_clean = "subscription-manager clean" (ret, output) = self.runcmd(cmd_clean, "clean client data") if (ret == 0) and ("All local data removed" in output): logger.info( "It's successful to run subscription-manager clean") else: raise FailException( "Test Failed - error happened when run subscription-manager clean" ) # re-register with max characters(>=250) cmd_register = "subscription-manager register --username=%s --password='******' --name=%s" % ( username, password, name250) (ret, output) = self.runcmd(cmd_register, "register with max characters(>=250)") if (ret != 0) and ( "Name of the unit must be shorter than 250 characters" in output): logger.info( "It's successful to verify that registeration with max characters(>=250) should not succeed" ) else: raise FailException( "Test Failed - error happened when re-register with max characters(>=250)" ) self.sub_register(username, password) autosubprod = RHSMConstants().get_constant("autosubprod") self.sub_autosubscribe(autosubprod) self.assert_(True, case_name) except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name)
def test_run(self): case_name = self.__class__.__name__ logger.info("========== Begin of Running Test Case %s ==========" % case_name) try: username = RHSMConstants().get_constant("username") password = RHSMConstants().get_constant("password") self.sub_register(username, password) # check identity and record the identity information cmd_check = "subscription-manager identity" (ret, output) = self.runcmd(cmd_check, "run subscription-manager identity") identity_info1 = output if ret == 0: logger.info("It's successful to display identity 1 info!") else: raise FailException("Test Failed - Failed to display identity 1 info") # check cert information cmd_check_cert = "stat /etc/pki/consumer/cert.pem | grep -i Modify | awk -F. '{print $1}' | awk '{print $2$3}'| awk -F- '{print $1$2$3}' | awk -F: '{print $1$2$3}'" (ret, output) = self.runcmd(cmd_check_cert, "check consumer certs") if ret == 0: modified_date1 = output logger.info("It's successful to gain the certs information and record the modified time for first time!") else: raise FailException("Test Failed - Failed to display modified info") # regenerate the certs cmd_regenerate = "subscription-manager identity --regenerate --username=%s --password='******' --force" % (username, password) (ret, output) = self.runcmd(cmd_regenerate, "regenerate the identity certs") if ret == 0 and "Identity certificate has been regenerated" in output: logger.info("It's successful to regenerate the identity certs") else: raise FailException("Test Failed - Failed to regenerate the identity certs") # check identity and record the identity information cmd_check = "subscription-manager identity" (ret, output) = self.runcmd(cmd_check, "run subscription-manager identity") identity_info2 = output if ret == 0: logger.info("It's successful to display identity 2 info!") else: raise FailException("Test Failed - Failed to display identity 2 info") # check wether the identity infos are the same if identity_info1 == identity_info2: logger.info("It's successful to verify that the identity infos are the same") else: raise FailException("Test Failed - Failed to verify that the identity infos are the same") # check cert information cmd_check_cert = "stat /etc/pki/consumer/cert.pem | grep -i Modify | awk -F. '{print $1}' | awk '{print $2$3}'| awk -F- '{print $1$2$3}' | awk -F: '{print $1$2$3}'" (ret, output) = self.runcmd(cmd_check_cert, "check consumer certs") if ret == 0: modified_date2 = output logger.info("It's successful to gain the certs information and record the modified time for second time!") else: raise FailException("Test Failed - Failed to display modified info") # check wether the certs are renewed if int(modified_date2) > int(modified_date1): logger.info("It's successful to verify that the certs have been renewed") else: raise FailException("Test Failed - Failed to verify that the certs have been renewed") autosubprod = RHSMConstants().get_constant("autosubprod") self.sub_autosubscribe(autosubprod) self.assert_(True, case_name) except Exception, e: logger.error("Test Failed - ERROR Message:" + str(e)) self.assert_(False, case_name)