use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class BugzillaTests method testSubscribingWithIncorrectFormatForPoolId.
/**
* @author skallesh
* @throws IOException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21958", "RHEL7-51820" }, 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 = "subscription-manager: subscribe multiple pools in incorrect format", groups = { "Tier3Tests", "MysubscribeTest", "blockedByBug-772218" }, enabled = true)
public void testSubscribingWithIncorrectFormatForPoolId() throws IOException {
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);
List<String> poolid = new ArrayList<String>();
for (SubscriptionPool pool : clienttasks.getCurrentlyAllAvailableSubscriptionPools()) {
poolid.add(pool.poolId);
}
if (poolid.isEmpty())
throw new SkipException("Cannot randomly pick a pool for subscribing when there are no available pools for testing.");
int i = randomGenerator.nextInt(poolid.size());
int j = randomGenerator.nextInt(poolid.size());
if (i == j) {
j = randomGenerator.nextInt(poolid.size());
}
SSHCommandResult subscribeResult = subscribeInvalidFormat_(null, null, poolid.get(i), poolid.get(j), null, null, null, null, null, null, null, null);
Assert.assertEquals(subscribeResult.getStdout().trim(), "cannot parse argument: " + poolid.get(j));
}
use of rhsm.data.SubscriptionPool 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.SubscriptionPool in project rhsm-qe by RedHatQE.
the class BugzillaTests method testImportedCertGetsDeletedByRepoCommand.
/**
* @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-21957", "RHEL7-51819" }, 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 subscription-manager repos --list does not delete an imported entitlement certificate on a system", groups = { "Tier3Tests", "VerifyImportedCertgetsDeletedByRepoCommand", "blockedByBug-1160150" }, enabled = true)
public void testImportedCertGetsDeletedByRepoCommand() throws Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, false, null, null, (String) null, null, null, null, true, null, null, null, null, null);
// disable
clienttasks.autoheal(null, null, true, null, null, null, null);
SubscriptionPool pool = getRandomSubsetOfList(clienttasks.getCurrentlyAvailableSubscriptionPools(), 1).get(0);
File importEntitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, sm_clientUsername, sm_clientPassword, sm_serverUrl);
File importEntitlementKeyFile = clienttasks.getEntitlementCertKeyFileCorrespondingToEntitlementCertFile(importEntitlementCertFile);
File importCertificateFile = new File(importCertificatesDir1 + File.separator + importEntitlementCertFile.getName());
List<Repo> subscribedReposBefore = clienttasks.getCurrentlySubscribedRepos();
client.runCommandAndWait("mkdir -p " + importCertificatesDir1);
client.runCommandAndWait("cat " + importEntitlementCertFile + " " + importEntitlementKeyFile + " > " + importCertificateFile);
String path = importCertificateFile.getPath();
clienttasks.clean();
clienttasks.importCertificate(path);
int Ceritificate_countBeforeRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
SSHCommandResult Result = clienttasks.repos_(true, null, null, (String) null, null, null, null, null, null);
int Ceritificate_countAfterRepoCommand = clienttasks.getCurrentEntitlementCertFiles().size();
List<Repo> subscribedReposAfter = clienttasks.getCurrentlySubscribedRepos();
Assert.assertEquals(Ceritificate_countBeforeRepoCommand, Ceritificate_countAfterRepoCommand);
Assert.assertEquals(Result.getExitCode(), new Integer(0));
Assert.assertTrue(subscribedReposBefore.containsAll(subscribedReposAfter) && subscribedReposAfter.containsAll(subscribedReposBefore), "The list of subscribed repos is the same before and after importing the entitlement certificate.");
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class BugzillaTests method testStatusAfterProductIdIsAddedOrDeleted.
/**
* @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-21971", "RHEL7-51833" }, 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 status check and response from server after addition and deletion of product to/from /etc/pki/product/", groups = { "Tier3Tests", "VerifyStatusCheck", "blockedByBug-921870", "blockedByBug-1183175" }, enabled = true)
public void testStatusAfterProductIdIsAddedOrDeleted() throws Exception {
String result, expectedStatus;
Boolean Flag = false;
ProductCert installedProductCert32060 = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", "32060", clienttasks.getCurrentProductCerts());
Assert.assertNotNull(installedProductCert32060, "Found installed product cert 32060 needed for this test.");
configureTmpProductCertDirWithInstalledProductCerts(Arrays.asList(new ProductCert[] {}));
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null);
Assert.assertTrue(clienttasks.getCurrentProductCertFiles().isEmpty(), "No product certs are installed.");
result = clienttasks.status(null, null, null, null, null).getStdout();
expectedStatus = "Overall Status: Current";
Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' because no products are installed.");
client.runCommandAndWait("cp " + installedProductCert32060.file + " " + tmpProductCertDir);
result = clienttasks.status(null, null, null, null, null).getStdout();
expectedStatus = "Overall Status: Invalid";
Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' after manully installing a product cert.");
for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
if (CandlepinTasks.isPoolRestrictedToUnmappedVirtualSystems(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
clienttasks.subscribeToSubscriptionPool(pool);
Flag = true;
break;
}
}
// enable
clienttasks.autoheal(null, true, null, null, null, null, null);
clienttasks.run_rhsmcertd_worker(true);
result = clienttasks.status(null, null, null, null, null).getStdout();
if (Flag) {
expectedStatus = "Overall Status: Insufficient";
Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' after finally running rhsmcertd worker with auto-healing.");
} else {
expectedStatus = "Overall Status: Current";
Assert.assertTrue(result.contains(expectedStatus), "System status displays '" + expectedStatus + "' after finally running rhsmcertd worker with auto-healing.");
}
}
use of rhsm.data.SubscriptionPool in project rhsm-qe by RedHatQE.
the class BugzillaTests method testRegenerateEntitlementCert.
/**
* @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-21963", "RHEL7-51825" }, 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 entitlement certs are regenerated if certs are manually removed", groups = { "Tier3Tests", "VerifyRegenrateEntitlementCert" }, enabled = true)
@ImplementsNitrateTest(caseId = 64181)
public void testRegenerateEntitlementCert() throws JSONException, Exception {
String poolId = null;
int Certfrequeny = 1;
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);
List<String[]> listOfSectionNameValues = new ArrayList<String[]>();
listOfSectionNameValues.add(new String[] { "rhsmcertd", "autoAttachInterval".toLowerCase(), "1440" });
clienttasks.config(null, null, true, listOfSectionNameValues);
clienttasks.unsubscribe(true, (BigInteger) null, null, null, null, null, null);
for (SubscriptionPool availList : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
poolId = availList.poolId;
}
clienttasks.subscribe_(null, null, poolId, null, null, null, null, null, null, null, null, null, null);
client.runCommandAndWait("rm -rf " + clienttasks.entitlementCertDir + "/*.pem");
clienttasks.restart_rhsmcertd(Certfrequeny, null, null);
SubscriptionManagerCLITestScript.sleep(Certfrequeny * 60 * 1000);
List<File> Cert = clienttasks.getCurrentEntitlementCertFiles();
Assert.assertNotNull(Cert.size());
}
Aggregations