Search in sources :

Example 16 with EntitlementCert

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

the class SubscriptionManagerCLITestScript method verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos.

protected void verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(List<ProductCert> currentProductCerts) {
    if (currentProductCerts == null)
        currentProductCerts = clienttasks.getCurrentProductCerts();
    List<YumRepo> yumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
    int numYumReposProvided = 0;
    for (EntitlementCert entitlementCert : entitlementCerts) {
        for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
            if (contentNamespace.type.equals("yum")) {
                if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
                    numYumReposProvided++;
                    Assert.assertNotNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", contentNamespace.label, yumRepos), "The '" + clienttasks.redhatRepoFile + "' has an entry for contentNamespace label '" + contentNamespace.label + "'.");
                }
            } else {
                // contentNamespace types that are not "yum" should not be included in the redhat.repo file (e.g. "file" and "kickstart")
                Assert.assertNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", contentNamespace.label, yumRepos), "The '" + clienttasks.redhatRepoFile + "' should NOT have an entry for contentNamespace label '" + contentNamespace.label + "' because it's type '" + contentNamespace.type + "' is not equal to 'yum'.");
            }
        }
    }
    if (entitlementCerts.isEmpty()) {
        Assert.assertTrue(yumRepos.isEmpty(), "When there are no entitlement contentNamespaces, then '" + clienttasks.redhatRepoFile + "' should have no yumRepo entries.");
    } else if (numYumReposProvided == 0) {
        Assert.assertTrue(yumRepos.isEmpty(), "When none of the currently installed product certs provideTags matching the currently entitled content namespace requiredTags, then '" + clienttasks.redhatRepoFile + "' should have no yumRepo entries.");
    }
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) YumRepo(rhsm.data.YumRepo)

Example 17 with EntitlementCert

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

the class SubscriptionManagerCLITestScript method getAllEntitlementCertsDataAsListOfLists.

/**
 * @return List of [EntitlementCert entitlementCert]
 */
protected List<List<Object>> getAllEntitlementCertsDataAsListOfLists() throws JSONException, Exception {
    List<List<Object>> ll = new ArrayList<List<Object>>();
    if (!isSetupBeforeSuiteComplete)
        return ll;
    if (clienttasks == null)
        return ll;
    if (sm_clientUsername == null)
        return ll;
    if (sm_clientPassword == null)
        return ll;
    // first make sure we are subscribed to all pools
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    // then assemble a list of all consumed ProductSubscriptions
    for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
        ll.add(Arrays.asList(new Object[] { entitlementCert }));
        // minimize the number of dataProvided rows (useful during automated testcase development)
        if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
            break;
    }
    return ll;
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) JSONObject(org.json.JSONObject)

Example 18 with EntitlementCert

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

the class GoldenTicketTests method testGoldenTicketIsGrantedWhenRegisteredUsingActivationKey.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47903", "RHEL7-96741" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : Org/Environment Level Content Access
workitemId = "RHEL6-47900", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : Org/Environment Level Content Access
workitemId = "RHEL7-85127", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, 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 = "Tier3")
@Test(description = "Verify golden ticket entitlement is granted when system is registered using an activationkey belonging to an org that has a contentAccessMode set", groups = { "Tier3Tests" }, enabled = true)
public void testGoldenTicketIsGrantedWhenRegisteredUsingActivationKey() throws JSONException, Exception {
    // verify registering the system to activation key belonging to owner(contentAccessmode set) with auto-attach false has access to golden ticket
    CandlepinTasks.setAttributeForOrg(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, org, attributeName, attributeValue);
    String activationKeyName = String.format("%s_%s-ActivationKey%s", sm_clientUsername, sm_clientOrg, System.currentTimeMillis());
    Map<String, String> mapActivationKeyRequest = new HashMap<String, String>();
    mapActivationKeyRequest.put("name", activationKeyName);
    mapActivationKeyRequest.put("autoAttach", "false");
    JSONObject jsonActivationKeyRequest = new JSONObject(mapActivationKeyRequest);
    CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/owners/" + org + "/activation_keys", jsonActivationKeyRequest.toString());
    clienttasks.register(null, null, org, null, null, null, null, null, null, null, activationKeyName, null, null, null, true, null, null, null, null, null);
    // verify only the golden entitlement cert granted by org/environment is present
    List<EntitlementCert> entitlementCertsAfterRegisteringToactivationKeyFalse = clienttasks.getCurrentEntitlementCerts();
    Assert.assertTrue(entitlementCertsAfterRegisteringToactivationKeyFalse.size() == 1, "Only extra entitlement granted by the org/environment is present");
    // verify registering the system to activation key belonging to owner (contentAccessmode set) with auto-attach true also has access to golden ticket
    String activationKeyNameTrue = String.format("%s_%s-ActivationKey%s", sm_clientUsername, org, System.currentTimeMillis());
    Map<String, String> mapActivationKeyTrueRequest = new HashMap<String, String>();
    mapActivationKeyTrueRequest.put("name", activationKeyNameTrue);
    mapActivationKeyTrueRequest.put("autoAttach", "true");
    JSONObject jsonActivationKeyTrueRequest = new JSONObject(mapActivationKeyTrueRequest);
    CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/owners/" + org + "/activation_keys", jsonActivationKeyTrueRequest.toString());
    clienttasks.register(null, null, org, null, null, null, null, null, null, null, activationKeyNameTrue, null, null, null, true, null, null, null, null, null);
    // verify the golden entitlement cert granted by org/environment is present along with other ent certs granted by auto-attach process
    Assert.assertTrue(clienttasks.getCurrentEntitlementCerts().size() > 1, "extra entitlement granted by owner is present along with other entitlements attached by auto-attach");
    List<EntitlementCert> extraEntitlementCerts = EntitlementCert.findAllInstancesWithMatchingFieldFromList("poolId", "Not Available", clienttasks.getCurrentEntitlementCerts());
    // verify the golden entitlement cert granted by org/environment is present
    Assert.assertTrue(extraEntitlementCerts.size() == 1, "extra entitlement granted by owner is present along with other entitlements attached by auto-attach");
}
Also used : JSONObject(org.json.JSONObject) EntitlementCert(rhsm.data.EntitlementCert) HashMap(java.util.HashMap) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Example 19 with EntitlementCert

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

the class CertificateTests method testEntitlementCertStatisticsForZeroContentSetEntitlement.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36642", "RHEL7-51453" }, 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 the statistic values reported by the rct stat-cert tool for a zero-content set entitlement", groups = { "Tier2Tests", "blockedByBug-966137" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEntitlementCertStatisticsForZeroContentSetEntitlement() {
    File zeroContentSetEntitlementCertFile = new File("/tmp/zeroContentSetEntitlementCert.pem");
    client.runCommandAndWait("echo \"" + zeroContentSetEntitlementCert.trim() + "\" > " + zeroContentSetEntitlementCertFile);
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(zeroContentSetEntitlementCertFile);
    // [root@jsefler-5 tmp]# rct cat-cert /tmp/8a85f9843ad21fe4013ae6a01d0b5d3c.pem
    // 
    // +-------------------------------------------+
    // Entitlement Certificate
    // +-------------------------------------------+
    // 
    // Certificate:
    // Path: /tmp/8a85f9843ad21fe4013ae6a01d0b5d3c.pem
    // Version: 3.0
    // Serial: 8429484359950764937
    // Start Date: 2012-11-09 05:00:00+00:00
    // End Date: 2013-11-09 04:59:59+00:00
    // Pool ID: Not Available
    // 
    // Subject:
    // CN: 8a85f9843e139e8c013e1e24d82f1ed0
    // 
    // Issuer:
    // C: US
    // CN: Red Hat Candlepin Authority
    // O: Red Hat, Inc.
    // OU: Red Hat Network
    // ST: North Carolina
    // emailAddress: ca-support@redhat.com
    Assert.assertEquals(entitlementCert.id, "8a85f9843e139e8c013e1e24d82f1ed0", "rct cat-cert reports this id.");
    Assert.assertEquals(entitlementCert.issuer, "Red Hat Candlepin Authority", "rct cat-cert reports this issuer.");
    Assert.assertEquals(entitlementCert.contentNamespaces.size(), 0, "rct cat-cert reports this number of Content sets.");
    CertStatistics certStatistics = clienttasks.getCertStatisticsFromCertFile(zeroContentSetEntitlementCertFile);
    // [root@jsefler-5 tmp]# rct stat-cert /tmp/8a85f9843ad21fe4013ae6a01d0b5d3c.pem
    // Type: Entitlement Certificate
    // Version: 3.0
    // DER size: 1891b
    // Subject Key ID size: 20b
    // Content sets: 0
    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, "1891b", "rct stat-cert reports this DER size.");
    // TODO assert something better than not null
    Assert.assertEquals(certStatistics.subjectKeyIdSize, "20b", "rct stat-cert reports this Subject Key ID size.");
    Assert.assertEquals(certStatistics.contentSets, Integer.valueOf(0), "rct stat-cert reports this number of Content sets.");
}
Also used : EntitlementCert(rhsm.data.EntitlementCert) File(java.io.File) CertStatistics(rhsm.data.CertStatistics) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 20 with EntitlementCert

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

the class CertificateTests method testEntitlementCertContainsExpectedOIDs.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20029", "RHEL7-51904" }, 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 = "Make sure the entitlement cert contains all expected OIDs", groups = { "Tier1Tests", "VerifyEntitlementCertContainsExpectedOIDs_Test", "blockedByBug-744259", "blockedByBug-754426", "blockedByBug-962520", "blockedByBug-997970", "blockedByBug-1021581", "blockedByBug-1443693" }, dataProvider = "getAllAvailableSubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEntitlementCertContainsExpectedOIDs(SubscriptionPool pool) throws JSONException, Exception {
    // skip RAM-based subscriptions since they were are not supported on v1 certificates
    if (CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "ram") != null) {
        throw new SkipException("This test is not designed for RAM-based product subscriptions.");
    }
    // skip CORES-based subscriptions since they were are not supported on v1 certificates
    if (CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "cores") != null) {
        throw new SkipException("This test is not designed for CORES-based product subscriptions.");
    }
    // skip physical_only subscriptions when run on a virtual system
    if (CandlepinTasks.isPoolRestrictedToPhysicalSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId) && Boolean.valueOf(clienttasks.getFactValue("virt.is_guest"))) {
        throw new SkipException("This test is not designed for physical_only subscriptions on a virtual machine.");
    }
    // skip virt_only subscriptions when run on a physical system
    if (CandlepinTasks.isPoolRestrictedToVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId) && !Boolean.valueOf(clienttasks.getFactValue("virt.is_guest"))) {
        throw new SkipException("This test is not designed for virt_only subscriptions on a physical machine.");
    }
    // adjust quantity for instance_multiplier pools
    String instance_multiplier = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "instance_multiplier");
    String quantity = null;
    /*if (clienttasks.isPackageVersion("subscription-manager",">=","1.10.3-1"))*/
    if (pool.suggested != null) {
        if (pool.suggested < 1 && instance_multiplier != null) {
            quantity = instance_multiplier;
        }
    }
    // subscribe to the pool and get the EntitlementCert
    // File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool);
    // EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
    // ^ replaced with the following to save logging/assertion time
    SSHCommandResult result = clienttasks.subscribe_(null, null, pool.poolId, null, null, quantity, null, null, null, null, null, null, null);
    if (result.getStderr().startsWith("Too many content sets"))
        throw new SkipException("This test is only designed for system.certificate_version=1.0 compatible subscriptions.");
    // if (result.getStdout().startsWith("Pool is restricted to")) throw new SkipException("This test is not designed for this subscription pool: "+pool);	// Pool is restricted to physical systems: '8a9087e3443db08f01443db1847a142a'.
    EntitlementCert entitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
    Assert.assertNotNull(entitlementCert, "Successfully retrieved the entitlement cert granted after subscribing to pool: " + pool);
    // re-scan the entitlement cert using openssl because it better distinguishes between a "" OID value and a null OID value.
    entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFileUsingOpensslX509(entitlementCert.file);
    // Commented out the following log of rawCertificate to conserve logFile size
    // log.info("Raw entitlement certificate: \n"+entitlementCert.rawCertificate);
    boolean allMandatoryOIDsFound = true;
    // Reference	https://docspace.corp.redhat.com/docs/DOC-30244
    // asserting all expected OIDS in the OrderNamespace
    // 1.3.6.1.4.1.2312.9.4.1 (Name): Red Hat Enterprise Linux Server
    // 1.3.6.1.4.1.2312.9.4.2 (Order Number) : ff8080812c3a2ba8012c3a2cbe63005b
    // 1.3.6.1.4.1.2312.9.4.3 (SKU) : MCT0982
    // 1.3.6.1.4.1.2312.9.4.4 (Subscription Number) : abcd-ef12-1234-5678   <- SHOULD ONLY EXIST IF ORIGINATED FROM A REGTOKEN
    // 1.3.6.1.4.1.2312.9.4.5 (Quantity) : 100
    // 1.3.6.1.4.1.2312.9.4.6 (Entitlement Start Date) : 2010-10-25T04:00:00Z
    // 1.3.6.1.4.1.2312.9.4.7 (Entitlement End Date) : 2011-11-05T00:00:00Z
    // 1.3.6.1.4.1.2312.9.4.8 (Virtualization Limit) : 4						<- ONLY EXISTS WHEN VIRT POOLS ARE TO BE GENERATED
    // 1.3.6.1.4.1.2312.9.4.9 (Socket Limit) : None							<- ONLY EXISTS WHEN THE SUBSCRIPTION IS USED TO SATISFY HARDWARE
    // 1.3.6.1.4.1.2312.9.4.10 (Contract Number): 152341643
    // 1.3.6.1.4.1.2312.9.4.11 (Quantity Used): 4
    // 1.3.6.1.4.1.2312.9.4.12 (Warning Period): 30
    // 1.3.6.1.4.1.2312.9.4.13 (Account Number): 9876543210
    // 1.3.6.1.4.1.2312.9.4.14 (Provides Management): 0 (boolean, 1 for true)<- NEEDINFO
    // 1.3.6.1.4.1.2312.9.4.15 (Support Level): Premium						<- NEEDINFO
    // 1.3.6.1.4.1.2312.9.4.16 (Support Type): Level 3						<- NEEDINFO
    // 1.3.6.1.4.1.2312.9.4.17 (Stacking Id): 23456							<- ONLY EXISTS WHEN SUBSCRIPTION IS STACKABLE
    // 1.3.6.1.4.1.2312.9.4.18 (Virt Only): 1								<- ONLY EXISTS WHEN POOLS ARE INTENTED FOR VIRT MACHINES ONLY
    OrderNamespace orderNamespace = entitlementCert.orderNamespace;
    if (orderNamespace.productName != null) {
        Assert.assertNotNull(orderNamespace.productName, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.1 (Name) is present with value '" + orderNamespace.productName + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.1 (Name) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.orderNumber != null) {
        Assert.assertNotNull(orderNamespace.orderNumber, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.2 (Order Number) is present with value '" + orderNamespace.orderNumber + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.2 (Order Number) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.productId != null) {
        Assert.assertNotNull(orderNamespace.productId, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.3 (SKU) is present with value '" + orderNamespace.productId + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.3 (SKU) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.subscriptionNumber != null) {
        Assert.assertNotNull(orderNamespace.subscriptionNumber, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.4 (Subscription Number) is present with value '" + orderNamespace.subscriptionNumber + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.4 (Subscription Number) is missing");
    }
    if (orderNamespace.quantity != null) {
        Assert.assertNotNull(orderNamespace.quantity, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.5 (Quantity) is present with value '" + orderNamespace.quantity + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.5 (Quantity) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.startDate != null) {
        Assert.assertNotNull(orderNamespace.startDate, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.6 (Entitlement Start Date) is present with value '" + orderNamespace.startDate + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.6 (Entitlement Start Date) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.endDate != null) {
        Assert.assertNotNull(orderNamespace.endDate, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.7 (Entitlement End Date) is present with value '" + orderNamespace.endDate + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.7 (Entitlement End Date) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.virtualizationLimit != null) {
        Assert.assertNotNull(orderNamespace.virtualizationLimit, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.8 (Virtualization Limit) is present with value '" + orderNamespace.virtualizationLimit + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.8 (Virtualization Limit) is missing");
    }
    if (orderNamespace.socketLimit != null) {
        Assert.assertNotNull(orderNamespace.socketLimit, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.9 (Socket Limit) is present with value '" + orderNamespace.socketLimit + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.9 (Socket Limit) is missing");
    }
    // if (orderNamespace.contractNumber!=null)		{Assert.assertNotNull(orderNamespace.contractNumber,		"Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.10 (Contract Number) is present with value '"+ orderNamespace.contractNumber+"'");}			else {log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.10 (Contract Number) is missing"); allMandatoryOIDsFound = false;}
    if (orderNamespace.contractNumber != null) {
        Assert.assertNotNull(orderNamespace.contractNumber, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.10 (Contract Number) is present with value '" + orderNamespace.contractNumber + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.10 (Contract Number) is missing.  This subscription was probably granted to a test account.");
    }
    if (orderNamespace.quantityUsed != null) {
        Assert.assertNotNull(orderNamespace.quantityUsed, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.11 (Quantity Used) is present with value '" + orderNamespace.quantityUsed + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.11 (Quantity Used) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.warningPeriod != null) {
        Assert.assertNotNull(orderNamespace.warningPeriod, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.12 (Warning Period) is present with value '" + orderNamespace.warningPeriod + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.12 (Warning Period) is missing");
        allMandatoryOIDsFound = false;
    }
    // if (orderNamespace.accountNumber!=null)			{Assert.assertNotNull(orderNamespace.accountNumber,			"Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.13 (Account Number) is present with value '"+ orderNamespace.accountNumber+"'");}			else {log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.13 (Account Number) is missing"); allMandatoryOIDsFound = false;}
    if (orderNamespace.accountNumber != null) {
        Assert.assertNotNull(orderNamespace.accountNumber, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.13 (Account Number) is present with value '" + orderNamespace.accountNumber + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.13 (Account Number) is missing.  This subscription was probably granted to a test account.");
    }
    if (orderNamespace.providesManagement != null) {
        Assert.assertNotNull(orderNamespace.providesManagement, "Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.14 (Provides Management) is present with value '" + orderNamespace.providesManagement + "'");
    } else {
        log.warning("Mandatory OrderNamespace OID 1.3.6.1.4.1.2312.9.4.14 (Provides Management) is missing");
        allMandatoryOIDsFound = false;
    }
    if (orderNamespace.supportLevel != null) {
        Assert.assertNotNull(orderNamespace.supportLevel, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.15 (Support Level) is present with value '" + orderNamespace.supportLevel + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.15 (Support Level) is missing");
    }
    if (orderNamespace.supportType != null) {
        Assert.assertNotNull(orderNamespace.supportType, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.16 (Support Type) is present with value '" + orderNamespace.supportType + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.16 (Support Type) is missing");
    }
    if (orderNamespace.stackingId != null) {
        Assert.assertNotNull(orderNamespace.stackingId, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.17 (Stacking Id) is present with value '" + orderNamespace.stackingId + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.17 (Stacking Id) is missing");
    }
    if (orderNamespace.virtOnly != null) {
        Assert.assertNotNull(orderNamespace.virtOnly, "Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.18 (Virt Only) is present with value '" + orderNamespace.virtOnly + "'");
    } else {
        log.warning("Optional OrderNamespace OID 1.3.6.1.4.1.2312.9.4.18 (Virt Only) is missing");
    }
    for (ProductNamespace productNamespace : entitlementCert.productNamespaces) {
        // 1.3.6.1.4.1.2312.9.1.<product_hash>.4 (Provides) : String1, String2, String3
        if (productNamespace.name != null) {
            Assert.assertNotNull(productNamespace.name, "Mandatory ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".1 (Name) is present with value '" + productNamespace.name + "'");
        } else {
            log.warning("Mandatory ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".1 (Name) is missing");
            allMandatoryOIDsFound = false;
        }
        // if (productNamespace.version!=null)			{Assert.assertNotNull(productNamespace.version,			"Mandatory ProductNamespace OID 1.3.6.1.4.1.2312.9.1."+productNamespace.id+".2 (Version) is present with value '"+ productNamespace.version+"'");}		else {log.warning("Mandatory ProductNamespace OID 1.3.6.1.4.1.2312.9.1."+productNamespace.id+".2 (Version) is missing"); allMandatoryOIDsFound = false;}
        if (productNamespace.version != null) {
            Assert.assertNotNull(productNamespace.version, "Optional ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".2 (Version) is present with value '" + productNamespace.version + "'");
        } else {
            log.warning("Optional ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".2 (Version) is missing");
        }
        if (// the TESTDATA imported into a standalone candlepin does not honor the assertion that the product version OID must be blank since rel-eng creates product certs with valid version outside of candlepin
        !sm_serverType.equals(CandlepinType.standalone))
            if (productNamespace.version != null) {
                Assert.assertEquals(productNamespace.version, "", "Optional ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".2 (Version) can be present but must always be blank.");
            }
        if (productNamespace.arch != null) {
            Assert.assertNotNull(productNamespace.arch, "Mandatory ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".3 (Architecture) is present with value '" + productNamespace.arch + "'");
        } else {
            log.warning("Mandatory ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".3 (Architecture) is missing");
            allMandatoryOIDsFound = false;
        }
        if (productNamespace.providedTags != null) {
            Assert.assertNotNull(productNamespace.providedTags, "Optional ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".4 (Provides) is present with value '" + productNamespace.providedTags + "'");
        } else {
            log.warning("Optional ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".4 (Provides) is missing");
        }
        if (productNamespace.providedTags != null) {
            Assert.assertEquals(productNamespace.providedTags, "", "Optional ProductNamespace OID 1.3.6.1.4.1.2312.9.1." + productNamespace.id + ".4 (Provides) can be present but must always be blank.");
        }
    }
    for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
        if (!contentNamespace.type.equalsIgnoreCase("yum"))
            continue;
        // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.10 (Required Tags): TAG1,TAG2,TAG3
        if (contentNamespace.name != null) {
            Assert.assertNotNull(contentNamespace.name, "Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.1 (Name) is present with value '" + contentNamespace.name + "'");
        } else {
            log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.1 (Name) is missing");
            allMandatoryOIDsFound = false;
        }
        if (contentNamespace.label != null) {
            Assert.assertNotNull(contentNamespace.label, "Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.2 (Label) is present with value '" + contentNamespace.label + "'");
        } else {
            log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.2 (Label) is missing");
            allMandatoryOIDsFound = false;
        }
        // REMOVED						//if (contentNamespace.physicalEntitlement!=null)		{Assert.assertNotNull(contentNamespace.physicalEntitlement,		"Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2."+contentNamespace.hash+".1.3 (Physical Entitlements) is present with value '"+ contentNamespace.physicalEntitlement+"'");}	else {log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2."+contentNamespace.hash+".1.3 (Physical Entitlements) is missing"); allMandatoryOIDsFound = false;}
        Assert.assertNull(contentNamespace.physicalEntitlement, "ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.3 (Physical Entitlements) has been removed from the generation of entitlements.  Its current value is '" + contentNamespace.physicalEntitlement + "'");
        // REMOVED blockedByBug-754426	//if (contentNamespace.flexGuestEntitlement!=null)	{Assert.assertNotNull(contentNamespace.flexGuestEntitlement,	"Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2."+contentNamespace.hash+".1.4 (Flex Guest Entitlements) is present with value '"+ contentNamespace.flexGuestEntitlement+"'");}	else {log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2."+contentNamespace.hash+".1.4 (Flex Guest Entitlements) is missing"); allMandatoryOIDsFound = false;}
        Assert.assertNull(contentNamespace.flexGuestEntitlement, "ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.4 (Flex Guest Entitlements) has been removed from the generation of entitlements.  Its current value is '" + contentNamespace.flexGuestEntitlement + "'");
        if (contentNamespace.vendorId != null) {
            Assert.assertNotNull(contentNamespace.vendorId, "Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.5 (Vendor ID) is present with value '" + contentNamespace.vendorId + "'");
        } else {
            log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.5 (Vendor ID) is missing");
            allMandatoryOIDsFound = false;
        }
        if (contentNamespace.downloadUrl != null) {
            Assert.assertNotNull(contentNamespace.downloadUrl, "Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.6 (Download URL) is present with value '" + contentNamespace.downloadUrl + "'");
        } else {
            log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.6 (Download URL) is missing");
            allMandatoryOIDsFound = false;
        }
        // if (contentNamespace.gpgKeyUrl!=null)				{Assert.assertNotNull(contentNamespace.gpgKeyUrl,				"Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2."+contentNamespace.hash+".1.7 (GPG Key URL) is present with value '"+ contentNamespace.gpgKeyUrl+"'");}						else {if ("content-emptygpg".equals(contentNamespace.name)||"content-nogpg".equals(contentNamespace.name)) {log.info("Skipping assertion of Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2."+contentNamespace.hash+".1.7 (GPG Key URL) for negative test content '"+contentNamespace.name+"'");} else {log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2."+contentNamespace.hash+".1.7 (GPG Key URL) is missing"); allMandatoryOIDsFound = false;}}
        if (contentNamespace.gpgKeyUrl != null) {
            Assert.assertNotNull(contentNamespace.gpgKeyUrl, "Optional ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.7 (GPG Key URL) is present with value '" + contentNamespace.gpgKeyUrl + "'");
        } else {
            log.warning("Optional ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.7 (GPG Key URL) is missing");
        }
        if (contentNamespace.enabled != null) {
            Assert.assertNotNull(contentNamespace.enabled, "Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.8 (Enabled) is present with value '" + contentNamespace.enabled + "'");
        } else {
            log.warning("Mandatory ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.8 (Enabled) is missing");
            allMandatoryOIDsFound = false;
        }
        if (contentNamespace.metadataExpire != null) {
            Assert.assertNotNull(contentNamespace.metadataExpire, "Optional ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.9 (Metadata Expire Seconds) is present with value '" + contentNamespace.metadataExpire + "'");
        } else {
            log.warning("Optional ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.9 (Metadata Expire Seconds) is missing");
        }
        if (contentNamespace.requiredTags != null) {
            Assert.assertNotNull(contentNamespace.requiredTags, "Optional ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.10 (Required Tags) is present with value '" + contentNamespace.requiredTags + "'");
        } else {
            log.warning("Optional ContentNamespace OID 1.3.6.1.4.1.2312.9.2." + contentNamespace.hash + ".1.10 (Required Tags) is missing");
        }
    }
    if (!allMandatoryOIDsFound)
        Assert.fail("Could not find all mandatory entitlement cert OIDs. (see warnings above)");
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) OrderNamespace(rhsm.data.OrderNamespace) ProductNamespace(rhsm.data.ProductNamespace) 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