This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository wao. See http://git.codelutin.com/wao.git commit d53a19e3e60fe54d76d42bcab82aeb98e3ce3f35 Author: Brendan Le Ny <bleny@codelutin.com> Date: Tue Mar 31 12:12:28 2015 +0200 Ajout d'un test pour vérifier le bon fonctionnement de la demande de renouvellement de mot de passe --- .../administration/WaoUsersServiceTest.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java b/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java index e47d44d..6653feb 100644 --- a/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java +++ b/wao-services/src/test/java/fr/ifremer/wao/services/service/administration/WaoUsersServiceTest.java @@ -22,8 +22,10 @@ package fr.ifremer.wao.services.service.administration; */ import fr.ifremer.wao.services.AbstractWaoServiceTest; +import fr.ifremer.wao.services.service.ObsMerFixtures; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -33,11 +35,19 @@ public class WaoUsersServiceTest extends AbstractWaoServiceTest { protected WaoUsersService service; + protected ObsMerFixtures fixtures; + + protected boolean isDatabaseWithReferential() { + return true; + } + @Before public void setUp() { service = newService(WaoUsersService.class); + fixtures = new ObsMerFixtures(newServiceContext()); + } @Test @@ -50,4 +60,38 @@ public class WaoUsersServiceTest extends AbstractWaoServiceTest { } } + + @Test + public void testAskForNewPassword() throws WrongCredentialsException, NoRoleAttributedException, InactiveWaoUserException { + + String login = fixtures.robert().getWaoUser().getLogin(); + String fakePassword = fixtures.fakePassword(); + + service.authenticate(login, fakePassword); + + try { + service.askForPasswordReminder(login); + service.authenticate(login, "BJlNoN1Q"); + } catch (WrongCredentialsException | InactiveWaoUserException | NoRoleAttributedException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception", e); + } + Assert.fail("unexpected exception" + e); + } + + try { + service.authenticate(login, fakePassword); + Assert.fail("expected exception"); + } catch (WrongCredentialsException e) { + if (log.isDebugEnabled()) { + log.debug("expected exception", e); + } + } catch (NoRoleAttributedException | InactiveWaoUserException e) { + if (log.isDebugEnabled()) { + log.debug("unexpected exception", e); + } + Assert.fail("unexpected exception" + e); + } + + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.