use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testAutoSubscribeAgainAssertingServiceLevelIsPersisted.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21861", "RHEL7-51724" }, 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 = "subscription-manager: after autosubscribing with a service level, assert that another autosubscribe (without specifying service level) uses the service level persisted from the first sutosubscribe", groups = { "Tier3Tests", "blockedByBug-859652", "blockedByBug-977321" }, dependsOnMethods = {}, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testAutoSubscribeAgainAssertingServiceLevelIsPersisted() throws JSONException, Exception {
// Reference: https://engineering.redhat.com/trac/Entitlement/wiki/SlaSubscribe
// get all the valid service levels available to this org
List<String> serviceLevelsExpected = CandlepinTasks.getServiceLevelsForOrgKey(/*sm_serverAdminUsername*/
sm_clientUsername, /*sm_serverAdminPassword*/
sm_clientPassword, sm_serverUrl, sm_clientOrg);
String serviceLevel = serviceLevelsExpected.get(randomGenerator.nextInt(serviceLevelsExpected.size()));
// clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, serviceLevel, null, (String)null, null, false, null, null, null);
testAutoSubscribeWithServiceLevel(null, serviceLevel);
// return all entitlements
clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
// autosubscribe again without specifying a service level
clienttasks.subscribe(true, null, (String) null, (String) null, (String) null, null, null, null, null, null, null, null, null);
// get the current consumer object and assert that the serviceLevel persisted even though the subscribe did NOT specify a service level
Assert.assertEquals(clienttasks.getCurrentServiceLevel(), serviceLevel, "The call to subscribe with auto (without specifying a servicelevel) did not alter current servicelevel.");
// assert that each of the autosubscribed entitlements come from a pool that supports the original service level
for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
// tolerate entitlements granted from pools with null/no support_level regardless of the specified service level
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO ">" is technically correct*/
"2.0.2-1")) {
// commit 9cefb6e23baefcc4ee2e14423f205edd37eecf22 // Bug 1223560 - Service levels on an activation key prevent custom products from attaching at registration if auto-attach enabled
if (entitlementCert.orderNamespace.supportLevel == null || entitlementCert.orderNamespace.supportLevel.isEmpty()) {
log.warning("Regardless of the consumer's original service level '" + serviceLevel + "', this EntitlementCert provides a support_level of '" + entitlementCert.orderNamespace.supportLevel + "'. (New behavior modification from Bug 1223560)");
continue;
}
}
// tolerate exemptServiceLevels
if (sm_exemptServiceLevelsInUpperCase.contains(entitlementCert.orderNamespace.supportLevel.toUpperCase())) {
log.warning("Regardless of the consumer's original service level '" + serviceLevel + "', this EntitlementCert provides an exempt service level '" + entitlementCert.orderNamespace.supportLevel + "'.");
continue;
}
// CASE SENSITIVE ASSERTION Assert.assertEquals(entitlementCert.orderNamespace.supportLevel, serviceLevel,"This autosubscribed EntitlementCert was filled from a subscription order that provides the original service level '"+serviceLevel+"': "+entitlementCert.orderNamespace);
Assert.assertTrue(entitlementCert.orderNamespace.supportLevel.equalsIgnoreCase(serviceLevel), "Ignoring case, this autosubscribed EntitlementCert was filled from a subscription order that provides the original service level '" + serviceLevel + "': " + entitlementCert.orderNamespace);
}
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testRegisterWithAvailableServiceLevel.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19991", "RHEL7-51023" }, 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 = "subscription-manager: register with autosubscribe while specifying an valid service level; assert the entitlements granted match the requested service level", groups = { "Tier1Tests", "blockedByBug-859652", "blockedByBug-919700" }, // dataProvider="getAllAvailableServiceLevelData", // 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testRegisterWithAvailableServiceLevel(Object bugzilla, String serviceLevel) throws JSONException, Exception {
// Reference: https://engineering.redhat.com/trac/Entitlement/wiki/SlaSubscribe
// register with autosubscribe specifying a valid service level
String consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, serviceLevel, null, (String) null, null, null, null, true, null, null, null, null, null));
// get the current consumer object and assert that the serviceLevel persisted
JSONObject jsonConsumer = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerId));
Assert.assertEquals(jsonConsumer.get("serviceLevel"), serviceLevel, "The call to register with autosubscribe and a servicelevel persisted the servicelevel setting on the current consumer object.");
// assert that each of the autosubscribed entitlements come from a pool that supports the specified service level
clienttasks.listConsumedProductSubscriptions();
for (EntitlementCert entitlementCert : clienttasks.getCurrentEntitlementCerts()) {
// tolerate entitlements granted from pools with null/"" support_level regardless of the specified service level
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO ">" is technically correct*/
"2.0.2-1")) {
// commit 9cefb6e23baefcc4ee2e14423f205edd37eecf22 // Bug 1223560 - Service levels on an activation key prevent custom products from attaching at registration if auto-attach enabled
if (entitlementCert.orderNamespace.supportLevel == null || entitlementCert.orderNamespace.supportLevel.isEmpty()) {
log.warning("Regardless of the consumer's service-level preference '" + jsonConsumer.get("serviceLevel") + "' or the requested service-level '" + serviceLevel + "', this EntitlementCert provides a support_level of '" + entitlementCert.orderNamespace.supportLevel + "'. (New behavior modification from Bug 1223560)");
continue;
}
}
if (sm_exemptServiceLevelsInUpperCase.contains(entitlementCert.orderNamespace.supportLevel.toUpperCase())) {
log.warning("After autosubscribed registration with service level '" + serviceLevel + "', this autosubscribed entitlement provides an exempt service level '" + entitlementCert.orderNamespace.supportLevel + "' from entitled orderNamespace: " + entitlementCert.orderNamespace);
} else {
// CASE SENSITIVE ASSERTION Assert.assertEquals(entitlementCert.orderNamespace.supportLevel, serviceLevel,"This autosubscribed entitlement provides the requested service level '"+serviceLevel+"' from entitled orderNamespace: "+entitlementCert.orderNamespace);
Assert.assertTrue(entitlementCert.orderNamespace.supportLevel.equalsIgnoreCase(serviceLevel), "Ignoring case, this autosubscribed entitlement provides the requested service level '" + serviceLevel + "' from entitled orderNamespace: " + entitlementCert.orderNamespace);
}
}
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class UnsubscribeTests method testUnsubscribeFromSerialWhenNotRegistered.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36600", "RHEL7-51408" }, linkedWorkItems = { @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL6-28489", project = Project.RHEL6, role = DefTypes.Role.VERIFIES), @LinkedItem(// RHSM-REQ : subscription-manager cli attaching and removing subscriptions
workitemId = "RHEL7-84911", 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.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "Attempt to unsubscribe from a serial when not registered", groups = { "Tier2Tests", "blockedByBug-735338", "blockedByBug-838146", "blockedByBug-865590", "blockedByBug-873791" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testUnsubscribeFromSerialWhenNotRegistered() {
// first make sure we are subscribed to a pool
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, true, false, null, null, null, null);
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
// random available pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(clienttasks.subscribeToSubscriptionPool(pool, /*sm_serverAdminUsername*/
sm_clientUsername, /*sm_serverAdminPassword*/
sm_clientPassword, sm_serverUrl));
// now remove the consumer cert to simulate an unregister
clienttasks.removeAllCerts(true, false, false);
SSHCommandResult identityResult = clienttasks.identity_(null, null, null, null, null, null, null, null);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit 5697e3af094be921ade01e19e1dfe7b548fb7d5b bug 1119688
Assert.assertEquals(identityResult.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "stderr");
} else {
Assert.assertEquals(identityResult.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "stdout");
}
// now unsubscribe from the serial number (while not registered)
Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().size() > 0, "We should be consuming an entitlement (even while not registered)");
// clienttasks.unsubscribeFromSerialNumber(entitlementCert.serialNumber); // this will assert a different stdout message, instead call unsubscribe manually and assert results
SSHCommandResult result = clienttasks.unsubscribe(null, entitlementCert.serialNumber, null, null, null, null, null);
Assert.assertEquals(result.getStdout().trim(), "Subscription with serial number " + entitlementCert.serialNumber + " removed from this system", "We should always be able to remove a subscription (even while not registered).");
Assert.assertEquals(clienttasks.getCurrentlyConsumedProductSubscriptions().size(), 0, "We should not be consuming any entitlements after unsubscribing (while not registered).");
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class SubscribeTests method testSubscribeToFutureSubscriptionPool.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-27122", "RHEL7-51945" }, 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: subscribe to future subscription pool", groups = { "Tier2Tests", "blockedByBug-979492", "blockedByBug-1440180" }, // dataProvider="getAllFutureSystemSubscriptionPoolsData", // 06/04/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfFutureSystemSubscriptionPoolsData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscribeToFutureSubscriptionPool(SubscriptionPool pool) throws Exception {
// if (!pool.productId.equals("awesomeos-virt-unlmtd-phys")) throw new SkipException("debugTesting pool productId="+pool.productId);
Calendar now = new GregorianCalendar();
now.setTimeInMillis(System.currentTimeMillis());
// subscribe to the future subscription pool
SSHCommandResult subscribeResult = clienttasks.subscribe(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
// Pool is restricted to physical systems: '8a9086d3443c043501443c052aec1298'.
if (subscribeResult.getStdout().startsWith("Pool is restricted")) {
throw new SkipException("Subscribing to this future subscription is not applicable to this test: " + pool);
}
// assert that the granted entitlement cert begins in the future
EntitlementCert entitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
Assert.assertNotNull(entitlementCert, "Found the newly granted EntitlementCert on the client after subscribing to future subscription pool '" + pool.poolId + "'.");
Assert.assertTrue(entitlementCert.validityNotBefore.after(now), "The newly granted EntitlementCert is not valid until the future. EntitlementCert: " + entitlementCert);
Assert.assertTrue(entitlementCert.orderNamespace.startDate.after(now), "The newly granted EntitlementCert's OrderNamespace starts in the future. OrderNamespace: " + entitlementCert.orderNamespace);
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class SubscribeTests method testSubscribeWithQuantity.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19981", "RHEL7-33098" }, 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 = "subscription-manager: subscribe using various good and bad values for the --quantity option", groups = { "Tier1Tests", "blockedByBug-962520" }, dataProvider = "getSubscribeWithQuantityData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscribeWithQuantity(Object meta, SubscriptionPool pool, String quantity, Integer expectedExitCode, String expectedStdoutRegex, String expectedStderrRegex) {
log.info("Testing subscription-manager subscribe using various good and bad values for the --quantity option.");
// special case in the dataProvider to identify when a test pool was not available; expectedStderrRegex contains a message for what kind of test pool was being searched for.
if (pool == null)
throw new SkipException(expectedStderrRegex);
// start fresh by returning all entitlements
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
// for debugging purposes, list what is currently available so we can see the available quantity before we attempt to attach
clienttasks.list_(null, true, null, null, null, null, null, null, null, null, null, null, null, null);
// subscribe with quantity
SSHCommandResult sshCommandResult = clienttasks.subscribe_(null, null, pool.poolId, null, null, quantity, null, null, null, null, null, null, null);
// assert the sshCommandResult here
if (expectedExitCode != null)
Assert.assertEquals(sshCommandResult.getExitCode(), expectedExitCode, "ExitCode after subscribe with quantity=\"" + quantity + "\" option:");
if (expectedStdoutRegex != null)
Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), expectedStdoutRegex, "Stdout after subscribe with --quantity=\"" + quantity + "\" option:");
if (expectedStderrRegex != null)
Assert.assertContainsMatch(sshCommandResult.getStderr().trim(), expectedStderrRegex, "Stderr after subscribe with --quantity=\"" + quantity + "\" option:");
// when successful, assert that the quantity is correctly reported in the list of consumed subscriptions
List<ProductSubscription> subscriptionsConsumed = client1tasks.getCurrentlyConsumedProductSubscriptions();
List<EntitlementCert> entitlementCerts = client1tasks.getCurrentEntitlementCerts();
if (expectedExitCode == 0 && expectedStdoutRegex != null && expectedStdoutRegex.contains("Successful")) {
Assert.assertEquals(entitlementCerts.size(), 1, "One EntitlementCert should have been downloaded to " + client1tasks.hostname + " when the attempt to subscribe is successful.");
Assert.assertEquals(entitlementCerts.get(0).orderNamespace.quantityUsed, quantity.replaceFirst("^\\+", ""), "The quantityUsed in the OrderNamespace of the downloaded EntitlementCert should match the quantity requested when we subscribed to pool '" + pool.poolId + "'. OrderNamespace: " + entitlementCerts.get(0).orderNamespace);
for (ProductSubscription productSubscription : subscriptionsConsumed) {
Assert.assertEquals(productSubscription.quantityUsed, Integer.valueOf(quantity.replaceFirst("^\\+", "")), "The quantityUsed reported in each consumed ProductSubscription should match the quantity requested when we subscribed to pool '" + pool.poolId + "'. ProductSubscription: " + productSubscription);
}
} else {
Assert.assertEquals(subscriptionsConsumed.size(), 0, "No subscriptions should be consumed when the attempt to subscribe is not successful.");
}
}
Aggregations