use of com.redhat.qe.auto.tcms.ImplementsNitrateTest 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 com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testServiceLevelListWithInsecure.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21864", "RHEL7-51723" }, 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: service-level list with --insecure", groups = { "Tier3Tests", "ServiceLevelListWithInsecure_Test", "blockedByBug-844411", "blockedByBug-993202", "blockedByBug-1256960", /*is a duplicate of*/
"blockedByBug-1254349" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testServiceLevelListWithInsecure() {
SSHCommandResult sshCommandResult;
// calling service level list without insecure should pass
sshCommandResult = clienttasks.service_level(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, false, null, null, null, null);
// change the rhsm.ca_cert_dir configuration to simulate a missing candlepin ca cert
client.runCommandAndWait("mkdir -p /tmp/emptyDir");
sshCommandResult = clienttasks.config(null, null, true, new String[] { "rhsm", "ca_cert_dir", "/tmp/emptyDir/" });
// calling service level list without insecure should now fail (throwing stderr "certificate verify failed")
sshCommandResult = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, false, 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.getExitCode(), expectedExitCode, "Exitcode from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
if (clienttasks.isPackageVersion("python-rhsm", ">=", "1.18.5-1") && Integer.valueOf(clienttasks.redhatReleaseX) >= 7) {
// post python-rhsm commit 214103dcffce29e31858ffee414d79c1b8063970 Reduce usage of m2crypto (#184) (RHEL7+)
Assert.assertEquals(sshCommandResult.getStderr().trim(), "Unable to verify server's identity: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
} else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.9-1")) {
// post commit a695ef2d1da882c5f851fde90a24f957b70a63ad
Assert.assertEquals(sshCommandResult.getStderr().trim(), "Unable to verify server's identity: certificate verify failed", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
} else if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.10.9-1")) {
// post commit 3366b1c734fd27faf48313adf60cf051836af115
Assert.assertEquals(sshCommandResult.getStderr().trim(), "", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "Unable to verify server's identity: certificate verify failed", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
} else {
Assert.assertEquals(sshCommandResult.getStderr().trim(), "certificate verify failed", "Stderr from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
Assert.assertEquals(sshCommandResult.getStdout().trim(), "", "Stdout from the service-level list command when configuration rhsm.ca_cert_dir has been falsified.");
}
// calling service level list with insecure should now pass
sshCommandResult = clienttasks.service_level(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg, null, true, null, null, null, null);
// assert that option --insecure did NOT persist to rhsm.conf
Assert.assertEquals(clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "server", "insecure"), "0", "Expected value of " + clienttasks.rhsmConfFile + " server.insecure configuration. Use of the --insecure option when calling the service-level module should NOT be persisted to rhsm.conf as true.");
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest 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 com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testServiceLevelListWithInvalidOrg.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21865", "RHEL7-51721" }, 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: service-level --list (with invalid org)", groups = { "Tier3Tests", "blockedByBug-796468", "blockedByBug-815479", "blockedByBug-1256960", /*is a duplicate of*/
"blockedByBug-1254349" }, enabled = true)
@ImplementsNitrateTest(caseId = 165509)
public void testServiceLevelListWithInvalidOrg() {
String x = String.valueOf(getRandInt());
SSHCommandResult result;
// test while unregistered
clienttasks.unregister(null, null, null, null);
result = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg + x, null, null, null, null, null, null);
if (sm_serverOld) {
Assert.assertEquals(result.getStderr().trim(), "ERROR: The service-level command is not supported by the server.");
throw new SkipException("Skipping this test since service-level is gracefully not supported when configured against an old candlepin server.");
}
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(result.getExitCode(), expectedExitCode, "ExitCode from service-level --list with invalid org");
Assert.assertEquals(result.getStderr().trim(), String.format("Organization with id %s could not be found.", sm_clientOrg + x), "Stderr from service-level --list with invalid org");
Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --list with invalid credentials");
// test while registered
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (List<String>) null, null, null, null, null, null, null, null, null, null);
result = clienttasks.service_level_(null, true, null, null, sm_clientUsername, sm_clientPassword, sm_clientOrg + x, null, null, null, null, null, null);
Assert.assertEquals(result.getExitCode(), expectedExitCode, "ExitCode from service-level --list with invalid org");
Assert.assertEquals(result.getStderr().trim(), String.format("Organization with id %s could not be found.", sm_clientOrg + x), "Stderr from service-level --list with invalid org");
Assert.assertEquals(result.getStdout().trim(), "", "Stdout from service-level --list with invalid credentials");
}
use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.
the class ServiceLevelTests method testSetDefaultServiceLevelForOrgAndRegister.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21869", "RHEL7-51714" }, 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 = "Using curl, set the default service level for an org and then register using org credentials to verify consumer's service level", groups = { "Tier3Tests", "SetDefaultServiceLevelForOrgAndRegister_Test" }, // dataProvider="getAllAvailableServiceLevelData", // 06/05/2014 takes too long; rarely reveals a bug
dataProvider = "getRandomSubsetOfAllAvailableServiceLevelData", enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSetDefaultServiceLevelForOrgAndRegister(Object bugzilla, String defaultServiceLevel) throws JSONException, Exception {
// update the defaultServiceLevel on the Org
if (orgForSetDefaultServiceLevelForOrgAndRegister_Test == null)
orgForSetDefaultServiceLevelForOrgAndRegister_Test = clienttasks.getCurrentlyRegisteredOwnerKey();
JSONObject jsonOrg = CandlepinTasks.setAttributeForOrg(sm_clientUsername, sm_clientPassword, sm_serverUrl, orgForSetDefaultServiceLevelForOrgAndRegister_Test, "defaultServiceLevel", defaultServiceLevel);
Assert.assertEquals(jsonOrg.get("defaultServiceLevel"), defaultServiceLevel, "The defaultServiceLevel update to org '" + orgForSetDefaultServiceLevelForOrgAndRegister_Test + "' appears successful on the candlepin server.");
// register and assert the consumer's service level is set to the new org default
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, /*will either be null or equal to orgForSetDefaultServiceLevelForOrgAndRegister_Test*/
null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
Assert.assertEquals(clienttasks.getCurrentServiceLevel(), defaultServiceLevel, "Immediately upon registering, the consumer's service level preference was set to the org's default.");
}
Aggregations