Author: ymartel Date: 2012-06-12 18:12:48 +0200 (Tue, 12 Jun 2012) New Revision: 3454 Url: http://chorem.org/repositories/revision/pollen/3454 Log: refs #606 : add tests for security access with a normal poll Modified: trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/security/SecurityAccessSIT.java trunk/pollen-ui-struts2-test/src/test/resources/pollendb.h2.db Modified: trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/security/SecurityAccessSIT.java =================================================================== --- trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/security/SecurityAccessSIT.java 2012-06-12 14:25:28 UTC (rev 3453) +++ trunk/pollen-ui-struts2-test/src/test/java/org/chorem/pollen/ui/security/SecurityAccessSIT.java 2012-06-12 16:12:48 UTC (rev 3454) @@ -43,6 +43,14 @@ protected final String ADMIN_USERSLIST_URL = "http://localhost:8080/pollen/admin/usersList"; protected final String CONNECTEDREQUIRED_URL = "http://localhost:8080/pollen/security/connected_required"; protected final String ADMINREQUIRED_URL = "http://localhost:8080/pollen/security/admin_required"; + protected final String POLL_BASE_URL = "http://localhost:8080/pollen/poll/votefor/"; + protected final String POLL_ADMIN_BASE_URL = "http://localhost:8080/pollen/poll/votefor/"; + protected final String MODIFICATION_BASE8URL = "http://localhost:8080/pollen/poll/modification/"; + protected final String NORMALPOLL_ID = "c7082f9752844b83a1859abcae3b681c"; + protected final String NORMALPOLL_ADMINTOKEN = "b9b434acd58d42fca083d473ee021fce"; + protected final String POLLREQUIRED_URL = "http://localhost:8080/pollen/security/poll_required"; + protected final String POLLACCESSREQUIRED_URL = "http://localhost:8080/pollen/security/poll_access_required"; + protected final String POLLCREATORREQUIRED_URL = "http://localhost:8080/pollen/security/poll_creator_required"; /** * This test : @@ -212,6 +220,57 @@ } /** + * This test : + * <ol> + * <li>Try to access to normal poll with good pollId</li> + * <li>Try to access to normal poll with bad pollId (should be redirected)</li> + * <li>Try to access to moderation page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to moderation page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * <li>Try to access to admin page for normal poll with good pollId & good tokenId</li> + * <li>Try to access to admin page for normal poll with good pollId & bad tokenId (should be redirected)</li> + * </ol> + * + * All the page should be accessed. + * + * @throws Exception + */ + @Test + public void accessNormalPoolActionsAsAnonymous() throws Exception { + + WebDriver driver = getDriver(); + + // try to access to poll page, current url should be good one + String normalPollURL = POLL_BASE_URL + NORMALPOLL_ID; + driver.get(normalPollURL); + Assert.assertEquals(normalPollURL, driver.getCurrentUrl()); + + // try to access to poll page with bad pollId, current url should be the poll_required one + driver.get(normalPollURL.substring(0, 10)); + Assert.assertTrue(driver.getCurrentUrl().startsWith(POLLREQUIRED_URL)); + + // try to access to poll moderation page, current url should be good one + String moderationURL = normalPollURL + ":" + NORMALPOLL_ADMINTOKEN; + driver.get(moderationURL); + Assert.assertEquals(moderationURL, driver.getCurrentUrl()); + + // try to access to poll page with bad pollId, current url should be the poll_required one + String badModerationURL = normalPollURL + ":" + NORMALPOLL_ADMINTOKEN.substring(0, 5); + driver.get(badModerationURL); + Assert.assertTrue(driver.getCurrentUrl().startsWith(POLLACCESSREQUIRED_URL)); + + // try to access to poll moderation page, current url should be good one + String normalPollAdminURL = POLL_ADMIN_BASE_URL + NORMALPOLL_ID + ":" + NORMALPOLL_ADMINTOKEN; + driver.get(normalPollAdminURL); + Assert.assertEquals(normalPollAdminURL, driver.getCurrentUrl()); + + // try to access to poll page with bad pollId, current url should be the poll_required one + String badNormalPollAdminURL = POLL_ADMIN_BASE_URL + NORMALPOLL_ID + ":" + NORMALPOLL_ADMINTOKEN.substring(0, 2); + driver.get(badNormalPollAdminURL); + Assert.assertTrue(driver.getCurrentUrl().startsWith(POLLCREATORREQUIRED_URL)); + + } + + /** * Connect as the user named "user" * * @param driver : the {@link WebDriver} of the current test Modified: trunk/pollen-ui-struts2-test/src/test/resources/pollendb.h2.db =================================================================== (Binary files differ)
participants (1)
-
ymartel@users.chorem.org