use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.
the class EventTests method assertTheNewConsumerFeed.
/**
* Same as assertTheNewConsumerFeed(String ownerKey, String consumerUuid, SyndFeed oldConsumerFeed, String[] newEventTitles), but without regard to order of newEventTitles
*/
protected void assertTheNewConsumerFeed(String ownerKey, String consumerUuid, SyndFeed oldConsumerFeed, List<String> newEventTitles) throws IllegalArgumentException, IOException, FeedException {
// assert the consumer feed...
SyndFeed newConsumerFeed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerUuid, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
Assert.assertEquals(newConsumerFeed.getTitle(), "Event feed for consumer " + consumerUuid);
assertFeedContainsNoUnknownEvents(newConsumerFeed);
log.info("Expecting the new feed for consumer (" + consumerUuid + ") to have grown by the following " + newEventTitles.size() + " events (in no particular order): ");
for (String newEventTitle : newEventTitles) log.info(" " + newEventTitle);
// Assert.assertEquals(newConsumerFeed.getEntries().size(), oldConsumerFeed_EntriesSize+newEventTitles.size(), "The event feed for consumer "+consumerUuid+" has increased by "+newEventTitles.size()+" entries.");
// if (oldConsumerFeed_EntriesSize+newEventTitles.size() <= feedLimit) {
// Assert.assertEquals(newConsumerFeed.getEntries().size(), oldConsumerFeed_EntriesSize+newEventTitles.size(), "The event feed for consumer "+consumerUuid+" has increased by "+newEventTitles.size()+" entries.");
// } else {
// Assert.assertEquals(newConsumerFeed.getEntries().size(), feedLimit, "The event feed length for consumer '"+consumerUuid+"' has hit the max entry count as set by the Candlepin class AtomResource/ConsumerResource/OwnerResource hard-coded variable feedlimit.");
// }
Assert.assertEquals(getFeedGrowthCount(newConsumerFeed, oldConsumerFeed), newEventTitles.size(), newEventTitles.size() + " new event feed entries for consumer '" + consumerUuid + "' has been pushed onto the stack.");
List<String> newEventTitlesCloned = new ArrayList<String>();
for (String newEventTitle : newEventTitles) newEventTitlesCloned.add(newEventTitle);
for (int i = 0; i < newEventTitles.size(); i++) {
String actualEventTitle = ((SyndEntryImpl) newConsumerFeed.getEntries().get(i)).getTitle();
Assert.assertTrue(newEventTitlesCloned.remove(actualEventTitle), "The next (" + i + ") newest event feed entry (" + actualEventTitle + ") for consumer " + consumerUuid + " is among the expected list of event titles.");
}
}
use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.
the class EventTests method testPoolDeleted.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21849", "RHEL7-51670" }, 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 Deleted is sent over an RSS atom feed.", groups = { "Tier3Tests", "PoolDeleted_Test" }, dependsOnGroups = { "PoolCreated_Test" }, enabled = true, alwaysRun = true)
public // @ImplementsTCMS(id="")
void testPoolDeleted() throws Exception {
if (server == null)
throw new SkipException("This test requires an SSH connection to the candlepin server.");
if (sm_serverAdminUsername.equals("") || sm_serverAdminPassword.equals(""))
throw new SkipException("This test requires the candlepin server admin username and password credentials.");
// get the owner and consumer feeds before we test the firing of a new event
SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
/* DELETEME
if (servertasks.branch.equals("ALPHA") || servertasks.branch.equals("BETA") || servertasks.branch.matches("^candlepin-0\\.[012]\\..*$")) {
// candlepin branch 0.2- (deleteSubscriptionUsingCPC was deprecated in candlepin branch 0.3+)
servertasks.deletePoolUsingCPC(testJSONPool.getString("id"));
} else {
// candlepin branch 0.3+
servertasks.deleteSubscriptionUsingCPC(testJSONPool.getString("id"));
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, "<", "2.0.0")){ // no more refresh pools in candlepin 2.0
JSONObject jobDetail = servertasks.refreshPoolsUsingCPC(testOwnerKey,true);
CandlepinTasks.waitForJobDetailStateUsingRESTfulAPI(sm_serverAdminUsername,sm_serverAdminPassword,sm_serverUrl,jobDetail,"FINISHED", 10*1000, 3);
}
}
*/
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.10")) {
// candlepin commit 50d3bdcac7c9ad7f94dfd140a6ebfccc2512ee48 /root/candlepin/server/client/ruby/candlepin_api.rb:934:in `delete_subscription': Deprecated API. Please use delete_pool or HostedTest resources (RuntimeError)
// 201602221609:59.292 - FINE: ssh root@jsefler-f22-candlepin.usersys.redhat.com cd /root/candlepin/server/client/ruby; ./cpc delete_subscription "8a908790530a4f1801530ad04188158b" (com.redhat.qe.tools.SSHCommandRunner.run)
// 201602221610:00.269 - FINE: Stdout: (com.redhat.qe.tools.SSHCommandRunner.runCommandAndWait)
// 201602221610:00.269 - FINE: Stderr:
// /root/candlepin/server/client/ruby/candlepin_api.rb:934:in `delete_subscription': Deprecated API. Please use delete_pool or HostedTest resources (RuntimeError)
// from ./cpc:130:in `<main>'
// candlepin-2.0.10+ (createSubscriptionUsingCPC deprecation was enforced in candlepin 2.0.10 commit 50d3bdcac7c9ad7f94dfd140a6ebfccc2512ee48 )
servertasks.deletePoolUsingCPC(testJSONPool.getString("id"));
} else if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "0.3")) {
// candlepin branch 0.3+
servertasks.deleteSubscriptionUsingCPC(testJSONPool.getString("id"));
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, "<", "2.0.0")) {
// no more refresh pools in candlepin 2.0
JSONObject jobDetail = servertasks.refreshPoolsUsingCPC(testOwnerKey, true);
CandlepinTasks.waitForJobDetailStateUsingRESTfulAPI(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, jobDetail, "FINISHED", 10 * 1000, 3);
}
} else {
// candlepin branch 0.2- (deleteSubscriptionUsingCPC was deprecated in candlepin branch 0.3+)
servertasks.deletePoolUsingCPC(testJSONPool.getString("id"));
}
String[] newEventTitles = new String[] { "POOL DELETED" };
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=721136 - jsefler 07/14/2011
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "721136";
try {
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) {
newEventTitles = new String[] { "System deleted a pool for product " + testJSONProduct.getString("name") };
}
// END OF WORKAROUND
// assert the feed...
assertTheNewFeed(oldFeed, newEventTitles);
}
use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.
the class EventTests method testOwnerDeleted.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21852", "RHEL7-51673" }, 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: Owner Deleted is sent over an RSS atom feed.", groups = { "Tier3Tests", "OwnerDeleted_Test" }, dependsOnGroups = { "ImportCreated_Test" }, enabled = true, alwaysRun = true)
public // @ImplementsTCMS(id="")
void testOwnerDeleted() throws IllegalArgumentException, IOException, FeedException, JSONException {
if (server == null)
throw new SkipException("This test requires an SSH connection to the candlepin server.");
if (sm_serverAdminUsername.equals("") || sm_serverAdminPassword.equals(""))
throw new SkipException("This test requires the candlepin server admin username and password credentials.");
String ownerKey = sm_clientOrg;
// get the owner and consumer feeds before we test the firing of a new event
SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
// do something that will fire a delete owner event
servertasks.deleteOwnerUsingCPC(testOwnerKey);
String[] newEventTitles = new String[] { "OWNER DELETED" };
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=721136 - jsefler 07/14/2011
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "721136";
try {
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) {
newEventTitles = new String[] { ownerKey + " deleted the owner " + testOwnerKey };
}
// END OF WORKAROUND
// assert the feed...
// assertTheNewFeed(oldFeed, newEventTitles);
// TODO 10/24/2013 don't yet understand why "POOL DELETED" sometimes occurs on script re-runs
assertTheNewFeedIgnoringEventTitles(oldFeed, newEventTitles, new HashSet<String>() {
{
add("POOL DELETED");
}
});
}
use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.
the class EventTests method assertTheNewOwnerFeedIgnoringEventTitles.
protected void assertTheNewOwnerFeedIgnoringEventTitles(String ownerKey, SyndFeed oldOwnerFeed, String[] newEventTitles, Set<String> ignoreEventTitles) throws JSONException, Exception {
// assert the owner feed...
SyndFeed newOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
Assert.assertEquals(newOwnerFeed.getTitle(), "Event feed for owner " + CandlepinTasks.getOrgDisplayNameForOrgKey(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, ownerKey));
assertFeedContainsNoUnknownEvents(newOwnerFeed);
log.info("Expecting the new feed for owner (" + ownerKey + ") to have grown by at least (" + newEventTitles.length + ") events (" + ignoreEventTitles + " events will be ignored):");
int e = 0;
for (String newEventTitle : newEventTitles) log.info(String.format(" Expecting entry[%d].title %s", e++, newEventTitle));
int feedGrowthCount = getFeedGrowthCount(newOwnerFeed, oldOwnerFeed);
Assert.assertTrue(feedGrowthCount >= newEventTitles.length, "At least " + newEventTitles.length + " new event feed entries for owner '" + ownerKey + "' has been pushed onto the stack (actual=" + feedGrowthCount + ").");
int i = 0;
for (String newEventTitle : newEventTitles) {
String actualEventTitle = ((SyndEntryImpl) newOwnerFeed.getEntries().get(i)).getTitle();
if (ignoreEventTitles.contains(actualEventTitle)) {
log.warning("The next (" + i + ") newest event feed entry for owner '" + ownerKey + " is '" + actualEventTitle + "', and will be ignored.");
} else {
Assert.assertEquals(actualEventTitle, newEventTitle, "The next (" + i + ") newest event feed entry for owner '" + ownerKey + "' is '" + newEventTitle + "'.");
}
i++;
}
}
use of com.sun.syndication.feed.synd.SyndFeed in project rhsm-qe by RedHatQE.
the class EventTests method testNegativeSuperUserPassword.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21841", "RHEL7-51662" }, 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 super user/password.", groups = { "Tier3Tests", "NegativeSuperUserPassword_Test" }, dependsOnGroups = {}, enabled = true, alwaysRun = true)
@ImplementsNitrateTest(caseId = 50404)
public void testNegativeSuperUserPassword() throws IllegalArgumentException, IOException, FeedException {
if (sm_serverAdminUsername.equals("") || sm_serverAdminPassword.equals(""))
throw new SkipException("This test requires the candlepin server admin username and password credentials.");
String authuser = "", authpwd = "";
try {
// enter the wrong user, correct passwd
authuser = sm_serverAdminUsername + getRandInt();
authpwd = sm_serverAdminPassword;
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: 401", "Atom feed is unauthorized when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
try {
// enter the correct user, wrong passwd
authuser = sm_serverAdminUsername;
authpwd = sm_serverAdminPassword + getRandInt();
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: 401", "Atom feed is unauthorized when attempting to authorize with credentials " + authuser + ":" + authpwd);
}
// finally assert success with valid credentials
authuser = sm_serverAdminUsername;
authpwd = sm_serverAdminPassword;
SyndFeed feed = CandlepinTasks.getSyndFeed(authuser, authpwd, sm_serverUrl);
Assert.assertTrue(!feed.getEntries().isEmpty(), "Atom feed for all events is successful with valid credentials " + authuser + ":" + authpwd);
}
Aggregations