use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class ContentTests method VerifySubscribabilityOfSKUProvidingTooManyContentSets.
protected void VerifySubscribabilityOfSKUProvidingTooManyContentSets(String sku, int totalContentSets) {
// TODO remove parameter totalContentSets and make calls to CandepinTasks to find the totalContentSets from the sku
Map<String, String> factsMap = new HashMap<String, String>();
File entitlementCertFile;
EntitlementCert entitlementCert;
String systemCertificateVersionFactValue;
SSHCommandResult sshCommandResult;
// this msgid comes from Candlepin
String tooManyContentSetsMsgFormat = "Too many content sets for certificate. Please upgrade to a newer client to use subscription: %s";
tooManyContentSetsMsgFormat = "Too many content sets for certificate %s. A newer client may be available to address this problem. See kbase https://access.redhat.com/knowledge/node/129003 for more information.";
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.10-1")) {
// Bug 1190814 - typos in candlepin msgid // candlepin commit 18ede4fe2943f70b59f14a066a5ebd7b81525fad
tooManyContentSetsMsgFormat = "Too many content sets for certificate %s. A newer client may be available to address this problem. See knowledge database https://access.redhat.com/knowledge/node/129003 for more information.";
}
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);
SubscriptionPool pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", sku, clienttasks.getCurrentlyAvailableSubscriptionPools());
Assert.assertNotNull(pool, "Found an available pool to subscribe to productId '" + sku + "': " + pool);
// test that it is NOT subscribable when system.certificate_version: None
factsMap.put("system.certificate_version", null);
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.facts(null, true, null, null, null, null);
Assert.assertEquals(clienttasks.getFactValue("system.certificate_version"), "None", "When the system.certificate_version fact is null, its fact value is reported as 'None'.");
sshCommandResult = clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
Integer expectedExitCode = new Integer(255);
// EX_SOFTWARE // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
expectedExitCode = new Integer(70);
Assert.assertEquals(sshCommandResult.getStderr().trim(), String.format(tooManyContentSetsMsgFormat, pool.subscriptionName), "Stderr from an attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is null");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from an attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is null");
Assert.assertEquals(sshCommandResult.getExitCode(), expectedExitCode, "Exitcode from an attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is null");
Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(), "No entitlements should be consumed after attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is null");
// test that it is NOT subscribable when system.certificate_version: 1.0
factsMap.put("system.certificate_version", "1.0");
clienttasks.createFactsFileWithOverridingValues(factsMap);
clienttasks.facts(null, true, null, null, null, null);
Assert.assertEquals(clienttasks.getFactValue("system.certificate_version"), "1.0", "When the system.certificate_version fact is 1.0, its fact value is reported as '1.0'.");
sshCommandResult = clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
Assert.assertEquals(sshCommandResult.getStderr().trim(), String.format(tooManyContentSetsMsgFormat, pool.subscriptionName), "Stderr from an attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is 1.0");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from an attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is 1.0");
Assert.assertEquals(sshCommandResult.getExitCode(), expectedExitCode, "Exitcode from an attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is 1.0");
Assert.assertTrue(clienttasks.getCurrentlyConsumedProductSubscriptions().isEmpty(), "No entitlements should be consumed after attempt to subscribe to '" + pool.subscriptionName + "' that provides product(s) with many content sets (totalling >185) when system.certificate_version is 1.0");
// test that it is subscribable when system.certificate_version is the system's default value (should be >=3.0)
clienttasks.deleteFactsFileWithOverridingValues();
systemCertificateVersionFactValue = clienttasks.getFactValue("system.certificate_version");
Assert.assertTrue(Float.valueOf(systemCertificateVersionFactValue) >= 3.0, "The actual default system.certificate_version fact '" + systemCertificateVersionFactValue + "' is >= 3.0.");
clienttasks.subscribe(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
entitlementCert = clienttasks.getEntitlementCertCorrespondingToSubscribedPool(pool);
entitlementCertFile = clienttasks.getEntitlementCertFileFromEntitlementCert(entitlementCert);
// TOO ASSERTIVE Assert.assertTrue(Float.valueOf(entitlementCert.version)<=Float.valueOf(systemCertificateVersionFactValue),"The version of the entitlement certificate '"+entitlementCert.version+"' granted by candlepin is less than or equal to the system.certificate_version '"+systemCertificateVersionFactValue+"' which indicates the maximum certificate version this system knows how to handle."); // This assert was too assertive according to https://bugzilla.redhat.com/show_bug.cgi?id=1425236#c2
// Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1425236#c2
Assert.assertEquals(Float.valueOf(entitlementCert.version).intValue(), Float.valueOf(systemCertificateVersionFactValue).intValue(), "The major value of the entitlement certificate '" + entitlementCert.version + "' granted by candlepin matches the major value of the system.certificate_version '" + systemCertificateVersionFactValue + "' which indicates certificate compatibility.");
Assert.assertEquals(entitlementCert.contentNamespaces.size(), totalContentSets, "The number of content sets provided in this version '" + entitlementCert.version + "' entitlement cert parsed using the rct cat-cert tool.");
clienttasks.assertEntitlementCertsInYumRepolist(Arrays.asList(entitlementCert), true);
clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class ContentTests method testInstallAndRemoveYumGroupFromEnabledRepoAfterSubscribingToPool.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-25986", "RHEL7-56655" }, 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 Yum plugin: ensure yum groups can be installed/removed", groups = { "Tier2Tests", "FipsTests", "testInstallAndRemoveYumGroupFromEnabledRepoAfterSubscribingToPool" }, dataProvider = "getYumAvailableGroupFromEnabledRepoAndSubscriptionPoolData", enabled = true)
public // @ImplementsNitrateTest(caseId=) //TODO Find a tcms caseId for
void testInstallAndRemoveYumGroupFromEnabledRepoAfterSubscribingToPool(String availableGroup, String repoLabel, SubscriptionPool pool) throws JSONException, Exception {
if (availableGroup == null)
throw new SkipException("No yum groups corresponding to enabled repo '" + repoLabel + " were found after subscribing to pool: " + pool);
// avoid throttling RateLimitExceededException from IT-Candlepin
if (CandlepinType.hosted.equals(sm_serverType)) {
// strategically get a new consumer to avoid 60 repeated API calls from the same consumer
// re-register as a new consumer
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);
} else
clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
// subscribe to this pool (and remember it)
File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool);
Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to pool: " + pool);
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
// avoid htb repos that have no content (due to snapshot timing - see Bug 1360491 - no packages available from https://cdn.redhat.com/content/htb/rhel/computenode/7/x86_64/os
if (clienttasks.getYumListOfAvailablePackagesFromRepo(repoLabel).isEmpty()) {
if (repoLabel.contains("-htb-")) {
throw new SkipException("Skipping an attempt to groupinstall from repo '" + repoLabel + "' because it is empty. Assuming we are not within a RHEL Snapshot phase, HTB repositories are cleared out after GA and before Snapshot 1. See https://bugzilla.redhat.com/show_bug.cgi?id=1360491#c1");
} else {
// 201607261756:37.637 - FINE: ssh root@hp-dl380pgen8-02-vm-7.lab.bos.redhat.com yum -y groupinstall "Compatibility Libraries" --disableplugin=rhnplugin
// 201607261756:39.737 - FINE: Stdout:
// Loaded plugins: product-id, search-disabled-repos, subscription-manager
// No packages in any requested group available to install or update
// 201607261756:39.739 - FINE: Stderr:
// Warning: Group compat-libraries does not have any packages to install.
// Maybe run: yum groups mark install (see man yum)
// 201607261756:39.741 - FINE: ExitCode: 0
String expectedStdout = "No packages in any requested group available to install or update";
log.warning("This test will likely fail with '" + expectedStdout + "' because there are no available packages from repo '" + repoLabel + "'.");
}
}
// install availableGroup
clienttasks.yumInstallGroup(availableGroup);
// remove availableGroup
clienttasks.yumRemoveGroup(availableGroup);
// TODO: add asserts for the products that get installed or deleted in stdout as a result of yum group install/remove:
// deleting: /etc/pki/product/7.pem
// installing: 7.pem
// assert the list --installed "status" for the productNamespace name that corresponds to the ContentNamespace from where this repolabel came from.
// clean up
clienttasks.unsubscribeFromSerialNumber(entitlementCert.serialNumber);
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class ContentTests method getYumGroupFromEnabledRepoAndSubscriptionPoolDataAsListOfLists.
protected List<List<Object>> getYumGroupFromEnabledRepoAndSubscriptionPoolDataAsListOfLists() 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()) {
// avoid throttling RateLimitExceededException from IT-Candlepin
if (CandlepinType.hosted.equals(sm_serverType)) {
// strategically get a new consumer to avoid 60 repeated API calls from the same consumer
// re-register as a new consumer
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);
}
File entitlementCertFile = clienttasks.subscribeToSubscriptionPool_(pool);
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 first available group provided by this repo
String availableGroup = clienttasks.findAnAvailableGroupFromRepo(repoLabel);
// find first installed group provided by this repo
String installedGroup = clienttasks.findAnInstalledGroupFromRepo(repoLabel);
// String availableGroup, String installedGroup, String repoLabel, SubscriptionPool pool
ll.add(Arrays.asList(new Object[] { availableGroup, installedGroup, repoLabel, pool }));
}
}
clienttasks.unsubscribeFromSerialNumber(clienttasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
// minimize the number of dataProvided rows (useful during automated testcase development)
if (Boolean.valueOf(getProperty("sm.debug.dataProviders.minimize", "false")) && !ll.isEmpty())
break;
}
return ll;
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class ContentTests method getPackageFromEnabledRepoAndPersonalSubscriptionSubPoolDataAsListOfLists.
protected List<List<Object>> getPackageFromEnabledRepoAndPersonalSubscriptionSubPoolDataAsListOfLists() throws Exception {
List<List<Object>> ll = new ArrayList<List<Object>>();
if (!isSetupBeforeSuiteComplete)
return ll;
if (client1tasks == null)
return ll;
if (client2tasks == null)
return ll;
// assure we are registered (as a person on client2 and a system on client1)
// register client1 as a system under rhpersonalUsername
client1tasks.register(sm_rhpersonalUsername, sm_rhpersonalPassword, sm_rhpersonalOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
// register client2 as a person under rhpersonalUsername
client2tasks.register(sm_rhpersonalUsername, sm_rhpersonalPassword, sm_rhpersonalOrg, null, ConsumerType.person, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null, null);
// subscribe to the personal subscription pool to unlock the subpool
personalConsumerId = client2tasks.getCurrentConsumerId();
for (int j = 0; j < sm_personSubscriptionPoolProductData.length(); j++) {
JSONObject poolProductDataAsJSONObject = (JSONObject) sm_personSubscriptionPoolProductData.get(j);
String personProductId = poolProductDataAsJSONObject.getString("personProductId");
JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject.getJSONObject("subPoolProductData");
String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");
SubscriptionPool personPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", personProductId, client2tasks.getCurrentlyAvailableSubscriptionPools());
Assert.assertNotNull(personPool, "Personal productId '" + personProductId + "' is available to user '" + sm_rhpersonalUsername + "' registered as a person.");
File entitlementCertFile = client2tasks.subscribeToSubscriptionPool_(personPool);
Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to personal pool: " + personPool);
// now the subpool is available to the system
SubscriptionPool systemPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId, client1tasks.getCurrentlyAvailableSubscriptionPools());
Assert.assertNotNull(systemPool, "Personal subPool productId'" + systemProductId + "' is available to user '" + sm_rhpersonalUsername + "' registered as a system.");
// client1tasks.subscribeToSubscriptionPool(systemPool);
entitlementCertFile = client1tasks.subscribeToSubscriptionPool_(systemPool);
Assert.assertNotNull(entitlementCertFile, "Found the entitlement cert file that was granted after subscribing to system pool: " + systemPool);
EntitlementCert entitlementCert = client1tasks.getEntitlementCertFromEntitlementCertFile(entitlementCertFile);
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (!contentNamespace.type.equalsIgnoreCase("yum"))
continue;
if (contentNamespace.enabled) {
String repoLabel = contentNamespace.label;
// find an available package that is uniquely provided by repo
String pkg = client1tasks.findUniqueAvailablePackageFromRepo(repoLabel);
if (pkg == null) {
log.warning("Could NOT find a unique available package from repo '" + repoLabel + "' after subscribing to SubscriptionSubPool: " + systemPool);
}
// String availableGroup, String installedGroup, String repoLabel, SubscriptionPool pool
ll.add(Arrays.asList(new Object[] { pkg, repoLabel, systemPool }));
}
}
client1tasks.unsubscribeFromSerialNumber(client1tasks.getSerialNumberFromEntitlementCertFile(entitlementCertFile));
}
return ll;
}
use of rhsm.data.EntitlementCert in project rhsm-qe by RedHatQE.
the class ContentTests method testYumRepoListsEnabledContent.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20085", "RHEL7-51099" }, 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 content flag : Default content flag should enable", groups = { "Tier1Tests", "blockedByBug-804227", "blockedByBug-871146", "blockedByBug-924919", "blockedByBug-962520" }, enabled = true)
@ImplementsNitrateTest(caseId = 47578, fromPlan = 2479)
public void testYumRepoListsEnabledContent() throws JSONException, Exception {
// Original code from ssalevan
// ArrayList<String> repos = this.getYumRepolist();
//
// for (EntitlementCert cert:clienttasks.getCurrentEntitlementCerts()){
// if(cert.enabled.contains("1"))
// Assert.assertTrue(repos.contains(cert.label),
// "Yum reports enabled content subscribed to repo: " + cert.label);
// else
// Assert.assertFalse(repos.contains(cert.label),
// "Yum reports enabled content subscribed to repo: " + cert.label);
// }
List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
clienttasks.unregister(null, null, null, null);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
if (clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively().size() <= 0)
throw new SkipException("No available subscriptions were found. Therefore we cannot perform this test.");
List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
// or maybe we should skip when nothing is consumed
Assert.assertTrue(!entitlementCerts.isEmpty(), "After subscribing to all available subscription pools, there must be some entitlements.");
ArrayList<String> repolist = clienttasks.getYumRepolist("enabled");
for (EntitlementCert entitlementCert : entitlementCerts) {
for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
if (!contentNamespace.type.equalsIgnoreCase("yum"))
continue;
if (contentNamespace.enabled) {
if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
Assert.assertTrue(repolist.contains(contentNamespace.label), "Yum repolist enabled includes enabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "'.");
} else {
Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist enabled excludes enabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "' because not all requiredTags (" + contentNamespace.requiredTags + ") in the contentNamespace are provided by the currently installed productCerts.");
}
} else {
Assert.assertFalse(repolist.contains(contentNamespace.label), "Yum repolist enabled excludes disabled repo id/label '" + contentNamespace.label + "' after having subscribed to Subscription ProductId '" + entitlementCert.orderNamespace.productId + "'.");
}
}
}
}
Aggregations