def test_02_upload_direct_download_certificates(self):
        """Test Upload certificates to KVM hosts for direct download
        """

        # Validate the following
        # 1. Valid certificates are uploaded to hosts
        # 2. Revoke uploaded certificate from host

        cmd = uploadTemplateDirectDownloadCertificate.uploadTemplateDirectDownloadCertificateCmd()
        cmd.hypervisor = self.hypervisor
        cmd.name = "marvin-test-verify-certs" + str(uuid.uuid1())
        cmd.certificate = self.certificates["valid"]
        cmd.zoneid = self.zone.id

        try:
            self.apiclient.uploadTemplateDirectDownloadCertificate(cmd)
        except Exception as e:
            self.fail("Valid certificate must be uploaded")

        revokecmd = revokeTemplateDirectDownloadCertificate.revokeTemplateDirectDownloadCertificateCmd()
        revokecmd.hypervisor = self.hypervisor
        revokecmd.name = cmd.name
        revokecmd.zoneid = self.zone.id

        try:
            self.apiclient.revokeTemplateDirectDownloadCertificate(revokecmd)
        except Exception as e:
            self.fail("Uploaded certificates should be revoked when needed")

        return
    def test_01_sanity_check_on_certificates(self):
        """Test Verify certificates before uploading to KVM hosts
        """

        # Validate the following
        # 1. Invalid certificates cannot be uploaded to hosts for direct downloads
        # 2. Expired certificates cannot be uploaded to hosts for direct downloads

        cmd = uploadTemplateDirectDownloadCertificate.uploadTemplateDirectDownloadCertificateCmd()
        cmd.hypervisor = self.hypervisor
        cmd.name = "marvin-test-verify-certs" + str(uuid.uuid1())
        cmd.certificate = self.certificates["invalid"]
        cmd.zoneid = self.zone.id

        invalid_cert_uploadFails = False
        expired_cert_upload_fails = False
        try:
            self.apiclient.uploadTemplateDirectDownloadCertificate(cmd)
            self.fail("Invalid certificate must not be uploaded")
        except Exception as e:
            invalid_cert_uploadFails = True

        cmd.certificate = self.certificates["expired"]
        try:
            self.apiclient.uploadTemplateDirectDownloadCertificate(cmd)
            self.fail("Expired certificate must not be uploaded")
        except Exception as e:
            expired_cert_upload_fails = True

        self.assertTrue(invalid_cert_uploadFails and expired_cert_upload_fails,
                        "Invalid or expired certificates must not be uploaded")
        return
    def test_02_upload_direct_download_certificates(self):
        """Test Upload certificates to KVM hosts for direct download
        """

        # Validate the following
        # 1. Valid certificates are uploaded to hosts

        cmd = uploadTemplateDirectDownloadCertificate.uploadTemplateDirectDownloadCertificateCmd(
        )
        cmd.hypervisor = self.hypervisor
        cmd.name = "marvin-test-verify-certs"
        cmd.certificate = self.certificates["valid"]

        try:
            self.apiclient.uploadTemplateDirectDownloadCertificate(cmd)
        except Exception as e:
            self.fail("Valid certificate must be uploaded")

        return