use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.
the class InvitationTest method testSpamReporting.
/**
* This test proves that:
* 1. Guests (mail recipients) can report spam.
* 2. After a spam report, a user's mail privilege is suspended.
* 3. An admin will see a message telling him that a spam report was made.
* 4. After an admin marks the message as not spam, the sender can again send mail.
*/
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testSpamReporting() throws Exception {
TestUtils.Session admin = getUtil().getSession();
try {
getUtil().forceGuestUser();
getUtil().createUserAndLogin("spam", "andEggs");
setSenderPage(InvitationSenderPage.gotoPage());
startGreenMail();
getSenderPage().fillForm("undisclosed-recipients@localhost.localdomain", null, "You have won the email lottery!");
getSenderPage().send();
getGreenMail().waitForIncomingEmail(10000, 1);
MimeMessage[] messages = getGreenMail().getReceivedMessages();
String htmlMessage = getMessageContent(messages[0]).get("htmlPart");
// Restare greenmail to clear message
stopGreenMail();
startGreenMail();
// Now switch to guest.
TestUtils.Session spammer = getUtil().getSession();
getUtil().forceGuestUser();
InvitationGuestActionsPage guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.REPORT);
guestPage.setMemo("It's the email lottery, they have taken over your server!");
guestPage.confirm();
Assert.assertTrue("Failed to report spam", guestPage.getMessage().contains("Your report has been logged and the situation"));
// Prove that a reported message cannot be accepted (which would clear the "reported" status)
guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.ACCEPT);
Assert.assertTrue("After a message is reported a user can accept it, clearing the spam report", guestPage.getMessage().equals("This invitation has been reported as spam and is no longer valid."));
// Prove that a reported message cannot be declined
guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.DECLINE);
Assert.assertTrue("After a message is reported a user can decline it, clearing the spam report", guestPage.getMessage().equals("This invitation has already been reported as " + "spam and thus cannot be declined."));
// Switch to admin
getUtil().setSession(admin);
// Go to invitation sender.
setSenderPage(InvitationSenderPage.gotoPage());
// Switch back to spammer.
getUtil().setSession(spammer);
getSenderPage().send();
getGreenMail().waitForIncomingEmail(2000, 1);
Assert.assertTrue("Reported spammers can send mail!", getGreenMail().getReceivedMessages().length == 0);
Assert.assertTrue("No message telling user he's reported spammer.", getSenderPage().userIsSpammer());
// Switch to admin.
getUtil().setSession(admin);
setSenderPage(InvitationSenderPage.gotoPage());
Assert.assertTrue("No warning in footer that a message is reported as spam", getSenderPage().getFooter().spamReports() == 1);
// View spam message.
InspectInvitationsPage inspectPage = getSenderPage().getFooter().inspectAllInvitations();
InspectInvitationsPage.OneMessage inspect = inspectPage.getMessageWhere("Subject", "spam has invited you to join localhost");
// Prove that the memo left by spam reported is shown.
String expectedMessage = "Reported as spam with message: It's the email lottery, they have taken over " + "your server!";
Assert.assertTrue("The message by the spam reporter is not shown to the admin.\nExpecting:" + expectedMessage + "\n Got:" + inspect.getStatusAndMemo(), inspect.getStatusAndMemo().equals(expectedMessage));
String memo = "Actually the email lottery is quite legitimate.";
String expectedSuccessMessage = "Invitation successfully marked as not spam. Log entry: " + memo;
// Return their sending privilege.
String successMessage = inspect.notSpam("Actually the email lottery is quite legitimate.");
// Make sure the output is correct.
Assert.assertTrue("Admin got incorrect message after marking invitation as not spam\nExpecting:" + expectedSuccessMessage + "\n Got:" + successMessage, expectedSuccessMessage.equals(successMessage));
// Switch back to spammer
getUtil().setSession(spammer);
setSenderPage(InvitationSenderPage.gotoPage());
Assert.assertFalse("User permission to send not returned by admin action.", getSenderPage().userIsSpammer());
} finally {
stopGreenMail();
getUtil().setSession(admin);
getUtil().rest().deletePage("XWiki", "spam");
}
}
use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.
the class InvitationTest method testAcceptInvitationToClosedWiki.
/**
* This test proves that:
* 1. A guest cannot register if register permission is removed from XWikiPreferences.
* 2. Upon receiving an email invitation the guest can register even without register permission.
*/
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testAcceptInvitationToClosedWiki() throws Exception {
TestUtils.Session admin = getUtil().getSession();
try {
// First we ban anon from registering.
ObjectEditPage oep = ObjectEditPage.gotoPage("XWiki", "XWikiPreferences");
oep.getObjectsOfClass("XWiki.XWikiGlobalRights").get(0).getSelectElement(By.name("XWiki.XWikiGlobalRights_0_levels")).select("register");
oep.clickSaveAndContinue();
// now prove anon cannot register
getUtil().forceGuestUser();
RegistrationPage.gotoPage();
getUtil().assertOnPage(getUtil().getURL("XWiki", "XWikiLogin", "login"));
// Now we try sending and accepting an invitation.
getUtil().setSession(admin);
setSenderPage(InvitationSenderPage.gotoPage());
getSenderPage().fillInDefaultValues();
startGreenMail();
getSenderPage().send();
getGreenMail().waitForIncomingEmail(10000, 1);
MimeMessage[] messages = getGreenMail().getReceivedMessages();
String htmlMessage = getMessageContent(messages[0]).get("htmlPart");
Assert.assertTrue("New invitation is not listed as pending in the footer.", getSenderPage().getFooter().myPendingInvitations() == 1);
// Now switch to guest.
getUtil().forceGuestUser();
InvitationGuestActionsPage guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.ACCEPT);
Assert.assertTrue("There was an error message when accepting the invitation message:\n" + guestPage.getMessage(), guestPage.getMessage().equals(""));
// Register a new user.
RegistrationPage rp = new RegistrationPage();
rp.fillRegisterForm(null, null, "AnotherInvitedMember", "WeakPassword", "WeakPassword", null);
rp.clickRegister();
Assert.assertTrue("There were failure messages when registering.", rp.getValidationFailureMessages().isEmpty());
getDriver().get(getUtil().getURLToLoginAs("AnotherInvitedMember", "WeakPassword"));
Assert.assertTrue("Failed to log user in after registering from invitation.", rp.isAuthenticated());
} finally {
stopGreenMail();
getUtil().setSession(admin);
// Better open the wiki back up again.
ObjectEditPage oep = ObjectEditPage.gotoPage("XWiki", "XWikiPreferences");
oep.getObjectsOfClass("XWiki.XWikiGlobalRights").get(0).getSelectElement(By.name("XWiki.XWikiGlobalRights_0_levels")).unSelect("register");
oep.clickSaveAndContinue();
}
}
use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.
the class NewPagePanelTest method testCreatePageFromPanel.
/**
* Tests if a new page can be created using the create page panel.
*/
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testCreatePageFromPanel() {
NewPagePanel newPagePanel = NewPagePanel.gotoPage();
CreatePagePage createPagePage = newPagePanel.createPage(getTestClassName(), getTestMethodName());
createPagePage.clickCreate();
WikiEditPage editPage = new WikiEditPage();
Assert.assertEquals(getTestMethodName(), editPage.getDocumentTitle());
Assert.assertEquals("WebHome", editPage.getMetaDataValue("page"));
Assert.assertEquals(getTestClassName() + "." + getTestMethodName(), editPage.getMetaDataValue("space"));
}
use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.
the class EditObjectsTest method testChangeMultiselectProperty.
/**
* Tests that XWIKI-1621 remains fixed.
*/
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testChangeMultiselectProperty() {
// Create a class with a database list property set to return all documents
ClassEditPage cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
cep.addProperty("prop", "DBList");
cep.getDatabaseListClassEditElement("prop").setHibernateQuery("select doc.fullName from XWikiDocument doc where doc.space = 'Test'");
cep.clickSaveAndView();
// Create a second page to hold the Object and set its content
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
wep.setContent("this is the content");
ViewPage vp = wep.clickSaveAndView();
// Add an object of the class created and set the value to be the test page
ObjectEditPage oep = vp.editObjects();
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestClass");
oep.clickSaveAndView();
// Set multiselect to true
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
cep.getDatabaseListClassEditElement("prop").setMultiSelect(true);
cep.clickSaveAndView();
// Select a second document in the DB list select field.
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestObject");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content", vp.getContent());
}
use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.
the class EditObjectsTest method testObjectAddAndRemove.
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testObjectAddAndRemove() {
ObjectEditPage oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
FormElement object = oep.addObject("XWiki.XWikiUsers");
object.setFieldValue(By.id("XWiki.XWikiUsers_0_first_name"), "John");
// Add another object
FormElement object2 = oep.addObject("XWiki.XWikiUsers");
// Check that the unsaved value from the first object wasn't lost
Assert.assertEquals("John", object.getFieldValue(By.id("XWiki.XWikiUsers_0_first_name")));
// Check that the value from the second object is unset
Assert.assertEquals("", object2.getFieldValue(By.id("XWiki.XWikiUsers_1_first_name")));
// Delete the second object
oep.deleteObject("XWiki.XWikiUsers", 1);
// Let's save the form and check that changes were persisted.
oep = oep.clickSaveAndView().editObjects();
List<ObjectEditPane> xwikiUsersForms = oep.getObjectsOfClass("XWiki.XWikiUsers");
Assert.assertEquals(1, xwikiUsersForms.size());
Assert.assertEquals("John", xwikiUsersForms.get(0).getFieldValue(By.id("XWiki.XWikiUsers_0_first_name")));
}
Aggregations