Search in sources :

Example 56 with ProductCert

use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.

the class CertificateTests method getVerifyBaseRHELProductCertVersionFromEachCDNReleaseVersion_TestDataAsListOfLists.

protected List<List<Object>> getVerifyBaseRHELProductCertVersionFromEachCDNReleaseVersion_TestDataAsListOfLists() {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (clienttasks == null)
        return ll;
    // unregister
    clienttasks.unregister(null, null, null, null);
    // get the currently installed RHEL product cert
    ProductCert rhelProductCert = clienttasks.getCurrentRhelProductCert();
    // rhel product cert cannot be subscribed if a rhel product cert is not installed
    if (rhelProductCert == null)
        throw new SkipException("Failed to find an installed RHEL product cert.");
    // register with autosubscribe
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
    // find the autosubscribed entitlement that provides access to RHEL content
    List<EntitlementCert> rhelEntitlementCerts = clienttasks.getEntitlementCertsProvidingProductCert(rhelProductCert);
    if (rhelEntitlementCerts.isEmpty()) {
        log.warning("Could not find an entitlement to a RHEL subscription.");
        return ll;
    }
    // EntitlementCert rhelEntitlementCert = clienttasks.getEntitlementCertsProvidingProductCert(rhelProductCert).get(0);
    EntitlementCert rhelEntitlementCert = rhelEntitlementCerts.get(0);
    // get the cacert file
    File caCertFile = new File(clienttasks.getConfParameter("repo_ca_cert"));
    // get the baseurl
    String baseurl = clienttasks.getConfParameter("baseurl");
    // get the repo url to the currently enabled base RHEL repo (assume it ends in /6/$releasever/$basearch/os
    // get the list of currently enabled repos
    // [root@jsefler-os6 ~]# subscription-manager repos --list-enabled
    // +----------------------------------------------------------+
    // Available Repositories in /etc/yum.repos.d/redhat.repo
    // +----------------------------------------------------------+
    // Repo ID:   rhel-6-server-rpms
    // Repo Name: Red Hat Enterprise Linux 6 Server (RPMs)
    // Repo URL:  https://cdn.redhat.com/content/dist/rhel/server/6/$releasever/$basearch/os
    // Enabled:   1
    // [root@amd-dinar-01 ~]# subscription-manager repos --list-enabled
    // +----------------------------------------------------------+
    // Available Repositories in /etc/yum.repos.d/redhat.repo
    // +----------------------------------------------------------+
    // Repo ID:   rhel-rs-for-rhel-7-server-eus-rpms
    // Repo Name: Red Hat Enterprise Linux Resilient Storage (for RHEL 7 Server) - Extended Update Support (RPMs)
    // Repo URL:  https://cdn.redhat.com/content/eus/rhel/server/7/$releasever/$basearch/resilientstorage/os
    // Enabled:   1
    // 
    // Repo ID:   rhel-ha-for-rhel-7-server-eus-rpms
    // Repo Name: Red Hat Enterprise Linux High Availability (for RHEL 7 Server) - Extended Update Support (RPMs)
    // Repo URL:  https://cdn.redhat.com/content/eus/rhel/server/7/$releasever/$basearch/highavailability/os
    // Enabled:   1
    // 
    // Repo ID:   rhel-7-server-eus-rpms
    // Repo Name: Red Hat Enterprise Linux 7 Server - Extended Update Support (RPMs)
    // Repo URL:  https://cdn.redhat.com/content/eus/rhel/server/7/$releasever/$basearch/os
    // Enabled:   1
    // 
    // Repo ID:   rhel-7-server-rpms
    // Repo Name: Red Hat Enterprise Linux 7 Server (RPMs)
    // Repo URL:  https://cdn.redhat.com/content/dist/rhel/server/7/$releasever/$basearch/os
    // Enabled:   1
    // RHEL-ALT Repos:
    // Product 419 aarch64 Repo rhel-7-for-arm-64-rpms        URL: https://cdn.redhat.com/content/dist/rhel-alt/server/7/$releasever/armv8-a/$basearch/os
    // Product 420 ppc64le Repo rhel-7-for-power-9-rpms       URL: https://cdn.redhat.com/content/dist/rhel-alt/server/7/$releasever/power9/$basearch/os
    // Product 434 s390x   Repo rhel-7-for-system-z-a-rpms	   URL: https://cdn.redhat.com/content/dist/rhel-alt/server/7/$releasever/system-z-a/$basearch/os
    String rhelRepoUrl = null;
    for (Repo enabledRepo : Repo.parse(clienttasks.repos(null, true, false, (String) null, (String) null, null, null, null, null).getStdout())) {
        if (enabledRepo.enabled) {
            // if (enabledRepo.repoUrl.endsWith(clienttasks.redhatReleaseX+"/$releasever/$basearch/os")) {	// does not match the RHEL-ALT repos
            if (enabledRepo.repoUrl.matches(baseurl + "([\\w/-]+)*/" + clienttasks.redhatReleaseX + "/\\$releasever/([\\w/-]+/)*\\$basearch/os")) {
                // skip Extended Update Support repos
                if (enabledRepo.repoUrl.contains("/eus/"))
                    continue;
                if (rhelRepoUrl != null && !rhelRepoUrl.equals(enabledRepo.repoUrl)) {
                    Assert.fail("Excluding EUS, encountered multiple enabled repos that appear to serve the base RHEL content.  Did not expect this:\n " + rhelRepoUrl + "\n " + enabledRepo.repoUrl);
                }
                rhelRepoUrl = enabledRepo.repoUrl;
            }
        }
    }
    // add each available release as a row to the dataProvider
    for (String release : clienttasks.getCurrentlyAvailableReleases(null, null, null, null)) {
        List<String> bugIds = new ArrayList<String>();
        // https://pp.engineering.redhat.com/pp/product/rhel/overview
        if (release.startsWith("6")) {
            // Bug 1214856 - cdn.redhat.com has the wrong productId version for rhel 6.2 and 6.4
            if (release.equals("6.2"))
                bugIds.add("1214856");
            // Bug 1214856 - cdn.redhat.com has the wrong productId version for rhel 6.2 and 6.4
            if (release.equals("6.4"))
                bugIds.add("1214856");
            // Bug 1559114 - cdn.redhat.com has the wrong productId version for many variants/arches of RHEL 6.2 and 6.4
            if (release.equals("6.2") && clienttasks.variant.equals("Server") && clienttasks.arch.matches("i386|ppc64|s390x"))
                bugIds.add("1559114");
            // Bug 1559114 - cdn.redhat.com has the wrong productId version for many variants/arches of RHEL 6.2 and 6.4
            if (release.equals("6.4") && clienttasks.variant.equals("Server") && clienttasks.arch.matches("i386|ppc64|s390x"))
                bugIds.add("1559114");
            // Bug 1559114 - cdn.redhat.com has the wrong productId version for many variants/arches of RHEL 6.2 and 6.4
            if (release.equals("6.2") && clienttasks.variant.matches("Workstation|Client|ComputeNode"))
                bugIds.add("1559114");
            // Bug 1559114 - cdn.redhat.com has the wrong productId version for many variants/arches of RHEL 6.2 and 6.4
            if (release.equals("6.4") && clienttasks.variant.matches("Workstation|Client|ComputeNode"))
                bugIds.add("1559114");
            // Bug 1302409 - cdn.redhat.com has the wrong productId version for rhel 6.6
            if (release.equals("6.6") && clienttasks.variant.matches("Client|Server") && clienttasks.arch.matches("i\\d86"))
                bugIds.add("1302409");
        }
        if (release.startsWith("7")) {
            // Bug 1261163 - uncertain of expected release listing on rhel72 arm system
            if (release.equals("7.2") && clienttasks.arch.equals("aarch64"))
                bugIds.add("1261163");
            // Bug 1441281 - production CDN productid files 404: Not Found. for ARM releasever 7.2
            if (release.equals("7.2") && clienttasks.arch.equals("aarch64"))
                bugIds.add("1441281");
            // Bug 1261171 - uncertain of expected release listing on rhel72 ppc64le system
            if (release.equals("7.2") && clienttasks.arch.equals("ppc64le"))
                bugIds.add("1261171");
            // Bug 1267732 - production CDN productid files 404: Not Found. for ComputeNode releasever 7.1 and 7Server
            if (release.equals("7.2") && clienttasks.variant.equals("ComputeNode") && release.equals("7.1"))
                bugIds.add("1267732");
            // Bug 1267732 - production CDN productid files 404: Not Found. for ComputeNode releasever 7.1 and 7Server
            if (release.equals("7.2") && clienttasks.variant.equals("ComputeNode") && release.equals("7ComputeNode"))
                bugIds.add("1267732");
            // Bug 1338857 - cdn.redhat.com has the wrong productId version for rhel 7.2
            if (!release.matches("7.0|7.1") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("x86_64"))
                bugIds.add("1338857");
            // Bug 1356738 - cdn.redhat.com has the wrong repodata/productId version at server/7/7.2/s390x and server/7/7Server/s390x
            if (!release.matches("7.0|7.1") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("s390x"))
                bugIds.add("1356738");
            // Bug 1356740 - cdn.redhat.com has the wrong repodata/productId version at server/7/7.2/ppc64 and server/7/7Server/ppc64
            if (!release.matches("7.0|7.1") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64"))
                bugIds.add("1356740");
            // Bug 1356710 - cdn.redhat.com has the wrong repodata/productId version at workstation/7/7.2 and workstation/7/7Workstation
            if (!release.matches("7.0|7.1") && clienttasks.variant.equals("Workstation") && clienttasks.arch.equals("x86_64"))
                bugIds.add("1356710");
            // Bug 1356722 - cdn.redhat.com has the wrong repodata/productId version at computenode/7/7.2 and computenode/7/7ComputeNode
            if (!release.matches("7.0|7.1") && clienttasks.variant.equals("ComputeNode") && clienttasks.arch.equals("x86_64"))
                bugIds.add("1356722");
            // Bug 1356729 - cdn.redhat.com has the wrong repodata/productId version at client/7/7.2 and client/7/7Client
            if (!release.matches("7.0|7.1") && clienttasks.variant.equals("Client") && clienttasks.arch.equals("x86_64"))
                bugIds.add("1356729");
            // Bug 1351754 - production CDN productid files 404: Not Found. for Power, little endian releasever 7.1, 7.2, and 7Server
            if (release.matches("7.0|7.1|7.2") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("ppc64le"))
                bugIds.add("1351754");
            // Bug 1351800 - production CDN productid files 404: Not Found. for ARM releasever 7.1, 7.2, and 7Server
            if (release.matches("7.*") && clienttasks.variant.equals("Server") && clienttasks.arch.equals("aarch64"))
                bugIds.add("1351800");
        }
        BlockedByBzBug blockedByBzBug = new BlockedByBzBug(bugIds.toArray(new String[] {}));
        // Object blockedByBug, String release, String rhelRepoUrl, File rhelEntitlementCertFile, File caCertFile
        ll.add(Arrays.asList(new Object[] { blockedByBzBug, release, rhelRepoUrl, rhelEntitlementCert.file, caCertFile }));
    }
    return ll;
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) Repo(rhsm.data.Repo) ArrayList(java.util.ArrayList) List(java.util.List) SkipException(org.testng.SkipException) File(java.io.File) BlockedByBzBug(com.redhat.qe.auto.bugzilla.BlockedByBzBug)

Example 57 with ProductCert

use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.

the class CertificateTests method testProductCertsAreV1Certificates.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36643", "RHEL7-51454" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "assert that the rct cat-cert tool reports the currently installed product certs are Certificate: Version: 1.0 (Note: this is not the ProductNamespace.version)", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testProductCertsAreV1Certificates() {
    /* installed product certs only
		List <ProductCert> productCerts = clienttasks.getCurrentProductCerts();
		if (productCerts.isEmpty()) throw new SkipException("No testable product certs are currently installed."); 
		for (ProductCert productCert : productCerts) {
			Assert.assertEquals(productCert.version, "1.0", "The rct cat-cert tool reports this product cert to be a V1 Certificate: "+productCert);
		}
		*/
    /* installed product certs and migration product certs */
    List<List<Object>> productCertFilesData = getProductCertFilesDataAsListOfLists();
    if (productCertFilesData.isEmpty())
        throw new SkipException("No testable product certs are available for this test.");
    for (List<Object> productCertFilesDatum : productCertFilesData) {
        File productCertFile = (File) productCertFilesDatum.get(0);
        ProductCert productCert = clienttasks.getProductCertFromProductCertFile(productCertFile);
        Assert.assertEquals(productCert.version, "1.0", "The rct cat-cert tool reports this product cert to be a V1 Certificate: " + productCert);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 58 with ProductCert

use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.

the class CertificateTests method testBaseRHELProductCertIsInstalled.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20036", "RHEL7-51045" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "Verify that a base product cert corresponding to the /etc/redhat-release is installed", groups = { "Tier1Tests", "blockedByBug-706518", "blockedByBug-844368", "blockedByBug-1104498", "blockedByBug-904193" }, dependsOnMethods = { "testOnlyOneBaseRHELProductCertIsInstalled" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testBaseRHELProductCertIsInstalled() {
    // list the currently installed products
    clienttasks.listInstalledProducts();
    // list the currently installed product certs
    log.info("All installed product certs: ");
    List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
    for (ProductCert productCert : productCerts) {
        log.info(productCert.toString());
    }
    // assert that a product cert is installed that matches our base RHEL release version
    ProductCert rhelProductCert = null;
    if (clienttasks.releasever.equals("5Server") || clienttasks.releasever.equals("6Server")) {
        if (clienttasks.arch.startsWith("ppc")) {
            // ppc ppc64
            // Red Hat Enterprise Linux for IBM POWER
            rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "74", productCerts);
        } else if (clienttasks.arch.startsWith("s390")) {
            // s390 s390x
            // Red Hat Enterprise Linux for IBM System z
            rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "72", productCerts);
        } else {
            // i386 i686 ia64 x86_64
            // Red Hat Enterprise Linux Server
            rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "69", productCerts);
        }
    } else if (clienttasks.releasever.equals("5Client")) {
        // Red Hat Enterprise Linux Desktop
        if (rhelProductCert == null)
            rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "68", productCerts);
        // Red Hat Enterprise Linux Workstation
        if (rhelProductCert == null)
            rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "71", productCerts);
    } else if (clienttasks.releasever.equals("6Client")) {
        // i386 i686 x86_64
        // Red Hat Enterprise Linux Desktop
        rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "68", productCerts);
    } else if (clienttasks.releasever.equals("6Workstation")) {
        // i386 i686 x86_64
        // Red Hat Enterprise Linux Workstation
        rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "71", productCerts);
    } else if (clienttasks.releasever.equals("6ComputeNode")) {
        // i386 i686 x86_64
        // Red Hat Enterprise Linux for Scientific Computing
        rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "76", productCerts);
    }
    if (clienttasks.redhatReleaseX.equals("7")) {
        // rhel-alt-7 is built on kernel-4 ; rhel-7 is built on kernel-3
        if (clienttasks.isPackageVersion("kernel", "==", "4")) {
            // should only be one (tested by VerifyOnlyOneBaseRHELProductCertIsInstalled_Test)
            rhelProductCert = clienttasks.getCurrentProductCerts("rhel-alt-7-.*").get(0);
        } else {
            // should only be one (tested by VerifyOnlyOneBaseRHELProductCertIsInstalled_Test)
            rhelProductCert = clienttasks.getCurrentProductCerts("rhel-7-.*").get(0);
        }
    }
    Assert.assertNotNull(rhelProductCert, "Found an installed product cert that matches the system's base RHEL release version '" + clienttasks.releasever + "' on arch '" + clienttasks.arch + "':");
    log.info(rhelProductCert.toString());
}
Also used : ProductCert(rhsm.data.ProductCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 59 with ProductCert

use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.

the class CertificateTests method testIssuerOfConsumerProductAndEntitlementCerts.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20030", "RHEL7-33093" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "assert that the rct cat-cert tool reports the issuer of consumer/entitlement/product certificates", groups = { "Tier1Tests", "blockedByBug-968364" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testIssuerOfConsumerProductAndEntitlementCerts() throws JSONException, Exception {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
    // assert the issuer of the consumer cert
    Assert.assertNotNull(consumerCert.issuer, "The rct cat-cert tool reports the issuer of the current consumer cert: " + consumerCert);
    if (sm_serverType.equals(CandlepinType.hosted))
        Assert.assertEquals(consumerCert.issuer, "Red Hat Candlepin Authority", "Issuer of the current consumer cert: " + consumerCert.file);
    else if (sm_serverType.equals(CandlepinType.standalone))
        Assert.assertEquals(consumerCert.issuer, sm_serverHostname, "Issuer of the current consumer cert: " + consumerCert.file);
    else
        log.warning("Do not know what value to assert for issuer of the current consumer cert from a candlepin type '" + sm_serverType + "'.");
    consumerCert = null;
    // assert the issuer of a redhat product cert
    for (ProductCert productCert : clienttasks.getCurrentProductCerts()) {
        Assert.assertNotNull(productCert.issuer, "The rct cat-cert tool reports the issuer of the installed product cert: " + productCert);
        if (!productCert.file.getPath().endsWith("_.pem"))
            Assert.assertEquals(productCert.issuer, "Red Hat Entitlement Product Authority", "Issuer of the current installed product cert: " + productCert.file);
    }
    // assert the issuer of an entitlement cert
    List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
    if (entitlementCerts.isEmpty()) {
        List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
        if (pools.isEmpty()) {
            log.warning("Cound not find any available pool.");
            // TEMPORARY WORKAROUND
            if (clienttasks.arch.equals("ppc64le")) {
                boolean invokeWorkaroundWhileBugIsOpen = true;
                // Bug 1156638 - "Red Hat Enterprise Linux for IBM POWER" subscriptions need to provide content for arch "ppc64le"
                String bugId = "1156638";
                try {
                    if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
                        log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
                        SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
                    } else {
                        invokeWorkaroundWhileBugIsOpen = false;
                    }
                } catch (BugzillaAPIException be) {
                /* ignore exception */
                } catch (RuntimeException re) {
                /* ignore exception */
                }
                if (invokeWorkaroundWhileBugIsOpen) {
                    throw new SkipException("Skipping the remainder of this test on arch '" + clienttasks.arch + "' while blocking bug '" + bugId + "' is open.");
                }
            }
            // END OF WORKAROUND
            Assert.fail("Expected at least one available pool.  Maybe all subscriptions available to '" + sm_clientUsername + "' are being utilized.  Maybe all the available pools for this consumer's organization '" + clienttasks.getCurrentlyRegisteredOwnerKey() + "' do not support this systems arch '" + clienttasks.arch + "'.");
        }
        // randomly pick a pool
        SubscriptionPool pool = getRandomListItem(pools);
        clienttasks.subscribeToSubscriptionPool(pool);
        entitlementCerts = clienttasks.getCurrentEntitlementCerts();
    }
    for (EntitlementCert entitlementCert : entitlementCerts) {
        Assert.assertNotNull(entitlementCert.issuer, "The rct cat-cert tool reports the issuer of granted entitlement cert: " + entitlementCert);
        if (sm_serverType.equals(CandlepinType.hosted))
            Assert.assertEquals(entitlementCert.issuer, "Red Hat Candlepin Authority", "Issuer of granted entitlement cert: " + entitlementCert.file);
        else if (sm_serverType.equals(CandlepinType.standalone))
            Assert.assertEquals(entitlementCert.issuer, sm_serverHostname, "Issuer of granted entitlement cert: " + entitlementCert.file);
        else
            log.warning("Do not know what value to assert for issuer of an entitlement cert from a candlepin type '" + sm_serverType + "'.");
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) SubscriptionPool(rhsm.data.SubscriptionPool) ConsumerCert(rhsm.data.ConsumerCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 60 with ProductCert

use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.

the class CertificateTests method testDefaultProductCertVersion.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20037", "RHEL7-51046" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "Verify that default-product cert(s) provided by the redhat-release package for this release are expected (e.g. '6.9 Beta' during Beta/Snapshot composes and '6.9' during RC composes)", // Bug 1318584 - /etc/pki/product-default/*.pem should supply only GA product cert (HTB versus Beta versus GA discussion)
groups = { "Tier1Tests", "blockedByBug-1426759", "blockedByBug-1387101", "blockedByBug-1327016", "blockedByBug-1198931", "blockedByBug-1538957" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testDefaultProductCertVersion() {
    if (polarionPlannedIn.equalsIgnoreCase("None"))
        throw new SkipException("No automation property value for 'polarion.planned_in' was supplied to assert that the expected '" + clienttasks.productCertDefaultDir + "' cert(s) version was supplied.");
    // predict the expected product cert version based on the polarion.planned_in property
    // 7.5
    String expectedProductCertVersion = clienttasks.redhatReleaseXY;
    // possible PlannedIn values: "RHEL 7.5" "7.5 Pre-testing" "7.5 Internal Devel Freeze" "7.5 Alpha" "7.5 Beta" "7.5 Snap1"..."7.5 Snap5" "7.5 RC" "7.5 Launch"
    if (!polarionPlannedIn.toLowerCase().contains("RC".toLowerCase())) {
        // "7.5 Beta"
        expectedProductCertVersion += " Beta";
    }
    boolean productDefaultCertTested = false;
    // due to the implementation of Bug 1123029 - [RFE] Use default product certificates when they are present
    for (ProductCert productDefaultCert : clienttasks.getProductCerts(clienttasks.productCertDefaultDir)) {
        // Red Hat Enterprise Linux 6 Server HTB
        if (productDefaultCert.productId.equals("135"))
            expectedProductCertVersion = clienttasks.redhatReleaseXY + " HTB";
        // Red Hat Enterprise Linux 6 Workstation HTB
        if (productDefaultCert.productId.equals("155"))
            expectedProductCertVersion = clienttasks.redhatReleaseXY + " HTB";
        // Red Hat Enterprise Linux 7 Server High Touch Beta
        if (productDefaultCert.productId.equals("230"))
            expectedProductCertVersion = clienttasks.redhatReleaseXY + " HTB";
        // Red Hat Enterprise Linux 7 Workstation High Touch Beta
        if (productDefaultCert.productId.equals("231"))
            expectedProductCertVersion = clienttasks.redhatReleaseXY + " HTB";
        // log what package provides the productDefaultCert
        SSHCommandResult result = client.runCommandAndWait("rpm -q --whatprovides " + productDefaultCert.file.getPath());
        // assert that the Version of the /etc/pki/product-default/*.pem cert matches the expected value
        Assert.assertEquals(productDefaultCert.productNamespace.version, expectedProductCertVersion, "The version of the default product cert (provided by '" + result.getStdout().trim() + "') for this RHEL compose.");
        productDefaultCertTested = true;
    }
    // skip this test if there was no default-product installed
    if (!productDefaultCertTested)
        throw new SkipException("Did not find a default product cert in '" + clienttasks.productCertDefaultDir + "' therefore we cannot assert the expected default product certs' Version.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

ProductCert (rhsm.data.ProductCert)90 Test (org.testng.annotations.Test)60 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)54 SkipException (org.testng.SkipException)44 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)40 ArrayList (java.util.ArrayList)40 File (java.io.File)26 SubscriptionPool (rhsm.data.SubscriptionPool)24 EntitlementCert (rhsm.data.EntitlementCert)23 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)22 InstalledProduct (rhsm.data.InstalledProduct)21 JSONObject (org.json.JSONObject)19 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)17 List (java.util.List)16 ContentNamespace (rhsm.data.ContentNamespace)15 HashSet (java.util.HashSet)13 Calendar (java.util.Calendar)7 HashMap (java.util.HashMap)7 BigInteger (java.math.BigInteger)6 JSONArray (org.json.JSONArray)6