use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testConsumerUnsubscribedWhenSubscriptionRevoked.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@SuppressWarnings("deprecation")
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21905", "RHEL7-51766" }, 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 = "Consumer unsubscribed when Subscription revoked", groups = { "Tier3Tests", "ConsumerUnsubscribedWhenSubscriptionRevoked", "blockedByBug-947429", "blockedByBug-1555582" }, enabled = true)
@ImplementsNitrateTest(caseId = 56025)
public void testConsumerUnsubscribedWhenSubscriptionRevoked() throws Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
clienttasks.autoheal(null, null, true, null, null, null, null);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
String name, productId;
List<String> providedProductIds = new ArrayList<String>();
name = "Test product to check subscription-removal";
productId = "test-product";
Map<String, String> attributes = new HashMap<String, String>();
attributes.clear();
attributes.put("version", "1.0");
attributes.put("variant", "server");
attributes.put("arch", "ALL");
attributes.put("warning_period", "30");
attributes.put("type", "MKT");
attributes.put("type", "SVC");
File entitlementCertFile = null;
CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, productId);
String resourcePath = "/products/" + productId;
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
resourcePath = "/owners/" + sm_clientOrg + resourcePath;
CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
CandlepinTasks.createProductUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, name + " BITS", productId, 1, attributes, null);
CandlepinTasks.createSubscriptionAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, 20, -1 * 24 * 60, /* 1 day ago */
15 * 24 * 60, /* 15 days from now */
getRandInt(), getRandInt(), productId, providedProductIds, null);
server.runCommandAndWait("rm -rf " + CandlepinTasks.candlepinCRLFile);
for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
if (pool.productId.equals(productId)) {
entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
}
}
Assert.assertNotNull(entitlementCertFile, "Successfully created and subscribed to product subscription '" + productId + "' created by and needed for this test.");
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
List<ProductSubscription> consumedSusbscription = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertFalse(consumedSusbscription.isEmpty());
CandlepinTasks.deleteSubscriptionsAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, sm_clientOrg, productId);
resourcePath = "/products/" + productId;
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.0"))
resourcePath = "/owners/" + sm_clientOrg + resourcePath;
CandlepinTasks.deleteResourceUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, resourcePath);
sleep(2 * /* min */
60 * 1000);
// verify the entitlement serial has been added to the CRL on the server
List<RevokedCert> revokedCerts = servertasks.getCurrentlyRevokedCerts();
RevokedCert revokedCert = RevokedCert.findFirstInstanceWithMatchingFieldFromList("serialNumber", entitlementCert.serialNumber, revokedCerts);
Assert.assertNotNull(revokedCert, "The Certificate Revocation List file on the candlepin server contains an entitlement serial '" + entitlementCert.serialNumber + "' to the product subscription '" + productId + "' that was just deleted on the candlepin server.");
// trigger the rhsmcertd on the system and verify the entitlement has
// been removed
clienttasks.run_rhsmcertd_worker(false);
Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(), "The revoked entitlement has been removed from the system by rhsmcertd.");
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testEmptyReposListForFutureSubscription.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21909", "RHEL7-51770" }, 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 if Repos List is empty for FutureSubscription", groups = { "Tier3Tests", "EmptyReposListForFutureSubscription", "blockedByBug-958775", "blockedByBug-1440180", "blockedByBug-1555582" }, enabled = true)
public void testEmptyReposListForFutureSubscription() throws JSONException, Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
clienttasks.autoheal(null, null, true, null, null, null, null);
String futurePool = createTestPool(60 * 24 * 365, 60 * 24 * (365 * 2), true);
DateFormat yyyy_MM_dd_DateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar nextYear = new GregorianCalendar();
nextYear.add(Calendar.YEAR, 1);
// one day after a year
nextYear.add(Calendar.DATE, 1);
String onDateToTest = yyyy_MM_dd_DateFormat.format(nextYear.getTime());
clienttasks.subscribe(null, null, futurePool, null, null, null, null, null, null, null, null, null, null);
// determine if both active and inactive entitlements are being consumed
boolean activeProductSubscriptionsConsumed = false;
boolean inactiveProductSubscriptionsConsumed = false;
List<ProductSubscription> currentlyConsumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
for (ProductSubscription subscriptions : currentlyConsumedProductSubscriptions) {
if (subscriptions.isActive)
activeProductSubscriptionsConsumed = true;
if (!subscriptions.isActive)
inactiveProductSubscriptionsConsumed = true;
}
if (activeProductSubscriptionsConsumed && inactiveProductSubscriptionsConsumed) {
throw new SkipException("This test assumes that both current and future subscriptions are available on '" + onDateToTest + "' which is determined by the subscriptions loaded on the candlepin server.");
}
Assert.assertTrue(!clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(), "We should still be consuming future entitlements (indicated by Active:False).");
Assert.assertTrue(clienttasks.getCurrentlySubscribedRepos().isEmpty(), "There should not be any entitled repos despite the future attached entitlements (indicated by Active:False).");
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testAutohealWithSLA.
/**
* @author skallesh
* @throws JSONException
* @throws Exception
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21938", "RHEL7-51800" }, 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 healing only attaches with a service-level that is set on the system's preference", groups = { "Tier3Tests", "AutoHealWithSLA", "blockedByBug-907638", "blockedByBug-907400" }, enabled = true)
public void testAutohealWithSLA() throws JSONException, Exception {
/*
* not necessary; will use clienttasks.run_rhsmcertd_worker(true) to
* invoke an immediate autoheal Integer autoAttachInterval = 2;
*/
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
List<String> availableServiceLevelData = clienttasks.getCurrentlyAvailableServiceLevels();
String randomServiceLevel = null;
for (String randomAvailableServiceLevel : getRandomSubsetOfList(availableServiceLevelData, availableServiceLevelData.size())) {
randomServiceLevel = randomAvailableServiceLevel;
clienttasks.subscribe_(true, randomAvailableServiceLevel, (String) null, null, null, null, null, null, null, null, null, null, null);
if (!clienttasks.getCurrentEntitlementCertFiles().isEmpty())
break;
}
if (clienttasks.getCurrentEntitlementCertFiles().isEmpty())
throw new SkipException("Could not find an available SLA that could be used to auto subscribe coverage for an installed product.");
String currentServiceLevel = clienttasks.getCurrentServiceLevel();
Assert.assertEquals(randomServiceLevel, currentServiceLevel, "The current service level should report the same value used during autosubscribe.");
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
clienttasks.autoheal(null, true, null, null, null, null, null);
clienttasks.run_rhsmcertd_worker(true);
List<ProductSubscription> productSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
Assert.assertTrue(!productSubscriptions.isEmpty(), "Autoheal with serviceLevel '" + currentServiceLevel + "' has granted this system some entitlement coverage.");
for (ProductSubscription productSubscription : productSubscriptions) {
// servicelevels api to return exempt service levels
if (!sm_exemptServiceLevelsInUpperCase.contains("Exempt SLA".toUpperCase()))
sm_exemptServiceLevelsInUpperCase.add("Exempt SLA".toUpperCase());
// WORKAROUND for bug 1066088
if (sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase())) {
Assert.assertTrue(sm_exemptServiceLevelsInUpperCase.contains(productSubscription.serviceLevel.toUpperCase()), "Autohealed subscription '" + productSubscription.productName + "' has been granted with an exempt service level '" + productSubscription.serviceLevel + "'.");
} else if ((productSubscription.serviceLevel == null || productSubscription.serviceLevel.isEmpty()) && SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">", "2.0.2-1")) {
log.info("Due to Bug 1223560, Autoheal with serviceLevel '" + currentServiceLevel + "' granted this system coverage from subscription '" + productSubscription.productName + "' which actually has no service level.");
} else {
Assert.assertEquals(productSubscription.serviceLevel, currentServiceLevel, "Autohealed subscription '" + productSubscription.productName + "' has been granted with the expected service level.");
}
}
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testConsumerAccountAndContractIdPresence.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21941", "RHEL7-51803" }, 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 that Consumer Account And Contract Id are Present in the consumed list", groups = { "Tier3Tests", "VerifyConsumerAccountAndContractIdPresence" }, enabled = true)
@ImplementsNitrateTest(caseId = 68738)
public void testConsumerAccountAndContractIdPresence() throws JSONException, Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
for (ProductSubscription consumed : clienttasks.getCurrentlyConsumedProductSubscriptions()) {
Assert.assertNotNull(consumed.accountNumber);
Assert.assertNotNull(consumed.contractNumber);
}
}
use of rhsm.data.ProductSubscription in project rhsm-qe by RedHatQE.
the class BugzillaTests method testRegisterUsingActivationKeyWithExpiredPool.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21924", "RHEL7-51785" }, 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 = "Tier3")
@Test(description = "verify if Registering with an activation key which has run out of susbcriptions results in a system, but no identity certificate", groups = { "Tier3Tests", "RegisterWithActivationKeyWithExpiredPool", "blockedByBug-803814", "blockedByBug-1555582" }, enabled = true)
public void testRegisterUsingActivationKeyWithExpiredPool() throws Exception {
int endingMinutesFromNow = 1;
Integer addQuantity = 1;
String name = String.format("%s_%s-ActivationKey%s", sm_clientUsername, sm_clientOrg, System.currentTimeMillis());
Map<String, String> mapActivationKeyRequest = new HashMap<String, String>();
mapActivationKeyRequest.put("name", name);
mapActivationKeyRequest.put("autoAttach", "false");
JSONObject jsonActivationKeyRequest = new JSONObject(mapActivationKeyRequest);
JSONObject jsonActivationKey = new JSONObject(CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/owners/" + sm_clientOrg + "/activation_keys", jsonActivationKeyRequest.toString()));
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
String consumerId = clienttasks.getCurrentConsumerId();
ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerId);
Calendar endCalendar = new GregorianCalendar();
String expiringPoolId = createTestPool(-60 * 24, endingMinutesFromNow, false);
Calendar c1 = new GregorianCalendar();
endCalendar.add(Calendar.MINUTE, endingMinutesFromNow);
DateFormat yyyy_MM_dd_DateFormat = new SimpleDateFormat("M/d/yy h:mm aaa");
String EndingDate = yyyy_MM_dd_DateFormat.format(endCalendar.getTime());
Calendar c2 = new GregorianCalendar();
sleep(1 * 59 * 1000 - (c2.getTimeInMillis() - c1.getTimeInMillis()));
new JSONObject(CandlepinTasks.postResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/activation_keys/" + jsonActivationKey.getString("id") + "/pools/" + expiringPoolId + (addQuantity == null ? "" : "?quantity=" + addQuantity), null));
clienttasks.unregister(null, null, null, null);
SSHCommandResult registerResult = clienttasks.register_(null, null, sm_clientOrg, null, null, null, null, null, null, null, name, null, null, null, true, null, null, null, null, null);
List<ProductSubscription> consumedResult = clienttasks.getCurrentlyConsumedProductSubscriptions();
SSHCommandResult consumedListResult = clienttasks.list(null, null, true, null, null, null, null, null, null, null, null, null, null, null);
String expected_message = "Unable to attach pool with ID '" + expiringPoolId + "'.: Subscriptions for " + productId + " expired on: " + EndingDate + ".";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.2.0-1")) {
Assert.assertContainsMatch(registerResult.getStderr().trim(), "None of the subscriptions on the activation key were available for attaching.", "stderr");
Assert.assertEquals(consumedListResult.getStdout().trim(), "No consumed subscription pools were found.", "Expired subscription cannot be attached to activationkey");
}
if ((SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">", "0.9.30-1")) && (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, "<", "2.2.0-1"))) {
// Follows:
expected_message = "No activation key was applied successfully.";
// candlepin-0.9.30-1
// //
// https://github.com/candlepin/candlepin/commit/bcb4b8fd8ee009e86fc9a1a20b25f19b3dbe6b2a
Assert.assertEquals(registerResult.getStderr().trim(), expected_message);
Assert.assertEquals(consumedResult.get(randomGenerator.nextInt(consumedResult.size() - 1)).statusDetails.toString(), "[Subscription is expired]", "Attached subscription is in expired state");
}
SSHCommandResult identityResult = clienttasks.identity_(null, null, null, null, null, null, null, null);
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
// post
// commit
// a695ef2d1da882c5f851fde90a24f957b70a63ad
Assert.assertEquals(identityResult.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "stderr");
} else {
Assert.assertEquals(identityResult.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "stdout");
}
}
Aggregations