use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method subscribeToSubscriptionPool.
/**
* subscribe to the given SubscriptionPool (assumes pool came from the list of available pools)
* @return the newly installed EntitlementCert file to the newly consumed ProductSubscriptions
*/
public File subscribeToSubscriptionPool(SubscriptionPool pool, String quantity, String authenticator, String password, String serverUrl) {
List<ProductSubscription> beforeProductSubscriptions = getCurrentlyConsumedProductSubscriptions();
List<File> beforeEntitlementCertFiles = getCurrentEntitlementCertFiles();
log.info("Subscribing to subscription pool: " + pool);
SSHCommandResult sshCommandResult = subscribe(null, null, pool.poolId, null, null, quantity, null, null, null, null, null, null, null);
// is this pool multi-entitleable?
/* This information is now in the SubscriptionPool itself
boolean isPoolMultiEntitlement = false;
try {
isPoolMultiEntitlement = CandlepinTasks.isPoolProductMultiEntitlement(this.currentlyRegisteredUsername,this.currentlyRegisteredPassword,SubscriptionManagerBaseTestScript.sm_serverUrl,pool.poolId);
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
*/
// get the pool's product "arch" attribute that this subscription pool supports
String poolProductAttributeArch = "";
List<String> poolProductAttributeArches = new ArrayList<String>();
if (authenticator != null && password != null && serverUrl != null) {
try {
poolProductAttributeArch = CandlepinTasks.getPoolProductAttributeValue(authenticator, password, serverUrl, pool.poolId, "arch");
if (poolProductAttributeArch != null && !poolProductAttributeArch.trim().isEmpty()) {
// Note: the arch attribute can be a comma separated list of values
poolProductAttributeArches.addAll(Arrays.asList(poolProductAttributeArch.trim().split(" *, *")));
// Note: x86 is a general arch to cover all 32-bit intel microprocessors
if (poolProductAttributeArches.contains("x86"))
poolProductAttributeArches.addAll(Arrays.asList("i386", "i486", "i586", "i686"));
// if (productSupportedArches.contains("ALL")) productSupportedArches.add(arch);
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
// assert that the remaining SubscriptionPools does NOT contain the pool just subscribed to (unless it is multi-entitleable)
List<SubscriptionPool> afterSubscriptionPools = getCurrentlyAvailableSubscriptionPools();
if (pool.subscriptionType != null && pool.subscriptionType.equals("Other")) {
Assert.fail("Encountered a subscription pool of type '" + pool.subscriptionType + "'. Do not know how to assert the remaining availability of this pool after subscribing to it: " + pool);
} else if (pool.multiEntitlement == null && pool.subscriptionType != null && pool.subscriptionType.isEmpty()) {
log.warning("Encountered a pool with an empty value for subscriptionType (indicative of an older candlepin server): " + pool);
log.warning("Skipping assertion of the pool's expected availability after having subscribed to it.");
} else if (!pool.quantity.equalsIgnoreCase("unlimited") && Integer.valueOf(pool.quantity) <= 1) {
Assert.assertTrue(!afterSubscriptionPools.contains(pool), "When the final quantity from the pool was consumed, the remaining available subscription pools no longer contains the just subscribed to pool: " + pool);
} else if (pool.multiEntitlement != null && !pool.multiEntitlement) {
Assert.assertTrue(!afterSubscriptionPools.contains(pool), "When the pool is not multi-entitleable, the remaining available subscription pools no longer contains the just subscribed to pool: " + pool);
} else if (pool.subscriptionType != null && (!pool.subscriptionType.equals("Stackable") && !pool.subscriptionType.equals("Multi-Entitleable") && !pool.subscriptionType.equals("Instance Based") && !pool.subscriptionType.equals("Stackable (Temporary)") && !pool.subscriptionType.equals("Multi-Entitleable (Temporary)") && !pool.subscriptionType.equals("Instance Based (Temporary)"))) {
// see https://bugzilla.redhat.com/show_bug.cgi?id=1029968#c2
Assert.assertTrue(!afterSubscriptionPools.contains(pool), "When the pool is not multi-entitleable (not Stackable && not Multi-Entitleable && not Instance Based), the remaining available subscription pools no longer contains the just subscribed to pool: " + pool);
} else if (!poolProductAttributeArches.isEmpty() && !poolProductAttributeArches.contains("ALL") && !poolProductAttributeArches.contains(arch)) {
Assert.assertTrue(!afterSubscriptionPools.contains(pool), "When the pools product attribute arch '" + poolProductAttributeArch + "' does not support this system arch '" + arch + "', the remaining available subscription pools should never contain the just subscribed to pool: " + pool);
} else {
Assert.assertTrue(afterSubscriptionPools.contains(pool), // TODO fix the assertions for "if this fails"
"When the pool is multi-entitleable, the remaining available subscription pools still contains the just subscribed to pool: " + pool + " (TODO: if this fails, then we likely attached the final entitlements from the pool)");
}
// assert that the remaining SubscriptionPools do NOT contain the same productId just subscribed to
// log.warning("We will no longer assert that the remaining available pools do not contain the same productId ("+pool.productId+") as the pool that was just subscribed. Reference: https://bugzilla.redhat.com/show_bug.cgi?id=663455");
/*
for (SubscriptionPool afterSubscriptionPool : afterSubscriptionPools) {
Assert.assertTrue(!afterSubscriptionPool.productId.equals(pool.productId),
"This remaining available pool "+afterSubscriptionPool+" does NOT contain the same productId ("+pool.productId+") after subscribing to pool: "+pool);
}
*/
// is this a personal subpool?
String poolProductId = pool.productId;
boolean isSubpool = false;
try {
JSONArray personSubscriptionPoolProductData;
// personSubscriptionPoolProductData = new JSONArray(System.getProperty("sm.person.subscriptionPoolProductData", "<>").replaceAll("<", "[").replaceAll(">", "]")); // hudson parameters use <> instead of []
// hudson JSONArray parameters get surrounded with double quotes that need to be stripped
personSubscriptionPoolProductData = new JSONArray(SubscriptionManagerBaseTestScript.getProperty("sm.person.subscriptionPoolProductData", "[]").replaceFirst("^\"", "").replaceFirst("\"$", "").replaceAll("<", "[").replaceAll(">", "]"));
for (int j = 0; j < personSubscriptionPoolProductData.length(); j++) {
JSONObject poolProductDataAsJSONObject = (JSONObject) personSubscriptionPoolProductData.get(j);
String personProductId = poolProductDataAsJSONObject.getString("personProductId");
JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject.getJSONObject("subPoolProductData");
String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");
if (poolProductId.equals(systemProductId)) {
// special case when pool's productId is really a personal subpool
poolProductId = personProductId;
isSubpool = true;
break;
}
}
} catch (JSONException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
// figure out which entitlement cert file has been newly installed into /etc/pki/entitlement after attempting to subscribe to pool
/* OLD - THIS ALGORITHM BREAKS DOWN WHEN MODIFIER ENTITLEMENTS ARE IN PLAY
File newCertFile = null;
List<File> afterEntitlementCertFiles = getCurrentEntitlementCertFiles();
for (File file : afterEntitlementCertFiles) {
if (!beforeEntitlementCertFiles.contains(file)) {
newCertFile = file; break;
}
}
*/
/* VALID BUT INEFFICIENT
List<File> afterEntitlementCertFiles = getCurrentEntitlementCertFiles();
File newCertFile = null;
Map<BigInteger, SubscriptionPool> map = new HashMap<BigInteger, SubscriptionPool>();
try {
map = getCurrentSerialMapToSubscriptionPools(this.currentAuthenticator,this.currentAuthenticatorPassword);
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
for (BigInteger serial: map.keySet()) {
if (map.get(serial).poolId.equals(pool.poolId)) {
newCertFile = new File(this.entitlementCertDir+"/"+serial+".pem");
break;
}
}
*/
// NOTE: this block of code is somewhat duplicated in getEntitlementCertCorrespondingToSubscribedPool(...)
File newCertFile = null;
List<File> afterEntitlementCertFiles = getCurrentEntitlementCertFiles("-t");
if (authenticator != null && password != null && serverUrl != null) {
for (File entitlementCertFile : afterEntitlementCertFiles) {
if (!beforeEntitlementCertFiles.contains(entitlementCertFile)) {
EntitlementCert entitlementCert = getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
try {
// JSONObject jsonEntitlement = CandlepinTasks.getEntitlementUsingRESTfulAPI(authenticator,password,serverUrl,entitlementCert.id); // is throwing a 500 in stage, but only for qa@redhat.com credentials - I don't know why
JSONObject jsonEntitlement = CandlepinTasks.getEntitlementUsingRESTfulAPI(currentlyRegisteredUsername, currentlyRegisteredPassword, serverUrl, entitlementCert.id);
JSONObject jsonPool = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(authenticator, password, serverUrl, jsonEntitlement.getJSONObject("pool").getString("href")));
if (jsonPool.getString("id").equals(pool.poolId)) {
newCertFile = entitlementCertFile;
break;
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
}
}
// when the pool is already subscribed to...
if (sshCommandResult.getStdout().startsWith("This consumer is already subscribed")) {
// assert that NO new entitlement cert file has been installed in /etc/pki/entitlement
/*Assert.assertNull(newCertFile,
"A new entitlement certificate has NOT been installed after attempting to subscribe to an already subscribed to pool: "+pool);
*/
Assert.assertEquals(beforeEntitlementCertFiles.size(), afterEntitlementCertFiles.size(), "The existing entitlement certificate count remains unchanged after attempting to subscribe to an already subscribed to pool: " + pool);
// find the existing entitlement cert file corresponding to the already subscribed pool
/* ALREADY FOUND USING ALGORITHM ABOVE
EntitlementCert entitlementCert = null;
for (File thisEntitlementCertFile : getCurrentEntitlementCertFiles()) {
EntitlementCert thisEntitlementCert = getEntitlementCertFromEntitlementCertFile(thisEntitlementCertFile);
if (thisEntitlementCert.orderNamespace.productId.equals(poolProductId)) {
entitlementCert = thisEntitlementCert;
break;
}
}
Assert.assertNotNull(entitlementCert, isSubpool?
"Found an already existing Entitlement Cert whose personal productId matches the system productId from the subscription pool: "+pool:
"Found an already existing Entitlement Cert whose productId matches the productId from the subscription pool: "+pool);
newCertFile = getEntitlementCertFileFromEntitlementCert(entitlementCert); // not really new, just already existing
*/
// assert that consumed ProductSubscriptions has NOT changed
List<ProductSubscription> afterProductSubscriptions = getCurrentlyConsumedProductSubscriptions();
Assert.assertTrue(afterProductSubscriptions.size() == beforeProductSubscriptions.size() && afterProductSubscriptions.size() > 0, "The list of currently consumed product subscriptions has not changed (from " + beforeProductSubscriptions.size() + " to " + afterProductSubscriptions.size() + ") since the productId of the pool we are trying to subscribe to is already consumed.");
// when no free entitlements exist... // No entitlements are available from the pool with id '8a90f8143611c33f013611c4797b0456'. // No subscriptions are available from the pool with id '8a90f8303c98703a013c98715ca80494'. Bug 876758
} else if (sshCommandResult.getStdout().startsWith("No entitlements are available") || sshCommandResult.getStdout().startsWith("No subscriptions are available")) {
// assert that the depleted pool Quantity is zero
SubscriptionPool depletedPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("poolId", pool.poolId, getCurrentlyAllAvailableSubscriptionPools());
/* behavior changed on list --all --available (3/4/2011)
Assert.assertNotNull(depletedPool,
"Found the depleted pool amongst --all --available after having consumed all of its available entitlements: ");
*/
Assert.assertNull(depletedPool, "Should no longer find the depleted pool amongst --all --available after having consumed all of its available entitlements: ");
// "Asserting the pool's quantity after having consumed all of its available entitlements is zero.");
if (authenticator != null && password != null && serverUrl != null) {
JSONObject jsonPool = null;
int consumed = 0;
int quantityAvailable = Integer.valueOf(pool.quantity);
try {
jsonPool = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(authenticator, password, serverUrl, "/pools/" + pool.poolId));
consumed = jsonPool.getInt("consumed");
quantityAvailable = jsonPool.getInt("quantity");
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
Assert.assertEquals(consumed, quantityAvailable, "Asserting the pool's consumed attribute equals it's total quantity after having consumed all of its available entitlements.");
}
// assert that NO new entitlement cert file has been installed in /etc/pki/entitlement
Assert.assertNull(newCertFile, "A new entitlement certificate has NOT been installed after attempting to subscribe to depleted pool: " + depletedPool);
Assert.assertEquals(beforeEntitlementCertFiles.size(), afterEntitlementCertFiles.size(), "The existing entitlement certificate count remains unchanged after attempting to subscribe to depleted pool: " + depletedPool);
// otherwise, the pool is NOT already subscribe to...
} else {
// assert that only ONE new entitlement cert file has been installed in /etc/pki/entitlement
// https://bugzilla.redhat.com/show_bug.cgi?id=640338
Assert.assertTrue(afterEntitlementCertFiles.size() == beforeEntitlementCertFiles.size() + 1, "Only ONE new entitlement certificate has been installed (count was '" + beforeEntitlementCertFiles.size() + "'; is now '" + afterEntitlementCertFiles.size() + "') after subscribing to pool: " + pool);
if (authenticator != null && password != null && serverUrl != null) {
// assert the new entitlement cert file has been installed in /etc/pki/entitlement
Assert.assertNotNull(newCertFile, "A new entitlement certificate has been installed after subscribing to pool: " + pool);
log.info("The new entitlement certificate file is: " + newCertFile);
// assert that the productId from the pool matches the entitlement productId
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=650278 - jsefler 11/05/2010
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=806986 - jsefler 06/28/2012
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId1 = "650278";
String bugId2 = "806986";
try {
if (invokeWorkaroundWhileBugIsOpen && (BzChecker.getInstance().isBugOpen(bugId1) || BzChecker.getInstance().isBugOpen(bugId2))) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId1).toString() + " Bugzilla " + bugId1 + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId1 + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId1);
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId2).toString() + " Bugzilla " + bugId2 + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId2 + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId2);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("Skipping assert that the productId from the pool matches the entitlement productId");
} else {
// END OF WORKAROUND
EntitlementCert entitlementCert = getEntitlementCertFromEntitlementCertFile(newCertFile);
File newCertKeyFile = getEntitlementCertKeyFileFromEntitlementCert(entitlementCert);
Assert.assertEquals(entitlementCert.orderNamespace.productId, poolProductId, isSubpool ? "New EntitlementCert productId '" + entitlementCert.orderNamespace.productId + "' matches originating Personal SubscriptionPool productId '" + poolProductId + "' after subscribing to the subpool." : "New EntitlementCert productId '" + entitlementCert.orderNamespace.productId + "' matches originating SubscriptionPool productId '" + poolProductId + "' after subscribing to the pool.");
Assert.assertTrue(RemoteFileTasks.testExists(sshCommandRunner, newCertFile.getPath()), "New EntitlementCert file exists after subscribing to SubscriptionPool '" + pool.poolId + "'.");
Assert.assertTrue(RemoteFileTasks.testExists(sshCommandRunner, newCertKeyFile.getPath()), "New EntitlementCert key file exists after subscribing to SubscriptionPool '" + pool.poolId + "'.");
}
}
// assert that consumed ProductSubscriptions has NOT decreased
List<ProductSubscription> afterProductSubscriptions = getCurrentlyConsumedProductSubscriptions();
// this assertion was valid prior to bug Bug 801187 - collapse list of provided products for subscription-manager list --consumed
// Assert.assertTrue(afterProductSubscriptions.size() >= beforeProductSubscriptions.size() && afterProductSubscriptions.size() > 0,
// "The list of currently consumed product subscriptions has increased (from "+beforeProductSubscriptions.size()+" to "+afterProductSubscriptions.size()+"), or has remained the same after subscribing (using poolID="+pool.poolId+") to pool: "+pool+" Note: The list of consumed product subscriptions can remain the same when all the products from this subscription pool are a subset of those from a previously subscribed pool.");
Assert.assertTrue(afterProductSubscriptions.size() == beforeProductSubscriptions.size() + 1, "The list of currently consumed product subscriptions has increased by 1 (from " + beforeProductSubscriptions.size() + " to " + afterProductSubscriptions.size() + "), after subscribing to pool: " + pool);
}
return newCertFile;
}
use of rhsm.data.EntitlementCert 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.EntitlementCert in project rhsm-qe by RedHatQE.
the class BugzillaTests method testEnableAndDisableCertV3.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@Test(description = "verify if refresh Pools w/ Auto-Create Owner Fails", groups = { "Tier3Tests", "EnableAndDisableCertV3", "blockedByBug-919700" }, enabled = false)
public void testEnableAndDisableCertV3() throws JSONException, Exception {
String version = null;
servertasks.updateConfFileParameter("candlepin.enable_cert_v3", "false");
servertasks.restartTomcat();
SubscriptionManagerCLITestScript.sleep(1 * 60 * 1000);
clienttasks.restart_rhsmcertd(null, null, null);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
for (EntitlementCert Cert : clienttasks.getCurrentEntitlementCerts()) {
version = Cert.version;
if (version.equals("1.0")) {
Assert.assertEquals(version, "1.0");
} else {
servertasks.updateConfFileParameter("candlepin.enable_cert_v3", "true");
servertasks.restartTomcat();
Assert.fail();
}
}
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
servertasks.updateConfFileParameter("candlepin.enable_cert_v3", "true");
servertasks.restartTomcat();
clienttasks.restart_rhsmcertd(null, null, null);
SubscriptionManagerCLITestScript.sleep(1 * 60 * 1000);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, null, null, null, null, null);
for (EntitlementCert Cert : clienttasks.getCurrentEntitlementCerts()) {
version = Cert.version;
Assert.assertEquals(version, "3.2");
}
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class BugzillaTests method testEntitlementStartDate.
/**
* @author skallesh
* @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-21946", "RHEL7-51808" }, 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 Entitlement Start Dates is the Subscription Start Date", groups = { "Tier3Tests", "VerifyEntitlementStartDate_Test", "blockedByBug-670831" }, enabled = true)
public void testEntitlementStartDate() 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);
for (SubscriptionPool pool : getRandomSubsetOfList(clienttasks.getCurrentlyAvailableSubscriptionPools(), 5)) {
JSONObject jsonPool = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/pools/" + pool.poolId));
Calendar subStartDate = parseISO8601DateString(jsonPool.getString("startDate"), "GMT");
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(clienttasks.subscribeToSubscriptionPool_(pool));
Calendar entStartDate = entitlementCert.validityNotBefore;
Assert.assertTrue(entStartDate.compareTo(subStartDate) == 0, "" + "The entitlement start date granted from pool '" + pool.poolId + "' (" + pool.productId + ") in '" + entitlementCert.file + "', '" + OrderNamespace.formatDateString(entStartDate) + "', " + "should match json start date '" + jsonPool.getString("startDate") + "' of the subscription pool it came from.");
}
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class BugzillaTests method getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists.
protected List<List<Object>> getPackageFromEnabledRepoAndSubscriptionPoolDataAsListOfLists() 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;
// get the currently installed product certs to be used when checking
// for conditional content tagging
List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
// assure we are freshly registered and process all available
// subscription pools
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
File entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (!contentNamespace.type.equalsIgnoreCase("yum"))
continue;
if (contentNamespace.enabled && clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
String repoLabel = contentNamespace.label;
// find an available package that is uniquely provided by
// repo
String pkg = clienttasks.findUniqueAvailablePackageFromRepo(repoLabel);
if (pkg == null) {
log.warning("Could NOT find a unique available package from repo '" + repoLabel + "' after subscribing to SubscriptionPool: " + pool);
}
ll.add(Arrays.asList(new Object[] { pkg, repoLabel, pool }));
}
}
clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
// testcase development)
if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")))
break;
}
return ll;
}
Aggregations