Search in sources :

Example 51 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class FactsTests method testEnablementOfReportPackageProfile.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36609", "RHEL7-59317" }, 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 = "subscription-manager: assert the ability to enable/disable the reporting of the consumers package profile", groups = { "Tier2Tests", "EnablementOfReportPackageProfile_Test", "blockedByBug-905922" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEnablementOfReportPackageProfile() throws JSONException, Exception {
    boolean isPackagesSupported = servertasks.isPackagesSupported(sm_clientUsername, sm_clientPassword, sm_serverUrl);
    String packagesNotSupportedLogMsg = "Server does not support packages, skipping profile upload.";
    String reportPackageProfileOffLogMsg = "Skipping package profile upload due to report_package_profile setting.";
    String rhsmLogMarker;
    SSHCommandResult sshCommandResult;
    // turn on the rhsm.report_package_profile configuration and assert the rhsm logging based on isPackagesSupported on the server during a registration
    sshCommandResult = clienttasks.config(null, null, true, new String[] { "rhsm", "report_package_profile", "1" });
    rhsmLogMarker = System.currentTimeMillis() + " Testing EnablementOfReportPackageProfile_Test during a register...";
    RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, rhsmLogMarker);
    client1tasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, null, null, null, null, null);
    if (isPackagesSupported) {
        Assert.assertTrue(RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, packagesNotSupportedLogMsg).trim().isEmpty(), "When the entitlements server supports package upload, this message should NOT be logged to " + clienttasks.rhsmLogFile + ": " + packagesNotSupportedLogMsg);
        Assert.assertTrue(RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, reportPackageProfileOffLogMsg).trim().isEmpty(), "When the entitlements server supports package upload and rhsm.report_package_profile is turned on , this message should NOT be logged to " + clienttasks.rhsmLogFile + ": " + reportPackageProfileOffLogMsg);
    } else {
        Assert.assertTrue(!RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, packagesNotSupportedLogMsg).trim().isEmpty(), "Regardless of the rhsm.report_package_profile value, when the entitlements server does not support package upload, this expected message is logged to " + clienttasks.rhsmLogFile + ": " + packagesNotSupportedLogMsg);
    }
    // turn off the rhsm.report_package_profile configuration and assert the rhsm logging based on isPackagesSupported on the server during a registration
    sshCommandResult = clienttasks.config(null, null, true, new String[] { "rhsm", "report_package_profile", "0" });
    rhsmLogMarker = System.currentTimeMillis() + " Testing DisablementOfReportPackageProfile_Test during a register...";
    RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, rhsmLogMarker);
    client1tasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, null, null, null, null, null);
    if (isPackagesSupported) {
        Assert.assertTrue(RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, packagesNotSupportedLogMsg).trim().isEmpty(), "When the entitlements server supports package upload, this message should NOT be logged to " + clienttasks.rhsmLogFile + ": " + packagesNotSupportedLogMsg);
        Assert.assertTrue(!RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, reportPackageProfileOffLogMsg).trim().isEmpty(), "When the entitlements server supports package upload and rhsm.report_package_profile is turned off , this expected message should be logged to " + clienttasks.rhsmLogFile + ": " + reportPackageProfileOffLogMsg);
    } else {
        Assert.assertTrue(!RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, rhsmLogMarker, packagesNotSupportedLogMsg).trim().isEmpty(), "Regardless of the rhsm.report_package_profile value, when the entitlements server does not support package upload, message '" + packagesNotSupportedLogMsg + "' is logged to " + clienttasks.rhsmLogFile + ".");
    }
    if (!isPackagesSupported)
        throw new SkipException("Only limited testing of the rhsm.report_package_profile enablement parameter can be achieved when the entitlement server does not support uploading the package profile of a consumer.  This testing should be done against a Katello server.");
// TODO when the server is a katello server that supports packages, we should also test these scenarios
// 1. register with report_package_profile=1 and call http://www.katello.org/apidoc/ GET /api/systems/:id/packages and assert the list matches all the rpms installed
// 2. register with report_package_profile=0 and call http://www.katello.org/apidoc/ GET /api/systems/:id/packages and assert the list is empty
// 3. after registered with report_package_profile=1, add a package and remove a package, call facts update (or rhsm check) and verify GET /api/systems/:id/packages and assert the list matches the new rpms installed
// 4. after registered with report_package_profile=0, add a package and remove a package, call facts update (or rhsm check) and verify GET /api/systems/:id/packages and assert the list was unchanged
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 52 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class FactsTests method testBypassRulesDueToType.

@Test(description = "subscription-manager: facts and rules: bypass rules due to type", groups = { "Tier2Tests", "blockedByBug-641027" }, dependsOnGroups = {}, // 9/17/2013 this test has been disabled in favor of new BypassRulesDueToTypeAndCapabilities_Test
enabled = false)
// cores, ram, instance_multiplier, derived_product
@ImplementsNitrateTest(caseId = 56331)
public void testBypassRulesDueToType() throws Exception {
    // determine which client is a RHEL Workstation
    SSHCommandRunner client = null;
    SubscriptionManagerTasks clienttasks = null;
    if (client1 != null && client1tasks.getRedhatRelease().startsWith("Red Hat Enterprise Linux Workstation")) {
        client = client1;
        clienttasks = client1tasks;
    } else if (client2 != null && client2tasks.getRedhatRelease().startsWith("Red Hat Enterprise Linux Workstation")) {
        client = client2;
        clienttasks = client2tasks;
    } else {
        throw new SkipException("This test requires a Red Hat Enterprise Linux Workstation.");
    }
    // on a RHEL workstation register to candlepin (as type system)
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    // get a list of available pools and all available pools (for this system consumer)
    List<SubscriptionPool> compatiblePoolsAsSystemConsumer = clienttasks.getCurrentlyAvailableSubscriptionPools();
    List<SubscriptionPool> allPoolsAsSystemConsumer = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
    Assert.assertFalse(compatiblePoolsAsSystemConsumer.containsAll(allPoolsAsSystemConsumer), "Without bypassing the rules, not *all* pools are available for subscribing by a type=system consumer.");
    Assert.assertTrue(allPoolsAsSystemConsumer.containsAll(compatiblePoolsAsSystemConsumer), "The pools available to a type=system consumer is a subset of --all --available pools.");
    // now register to candlepin (as type candlepin)
    clienttasks.unregister(null, null, null, null);
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.candlepin, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    // get a list of available pools and all available pools (for this candlepin consumer)
    List<SubscriptionPool> compatiblePoolsAsCandlepinConsumer = clienttasks.getCurrentlyAvailableSubscriptionPools();
    List<SubscriptionPool> allPoolsAsCandlepinConsumer = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
    Assert.assertTrue(compatiblePoolsAsCandlepinConsumer.containsAll(allPoolsAsCandlepinConsumer) && allPoolsAsCandlepinConsumer.containsAll(compatiblePoolsAsCandlepinConsumer), "The pools available to a type=candlepin consumer bypass the rules (list --all --available is identical to list --available).");
    // now assert that all the pools can be subscribed to by the consumer (registered as type candlepin)
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
}
Also used : SSHCommandRunner(com.redhat.qe.tools.SSHCommandRunner) SubscriptionManagerTasks(rhsm.cli.tasks.SubscriptionManagerTasks) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 53 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class CertificateTests method testValidityPeriodInProductCerts.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20033", "RHEL7-33094" }, 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 = "candidate product cert validity dates", groups = { "Tier1Tests" }, dataProvider = "getProductCertFilesData", enabled = true)
@ImplementsNitrateTest(caseId = 64656)
public void testValidityPeriodInProductCerts(File productCertFile) {
    ProductCert productCert = clienttasks.getProductCertFromProductCertFile(productCertFile);
    long actualValidityDurationDays = (productCert.validityNotAfter.getTimeInMillis() - productCert.validityNotBefore.getTimeInMillis()) / (24 * 60 * 60 * 1000);
    log.info("Verifying the validity period in product cert '" + productCertFile + "': " + productCert);
    log.info("The validity period for this product cert is (days): " + actualValidityDurationDays);
    Calendar now = Calendar.getInstance();
    // verify that the validity period for this product cert has already begun.
    Assert.assertTrue(productCert.validityNotBefore.before(now), "This validity period for this product cert has already begun.");
    // verify that the validity period for this product cert has not yet ended.
    Assert.assertTrue(productCert.validityNotAfter.after(now), "This validity period for this product cert has not yet ended.");
    // verify that the validity period for this product cert is among the expected values.
    List<Long> expectedValidityDurationDaysList = new ArrayList<Long>();
    String productCertValidityDuration = sm_productCertValidityDuration;
    for (String expectedValidityDurationDayOption : Arrays.asList(productCertValidityDuration.trim().split(" *, *"))) {
        expectedValidityDurationDaysList.add(Long.valueOf(expectedValidityDurationDayOption));
    }
    log.info("Asserting that the the validity period for this product certificate (" + actualValidityDurationDays + ") spans one of the expected number of days (" + productCertValidityDuration + ")...");
    Assert.assertContains(expectedValidityDurationDaysList, new Long(actualValidityDurationDays));
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) ProductCert(rhsm.data.ProductCert) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 54 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest 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 55 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest 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

ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)267 Test (org.testng.annotations.Test)267 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)244 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)146 SkipException (org.testng.SkipException)125 SubscriptionPool (rhsm.data.SubscriptionPool)71 ArrayList (java.util.ArrayList)62 BigInteger (java.math.BigInteger)53 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)42 ProductSubscription (rhsm.data.ProductSubscription)42 File (java.io.File)36 JSONObject (org.json.JSONObject)33 EntitlementCert (rhsm.data.EntitlementCert)32 ProductCert (rhsm.data.ProductCert)32 InstalledProduct (rhsm.data.InstalledProduct)15 ConsumerCert (rhsm.data.ConsumerCert)14 HashMap (java.util.HashMap)11 Calendar (java.util.Calendar)10 List (java.util.List)10 JSONArray (org.json.JSONArray)8