示例#1
0
 def wait_till_pulp_tasks_finish(connection):
     '''
     wait until there are no running Pulp tasks
     '''
     # will be using pulp-admin, which requires you to log in to it
     # if the Pulp user cert has expired, delete it first of all;
     # if the Pulp user cert doesn't exist, use the one from rhui-manager
     # but create the .pulp directory (with the right perms) if it doesn't exist
     try:
         if Util.cert_expired(connection, "~/.pulp/user-cert.pem"):
             Expect.expect_retval(connection, "rm -f ~/.pulp/user-cert.pem")
     except OSError:
         pass
     rhua = ConMgr.get_rhua_hostname()
     Expect.expect_retval(
         connection, "if ! [ -e ~/.pulp/user-cert.pem ]; then " +
         "mkdir -p -m 700 ~/.pulp; " +
         "ln -s ~/.rhui/%s/user.crt ~/.pulp/user-cert.pem; " % rhua +
         "touch /tmp/pulploginhack; " + "fi")
     while connection.recv_exit_status(
             "pulp-admin tasks list | grep -q '^No tasks found'"):
         time.sleep(15)
     Expect.expect_retval(
         connection, "if [ -f /tmp/pulploginhack ]; then " +
         "rm -f ~/.pulp/user-cert.pem /tmp/pulploginhack; " + "fi")
 def test_13_upload_semi_bad_cert():
     '''
        upload a certificate containing a mix of valid and invalid repos
     '''
     # for RHBZ#1588931 & RHBZ#1584527
     cert = "/tmp/extra_rhui_files/rhcert_partially_invalid.pem"
     if Util.cert_expired(RHUA, cert):
         raise nose.exc.SkipTest(
             "The given certificate has already expired.")
     RHUIManagerEntitlements.upload_rh_certificate(RHUA, cert)
示例#3
0
 def test_28_upload_incompat_cert():
     '''check incompatible certificate handling'''
     cert = "%s/%s" % (DATADIR, CERTS["incompatible"])
     if Util.cert_expired(RHUA, cert):
         raise nose.exc.SkipTest(
             "The given certificate has already expired.")
     try:
         RHUIManagerCLI.cert_upload(RHUA, cert)
     except RuntimeError as err:
         nose.tools.ok_("does not contain any entitlements" in str(err),
                        msg="unexpected error: %s" % err)
 def test_12_upload_incompat_cert():
     '''
        upload an incompatible certificate, expect a proper refusal
     '''
     cert = "/tmp/extra_rhui_files/rhcert_incompatible.pem"
     if Util.cert_expired(RHUA, cert):
         raise nose.exc.SkipTest(
             "The given certificate has already expired.")
     nose.tools.assert_raises(IncompatibleCertificate,
                              RHUIManagerEntitlements.upload_rh_certificate,
                              RHUA, cert)
示例#5
0
 def test_44_upload_empty_cert():
     '''check that an empty certificate is rejected (no traceback)'''
     # for RHBZ#1497028
     cert = "%s/%s" % (DATADIR, CERTS["empty"])
     if Util.cert_expired(RHUA, cert):
         raise nose.exc.SkipTest(
             "The given certificate has already expired.")
     try:
         RHUIManagerCLI.cert_upload(RHUA, cert)
     except RuntimeError as err:
         nose.tools.ok_("does not contain any entitlements" in str(err),
                        msg="unexpected error: %s" % err)
 def test_16_upload_empty_cert():
     '''
        upload a certificate that contains no entitlements
     '''
     # for RHBZ#1497028
     cert = "/tmp/extra_rhui_files/rhcert_empty.pem"
     if Util.cert_expired(RHUA, cert):
         raise nose.exc.SkipTest(
             "The given certificate has already expired.")
     nose.tools.assert_raises(IncompatibleCertificate,
                              RHUIManagerEntitlements.upload_rh_certificate,
                              RHUA, cert)
示例#7
0
 def test_43_upload_semi_bad_cert(self):
     '''check that a partially invalid certificate can still be accepted'''
     # for RHBZ#1588931 & RHBZ#1584527
     # delete currently used certificates and repos first
     RHUIManager.remove_rh_certs(RHUA)
     for repo in CUSTOM_REPOS + self.yum_repo_ids:
         RHUIManagerCLI.repo_delete(RHUA, repo)
     repolist = RHUIManagerCLI.repo_list(RHUA, True)
     nose.tools.ok_(not repolist,
                    msg="can't continue as some repos remain: %s" %
                    repolist)
     # try uploading the cert now
     cert = "%s/%s" % (DATADIR, CERTS["partial"])
     if Util.cert_expired(RHUA, cert):
         raise nose.exc.SkipTest(
             "The given certificate has already expired.")
     RHUIManagerCLI.cert_upload(RHUA, cert)
     # the RHUI log must contain the fact that an invalid path was found in the cert
     Expect.ping_pong(RHUA, "tail /root/.rhui/rhui.log",
                      "Invalid entitlement path")
     RHUIManager.remove_rh_certs(RHUA)