use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class BugzillaTests method testRegisterWithNameBlank.
/**
* @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-21990", "RHEL7-51852" }, 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: register --name , setting consumer name to blank", groups = { "Tier3Tests", "registerwithname", "blockedByBug-669395" }, enabled = true)
public void testRegisterWithNameBlank() throws JSONException, Exception {
String name = "test";
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, name, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
Assert.assertEquals(consumerCert.name, name);
name = "";
SSHCommandResult result = clienttasks.register_(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, name, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
String expectedMsg = String.format("Error: system name can not be empty.");
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post
// commit
// df95529a5edd0be456b3528b74344be283c4d258
Assert.assertEquals(result.getStderr().trim(), expectedMsg, "stderr");
Assert.assertEquals(result.getExitCode(), new Integer(64));
} else {
Assert.assertEquals(result.getStdout().trim(), expectedMsg, "stdout");
Assert.assertEquals(result.getExitCode(), new Integer(255));
}
consumerCert = clienttasks.getCurrentConsumerCert();
Assert.assertNotNull(consumerCert.name);
}
use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class EventTests method testNegativeConsumerUserPassword.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21843", "RHEL7-51664" }, 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: events: negative test for consumer user/password.", groups = { "Tier3Tests", "NegativeConsumerUserPassword_Test" }, dependsOnGroups = { "ConsumerCreated_Test" }, enabled = true)
@ImplementsNitrateTest(caseId = 50404)
public void testNegativeConsumerUserPassword() throws JSONException, Exception {
String authuser = "", authpwd = "";
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
try {
// enter the wrong user, correct passwd
authuser = sm_client1Username + getRandInt();
authpwd = sm_client1Password;
CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, authuser, authpwd, sm_serverUrl);
Assert.fail("Expected the candlepin server request for a syndication feed to return an HTTP response code 401 Unauthorized due to invalid authorization credentials " + authuser + ":" + authpwd);
} catch (IOException e) {
Assert.assertContainsMatch(e.getMessage(), "HTTP response code: 401", "Atom feed is unauthorized when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
try {
// enter the correct user, wrong passwd
authuser = sm_client1Username;
authpwd = sm_client1Password + getRandInt();
CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, authuser, authpwd, sm_serverUrl);
Assert.fail("Expected the candlepin server request for a syndication feed to return an HTTP response code 401 Unauthorized due to invalid authorization credentials " + authuser + ":" + authpwd);
} catch (IOException e) {
Assert.assertContainsMatch(e.getMessage(), "HTTP response code: 401", "Atom feed is unauthorized when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
try {
// enter the correct user, correct passwd for super admin atom
authuser = sm_client1Username;
authpwd = sm_client1Password;
CandlepinTasks.getSyndFeed(authuser, authpwd, sm_serverUrl);
Assert.fail("Expected the candlepin server request for a syndication feed to return an HTTP response code 401 Unauthorized due to invalid authorization credentials " + authuser + ":" + authpwd);
} catch (IOException e) {
Assert.assertContainsMatch(e.getMessage(), "HTTP response code: 403", "Atom feed is forbidden when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
// finally assert success with valid credentials
authuser = sm_client1Username;
authpwd = sm_client1Password;
SyndFeed feed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, authuser, authpwd, sm_serverUrl);
Assert.assertTrue(!feed.getEntries().isEmpty(), "Atom feed for consumer events is successful with valid credentials " + authuser + ":" + authpwd);
}
use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class EventTests method testConsumerModified.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21845", "RHEL7-51666" }, 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: events: Consumer Modified is sent over an RSS atom feed.", groups = { "Tier3Tests", "blockedByBug-721141", "ConsumerModified_Test" }, dependsOnGroups = { "EnititlementDeleted_Test" }, enabled = true)
public // @ImplementsTCMS(id="")
void testConsumerModified() throws Exception {
// get the owner and consumer feeds before we test the firing of a new event
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldConsumerFeed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
// fire an facts update event by overriding a fact in /etc/rhsm/facts/event_tests.facts
Map<String, String> eventFacts = new HashMap<String, String>();
eventFacts.put("events.test.description", "Testing CONSUMER MODIFIED event fires on facts update.");
eventFacts.put("events.test.currentTimeMillis", String.valueOf(System.currentTimeMillis()));
clienttasks.createFactsFileWithOverridingValues(eventFacts);
clienttasks.facts(null, true, null, null, null, null);
// FYI: Another way to fire a consumer modified event is to call CandlepinTasks.setAutohealForConsumer(authenticator, password, url, consumerid, autoheal);
String[] newEventTitles = new String[] { "CONSUMER MODIFIED" };
// COMPLIANCE CREATED events were added to support gutterball
newEventTitles = new String[] { "COMPLIANCE CREATED", "CONSUMER MODIFIED" };
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.1.1-1")) {
// commit 1ad3fd6f338d9bbcedc8eba8361d4bc6c807f84d 1474443 compliance.created events now use UUID for 'consumerId' field
newEventTitles = new String[] { "CONSUMER MODIFIED" };
}
// assert the consumer feed...
// assertTheNewConsumerFeed(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles);
assertTheNewConsumerFeedIgnoringEventTitles(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
// assert the owner feed...
// assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, newEventTitles);
assertTheNewOwnerFeedIgnoringEventTitles(ownerKey, oldOwnerFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
// assert the feed...
// assertTheNewFeed(oldFeed, newEventTitles);
assertTheNewFeedIgnoringEventTitles(oldFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
}
use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class EventTests method testPoolModifiedAndEntitlementModified.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-26757", "RHEL7-52091" }, 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: events: Pool Modified and Entitlement Modified is sent over an RSS atom feed.", groups = { "Tier3Tests", "blockedByBug-721141", "PoolModifiedAndEntitlementModified_Test", "blockedByBug-645597", "blockedByBug-1303242", "blockedByBug-1500837", "blockedByBug-1500843" }, dependsOnGroups = { "EntitlementCreated_Test" }, enabled = true)
public // @ImplementsTCMS(id="")
void testPoolModifiedAndEntitlementModified() throws Exception {
if (server == null)
throw new SkipException("This test requires an SSH connection to the candlepin server.");
// get the owner and consumer feeds before we test the firing of a new event
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
// get the number of subscriptions this owner owns
// JSONArray jsonSubscriptions = new JSONArray(CandlepinTasks.getResourceUsingRESTfulAPI(serverHostname,serverPort,serverPrefix,clientusername,clientpassword,"/owners/"+ownerKey+"/subscriptions"));
// find the first pool id of a currently consumed product
List<ProductSubscription> consumedProductSubscriptions = clienttasks.getCurrentlyConsumedProductSubscriptions();
ProductSubscription originalConsumedProductSubscription = consumedProductSubscriptions.get(0);
testPool = clienttasks.getSubscriptionPoolFromProductSubscription(originalConsumedProductSubscription, sm_clientUsername, sm_clientPassword);
Calendar originalStartDate = (Calendar) originalConsumedProductSubscription.startDate.clone();
EntitlementCert originalEntitlementCert = clienttasks.getEntitlementCertCorrespondingToProductSubscription(originalConsumedProductSubscription);
originalStartDate = (Calendar) originalEntitlementCert.validityNotBefore.clone();
SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldConsumerFeed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
// fire an modified pool event (and subsequently a modified entitlement event because the pool was modified thereby requiring an entitlement update dropped to the consumer)
log.info("To fire a modified pool event (and subsequently a modified entitlement event because the pool is already subscribed too), we will modify pool '" + testPool.poolId + "' by subtracting one month from startdate...");
Calendar newStartDate = (Calendar) originalStartDate.clone();
newStartDate.add(Calendar.MONTH, -1);
if (false) {
// the following block was used prior to candlepin-2.0.0 and replaced by CandlepinTasks.updateSubscriptionAndRefreshPoolsUsingRESTfulAPI which I think will also work for pre candlepin-2.0.0, but is untested. <== TODO
updateSubscriptionPoolDatesOnDatabase(testPool, newStartDate, null);
log.info("Now let's refresh the subscription pools to expose the POOL MODIFIED event...");
JSONObject jobDetail = CandlepinTasks.refreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey);
jobDetail = CandlepinTasks.waitForJobDetailStateUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, jobDetail, "FINISHED", 10 * 1000, 3);
} else
/*OLD*/
CandlepinTasks.updateSubscriptionDatesAndRefreshPoolsUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, CandlepinTasks.getSubscriptionIdForPoolId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, testPool.poolId), newStartDate, null);
// NEW TODO CandlepinTasks.updateSubscriptionPoolDatesUsingRESTfulAPI(sm_serverAdminUsername,sm_serverAdminPassword,sm_serverUrl, testPool.poolId,newStartDate,null);
// assert the consumer feed...
List<String> newEventTitles = new ArrayList<String>();
// newEventTitles.add("ENTITLEMENT MODIFIED");
assertTheNewConsumerFeed(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles);
// assert the owner feed...
// //assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, new String[]{"ENTITLEMENT MODIFIED", "POOL MODIFIED"});
// for (int s=0; s<jsonSubscriptions.length(); s++) newEventTitles.add("POOL MODIFIED"); // NOTE: This is troublesome because the number of POOL MODIFIED events is not this predictable especially when the pool (which is randomly chosen) is a virt pool
// assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, newEventTitles);
newEventTitles.add("POOL MODIFIED");
assertTheNewOwnerFeedContains(ownerKey, oldOwnerFeed, newEventTitles);
// assert the feed...
// //assertTheNewFeed(oldFeed, new String[]{"ENTITLEMENT MODIFIED", "POOL MODIFIED"});
// assertTheNewFeed(oldFeed, newEventTitles);
assertTheNewFeedContains(oldFeed, newEventTitles);
log.info("Now let's refresh the client's entitlements to expose the ENTITLEMENT MODIFIED event...");
clienttasks.refresh(null, null, null, null);
// COMPLIANCE CREATED events were added to support gutterball
newEventTitles.add("COMPLIANCE CREATED");
newEventTitles.add("ENTITLEMENT MODIFIED");
// assert the feed...
assertTheNewFeedContains(oldFeed, newEventTitles);
// assert the owner feed...
assertTheNewOwnerFeedContains(ownerKey, oldOwnerFeed, newEventTitles);
// assert the consumer feed...
newEventTitles.remove("POOL MODIFIED");
// assertTheNewConsumerFeed(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles);
assertTheNewConsumerFeedIgnoringEventTitles(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles.toArray(new String[] {}), new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
// TEMPORARY WORKAROUND FOR BUG
boolean invokeWorkaroundWhileBugIsOpen = true;
Calendar now = Calendar.getInstance();
try {
String bugId = "883486";
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("The workaround while this bug is open is to compensate the expected consumed product subscription start date for daylight savings.");
// adjust the expected entitlement dates for daylight savings time (changed by https://github.com/candlepin/subscription-manager/pull/385)
// now.get(Calendar.DST_OFFSET) will equal 0 in the winter StandardTime; will equal 1000*60*60 in the summer DaylightSavingsTime (when the local time zone observes DST)
newStartDate.add(Calendar.MILLISECOND, now.get(Calendar.DST_OFFSET) - newStartDate.get(Calendar.DST_OFFSET));
newStartDate.add(Calendar.MILLISECOND, now.get(Calendar.DST_OFFSET) - newStartDate.get(Calendar.DST_OFFSET));
}
// END OF WORKAROUND
// ProductSubscription newConsumedProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("serialNumber", originalConsumedProductSubscription.serialNumber, clienttasks.getCurrentlyConsumedProductSubscriptions()); // can't do this because the serialNumber changes after the pool and entitlement have been modified
ProductSubscription newConsumedProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productId", originalConsumedProductSubscription.productId, clienttasks.getCurrentlyConsumedProductSubscriptions());
// AN org.xmlpull.v1.XmlPullParserException IS THROWN WHEN THIS FAILS: Assert.assertEquals(newConsumedProductSubscription.startDate, newStartDate, "After modifying pool '"+testPool.poolId+"' by subtracting one month from startdate and refreshing entitlements, the consumed product subscription now reflects the modified field.");
Assert.assertEquals(ProductSubscription.formatDateString(newConsumedProductSubscription.startDate), ProductSubscription.formatDateString(newStartDate), "After modifying pool '" + testPool.poolId + "' by subtracting one month from startdate and refreshing entitlements, the consumed product subscription now reflects the modified field.");
}
use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method register_.
/**
* register WITHOUT asserting results.
* @param insecure TODO
* @param noproxy TODO
*/
public SSHCommandResult register_(String username, String password, String org, String environment, ConsumerType type, String name, String consumerid, Boolean autosubscribe, String servicelevel, String release, List<String> activationkeys, String serverurl, Boolean insecure, String baseurl, Boolean force, Boolean autoheal, String proxy, String proxyuser, String proxypassword, String noproxy) {
String command = registerCommand(username, password, org, environment, type, name, consumerid, autosubscribe, servicelevel, release, activationkeys, serverurl, insecure, baseurl, force, autoheal, proxy, proxyuser, proxypassword, noproxy);
/* this workaround should no longer be needed after rhel70 fixes by ckozak similar to bugs 1052297 1048325 commit 6fe57f8e6c3c35ac7761b9fa5ac7a6014d69ce20 that employs #!/usr/bin/python -S sys.setdefaultencoding('utf-8') import site
if (!SubscriptionManagerCLITestScript.isStringSimpleASCII(command)) command = "PYTHONIOENCODING=ascii "+command; // workaround for bug 800323 after master commit 1bc25596afaf294cd217200c605737a43112a378 to avoid stderr: 'ascii' codec can't decode byte 0xe5 in position 13: ordinal not in range(128)
*/
// run command without asserting results
SSHCommandResult sshCommandResult = sshCommandRunner.runCommandAndWait(command);
logRuntimeErrors(sshCommandResult);
// copy the current consumer cert and key to allRegisteredConsumerCertsDir for recollection by deleteAllRegisteredConsumerEntitlementsAfterSuite()
ConsumerCert consumerCert = getCurrentConsumerCert();
if (consumerCert != null) {
sshCommandRunner.runCommandAndWait(/*WithoutLogging*/
"cp -f " + consumerCert.file + " " + consumerCert.file.getPath().replace(consumerCertDir, SubscriptionManagerCLITestScript.allRegisteredConsumerCertsDir).replaceFirst("cert.pem$", consumerCert.consumerid + "_cert.pem"));
sshCommandRunner.runCommandAndWait(/*WithoutLogging*/
"cp -f " + consumerCert.file.getPath().replace("cert", "key") + " " + consumerCert.file.getPath().replace(consumerCertDir, SubscriptionManagerCLITestScript.allRegisteredConsumerCertsDir).replaceFirst("cert.pem$", consumerCert.consumerid + "_key.pem"));
}
// reset this.currentlyRegistered values
if (isPackageVersion("subscription-manager", ">=", "1.19.11-1")) {
// commit 217c3863448478d06c5008694e327e048cc54f54 Bug 1443101: Provide feedback for force register
if (sshCommandResult.getStdout().contains("All local data removed")) {
// Unregistering from: jsefler-candlepin.usersys.redhat.com:8443/candlepin
// The system with UUID 2618dc5e-8407-4933-a945-da2a3fa1ccd6 has been unregistered
// All local data removed
// Registering to: jsefler-candlepin.usersys.redhat.com:8443/candlepin
// The system has been registered with ID: 2618dc5e-8407-4933-a945-da2a3fa1ccd6
this.currentlyRegisteredUsername = null;
this.currentlyRegisteredPassword = null;
this.currentlyRegisteredOrg = null;
this.currentlyRegisteredType = null;
}
}
if (sshCommandResult.getExitCode().equals(Integer.valueOf(0))) {
// The system has been registered with id: 660faf39-a8f2-4311-acf2-5c1bb3c141ef
this.currentlyRegisteredUsername = username;
this.currentlyRegisteredPassword = password;
this.currentlyRegisteredOrg = org;
this.currentlyRegisteredType = type;
} else if (sshCommandResult.getExitCode().equals(Integer.valueOf(1)) && autosubscribe != null && autosubscribe) {
// Bug 689608 - Return error code when auto subscribing doesn't find any subscriptions (reported by dgregor)
this.currentlyRegisteredUsername = username;
this.currentlyRegisteredPassword = password;
this.currentlyRegisteredOrg = org;
this.currentlyRegisteredType = type;
} else if (sshCommandResult.getExitCode().equals(Integer.valueOf(1)) && consumerid != null) {
this.currentlyRegisteredUsername = username;
this.currentlyRegisteredPassword = password;
this.currentlyRegisteredOrg = org;
this.currentlyRegisteredType = type;
} else if (sshCommandResult.getExitCode().equals(Integer.valueOf(1)) && activationkeys != null && !activationkeys.isEmpty()) {
this.currentlyRegisteredUsername = username;
this.currentlyRegisteredPassword = password;
this.currentlyRegisteredOrg = org;
this.currentlyRegisteredType = type;
} else if (sshCommandResult.getExitCode().equals(Integer.valueOf(1)) && (force == null || !force) && isPackageVersion("subscription-manager", "<", "1.13.8-1")) {
// pre commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
// stdout= This system is already registered. Use --force to override
} else if (sshCommandResult.getExitCode().equals(Integer.valueOf(64)) && (force == null || !force) && isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
// stdout= This system is already registered. Use --force to override
} else if (sshCommandResult.getExitCode().equals(Integer.valueOf(1)) && (environment != null)) {
// Server does not support environments.
} else if (sshCommandResult.getExitCode().equals(Integer.valueOf(1)) && sshCommandResult.getStderr().trim().endsWith("cannot register with any organizations.") && isPackageVersion("subscription-manager", ">=", "1.14.7-1")) {
// post commit 270f2a3e5f7d55b69a6f98c160d38362961b3059
// stderr= testuser3 cannot register with any organizations.
} else if (// EX_USAGE Error: Activation keys cannot be used with --auto-attach.
sshCommandResult.getExitCode().equals(Integer.valueOf(64)) || // EX_UNAVAILABLE Unable to reach the server
sshCommandResult.getExitCode().equals(Integer.valueOf(69)) || // EX_SOFTWARE Error parsing serverurl:
sshCommandResult.getExitCode().equals(Integer.valueOf(70)) || // EX_CONFIG Error: CA certificate for subscription service has not been installed.
sshCommandResult.getExitCode().equals(Integer.valueOf(78)) || sshCommandResult.getExitCode().equals(Integer.valueOf(255))) {
// EX-CODES http://docs.thefoundry.co.uk/nuke/63/pythonreference/os-module.html
// Traceback/Error
/* The current system consumer actually remains unchanged when these errors are encountered by the register attempt, stop nullifying the currentlyRegistered consumer. TODO not confident that this is always true
this.currentlyRegisteredUsername = null;
this.currentlyRegisteredPassword = null;
this.currentlyRegisteredOrg = null;
this.currentlyRegisteredType = null;
*/
} else {
Assert.fail("Encountered an unexpected exitCode '" + sshCommandResult.getExitCode() + "' during a attempt to register.");
}
// set autoheal attribute of the consumer
if (autoheal != null && sshCommandResult.getExitCode().equals(Integer.valueOf(0))) {
try {
// Note: NullPointerException will likely occur when activationKeys are used because null will likely be passed for username/password
CandlepinTasks.setAutohealForConsumer(currentlyRegisteredUsername, currentlyRegisteredPassword, candlepinUrl, getCurrentConsumerId(sshCommandResult), autoheal);
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
return sshCommandResult;
}
Aggregations