Search in sources :

Example 61 with EntitlementCert

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

the class SubscriptionManagerTasks method unsubscribeFromTheCurrentlyConsumedSerialsCollectively.

/**
 * Collectively unsubscribe from all of the currently consumed serials (in newest to oldest order).
 * This will ultimately issue a single call to unsubscribe --serial SERIAL1 --serial SERIAL2 --serial SERIAL3 (where each serial is listed in reverse order that they were granted).
 *
 * If there are no serials, then unsubscribe --all is called (should effectively do nothing).
 *
 * @return SSHCommandResult result from the call to unsubscribe
 */
public SSHCommandResult unsubscribeFromTheCurrentlyConsumedSerialsCollectively() {
    log.info("Unsubscribing from all of the currently consumed serials in one collective call (in reverse order that they were granted)...");
    List<BigInteger> serials = new ArrayList<BigInteger>();
    // Runtime Error No row with the given identifier exists: [org.candlepin.model.PoolAttribute#8a99f98a46b4fa990146ba9494032318] at org.hibernate.UnresolvableObjectException.throwIfNull:64
    for (File serialPemFile : getCurrentEntitlementCertFiles("-t")) {
        EntitlementCert entitlementCert = getEntitlementCertFromEntitlementCertFile(serialPemFile);
        serials.add(entitlementCert.serialNumber);
    }
    // return unsubscribe --all when no serials are currently consumed
    if (serials.isEmpty())
        return unsubscribe(true, serials, null, null, null, null, null);
    // unsubscribe from all serials collectively
    SSHCommandResult result = unsubscribe(false, serials, null, null, null, null, null);
    Assert.assertTrue(getCurrentlyConsumedProductSubscriptions().size() == 0, "Currently no product subscriptions are consumed.");
    Assert.assertTrue(getCurrentEntitlementCertFiles().size() == 0, "This machine has no entitlement certificate files.");
    return result;
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) File(java.io.File)

Example 62 with EntitlementCert

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

the class BrandingTests method getEligibleBrandNamesFromCurrentEntitlementCerts.

/**
 * @param entitlementCerts TODO
 * @return the eligible brand names based on the current entitlement certs and the currently installed product certs
 */
Set<String> getEligibleBrandNamesFromCurrentEntitlementCerts() {
    // Rules:
    // - eligible brand names come from the currently entitled productNamespaces and are identified by a brandType = "OS"
    // - the corresponding productId must be among the currently installed product certs to be eligible
    Set<String> eligibleInstalledProductIdSet = new HashSet<String>();
    Set<String> eligibleBrandNamesSet = new HashSet<String>();
    List<String> eligibleBrandNamesList = new ArrayList<String>();
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
        for (ProductNamespace productNamespace : entitlementCert.productNamespaces) {
            if (ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", productNamespace.id, currentProductCerts) != null) {
                if (productNamespace.brandType != null) {
                    if (productNamespace.brandType.equals("OS")) {
                        /* THE ORIGINAL FLEX BRANDING IMPLEMENTATION DUAL-PURPOSED THE PRODUCT NAME AS THE SOURCE OF THE BRANDING NAME
							eligibleBrandNamesList.add(productNamespace.name);
							eligibleBrandNamesSet.add(productNamespace.name);
							*/
                        eligibleBrandNamesList.add(productNamespace.brandName);
                        eligibleBrandNamesSet.add(productNamespace.brandName);
                        eligibleInstalledProductIdSet.add(productNamespace.id);
                    }
                }
            }
        }
    }
    if (eligibleBrandNamesList.size() > eligibleBrandNamesSet.size()) {
        log.warning("Currently there are multiple entitled OS brand products by the same name " + eligibleBrandNamesList + ".  This can happen when multiple OS subscriptions have been stacked.");
    }
    if (eligibleInstalledProductIdSet.size() > 1) {
        log.warning("Currently there are multiple entitled OS brand product ids installed " + eligibleInstalledProductIdSet + ".  This is likely caused by a RHEL installation or redhat-release bug.  In this case a warning is logged to " + clienttasks.rhsmLogFile + " and no update is made to the branding file '" + brandingFile + "'.");
        // 2017-10-25 13:56:44,700 [DEBUG] subscription-manager:26339:MainThread @certdirectory.py:217 - Installed product IDs: ['68', '69', '71', '76']
        // 2017-10-25 13:56:44,772 [WARNING] subscription-manager:26339:MainThread @rhelentbranding.py:114 - More than one installed product with RHEL brand information is installed
        eligibleBrandNamesSet.clear();
        // TEMPORARY WORKAROUND
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 1506271 - redhat-release is providing more than 1 variant specific product cert
        String bugId = "1506271";
        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 this test while bug '" + bugId + "' is open.");
        }
    // END OF WORKAROUND
    }
    return eligibleBrandNamesSet;
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException) ProductNamespace(rhsm.data.ProductNamespace) SkipException(org.testng.SkipException) HashSet(java.util.HashSet)

Example 63 with EntitlementCert

use of rhsm.data.EntitlementCert 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 64 with EntitlementCert

use of rhsm.data.EntitlementCert 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 65 with EntitlementCert

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

the class CertificateTests method testEntitlementCertStatistics.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20035", "RHEL7-33079" }, 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 the statistic values reported by the rct stat-cert tool for currently subscribed entitlements", groups = { "Tier1Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEntitlementCertStatistics() {
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
    // get some entitlements!
    clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
    List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
    // loop through all of the current entitlement certs
    if (entitlementCerts.isEmpty())
        throw new SkipException("There are currently no entitlement certs to assert statistics.");
    for (EntitlementCert entitlementCert : entitlementCerts) {
        CertStatistics certStatistics = clienttasks.getCertStatisticsFromCertFile(entitlementCert.file);
        // [root@jsefler-6 ~]# rct stat-cert /etc/pki/entitlement/5254857399115244164.pem
        // Type: Entitlement Certificate
        // Version: 3.0
        // DER size: 947b
        // Subject Key ID size: 20b
        // Content sets: 3
        String expectedDerSize = client.runCommandAndWait("openssl x509 -in " + entitlementCert.file.getPath() + " -outform der -out /tmp/cert.der && du -b /tmp/cert.der | cut -f 1").getStdout().trim();
        expectedDerSize += "b";
        Assert.assertEquals(certStatistics.type, "Entitlement Certificate", "rct stat-cert reports this Type.");
        Assert.assertEquals(certStatistics.version, entitlementCert.version, "rct stat-cert reports this Version.");
        Assert.assertEquals(certStatistics.derSize, expectedDerSize, "rct stat-cert reports this DER size.");
        // TODO assert something better than not null
        Assert.assertNotNull(certStatistics.subjectKeyIdSize, "rct stat-cert reports this Subject Key ID size.");
        Assert.assertEquals(certStatistics.contentSets, Integer.valueOf(entitlementCert.contentNamespaces.size()), "rct stat-cert reports this number of Content sets.");
    }
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) SkipException(org.testng.SkipException) CertStatistics(rhsm.data.CertStatistics) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

EntitlementCert (rhsm.data.EntitlementCert)94 Test (org.testng.annotations.Test)63 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)58 SkipException (org.testng.SkipException)39 ArrayList (java.util.ArrayList)38 File (java.io.File)36 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)35 SubscriptionPool (rhsm.data.SubscriptionPool)33 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)30 JSONObject (org.json.JSONObject)29 ContentNamespace (rhsm.data.ContentNamespace)26 ProductCert (rhsm.data.ProductCert)23 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)17 BigInteger (java.math.BigInteger)17 ProductSubscription (rhsm.data.ProductSubscription)17 List (java.util.List)16 Calendar (java.util.Calendar)11 HashMap (java.util.HashMap)11 ProductNamespace (rhsm.data.ProductNamespace)11 HashSet (java.util.HashSet)8