Commit eedbd96c9fc1ee29c0aa25c2ce00ffe43c896e79
1 parent
b2678269
Exists in
master
Ajustes nos teste com exceções no login e no logout.
Showing
6 changed files
with
299 additions
and
150 deletions
Show diff stats
impl/core/src/test/java/security/athentication/error/ErrorAuthenticator.java
| ... | ... | @@ -1,60 +0,0 @@ |
| 1 | -/* | |
| 2 | - * Demoiselle Framework | |
| 3 | - * Copyright (C) 2010 SERPRO | |
| 4 | - * ---------------------------------------------------------------------------- | |
| 5 | - * This file is part of Demoiselle Framework. | |
| 6 | - * | |
| 7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | - * as published by the Free Software Foundation. | |
| 10 | - * | |
| 11 | - * This program is distributed in the hope that it will be useful, | |
| 12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | - * GNU General Public License for more details. | |
| 15 | - * | |
| 16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | - * ---------------------------------------------------------------------------- | |
| 21 | - * Este arquivo é parte do Framework Demoiselle. | |
| 22 | - * | |
| 23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | - * do Software Livre (FSF). | |
| 26 | - * | |
| 27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | - * para maiores detalhes. | |
| 31 | - * | |
| 32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | - */ | |
| 37 | -package security.athentication.error; | |
| 38 | - | |
| 39 | -import br.gov.frameworkdemoiselle.security.Authenticator; | |
| 40 | -import br.gov.frameworkdemoiselle.security.User; | |
| 41 | - | |
| 42 | -public class ErrorAuthenticator implements Authenticator { | |
| 43 | - | |
| 44 | - private static final long serialVersionUID = 1L; | |
| 45 | - | |
| 46 | - @Override | |
| 47 | - public void authenticate() { | |
| 48 | - throw new RuntimeException(); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Override | |
| 52 | - public void unauthenticate() { | |
| 53 | - throw new RuntimeException(); | |
| 54 | - } | |
| 55 | - | |
| 56 | - @Override | |
| 57 | - public User getUser() { | |
| 58 | - return null; | |
| 59 | - } | |
| 60 | -} |
impl/core/src/test/java/security/athentication/error/ErrorAuthenticatorTest.java
| ... | ... | @@ -1,90 +0,0 @@ |
| 1 | -/* | |
| 2 | - * Demoiselle Framework | |
| 3 | - * Copyright (C) 2010 SERPRO | |
| 4 | - * ---------------------------------------------------------------------------- | |
| 5 | - * This file is part of Demoiselle Framework. | |
| 6 | - * | |
| 7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | - * as published by the Free Software Foundation. | |
| 10 | - * | |
| 11 | - * This program is distributed in the hope that it will be useful, | |
| 12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | - * GNU General Public License for more details. | |
| 15 | - * | |
| 16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | - * ---------------------------------------------------------------------------- | |
| 21 | - * Este arquivo é parte do Framework Demoiselle. | |
| 22 | - * | |
| 23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | - * do Software Livre (FSF). | |
| 26 | - * | |
| 27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | - * para maiores detalhes. | |
| 31 | - * | |
| 32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | - */ | |
| 37 | -package security.athentication.error; | |
| 38 | - | |
| 39 | -import static junit.framework.Assert.assertEquals; | |
| 40 | -import static junit.framework.Assert.fail; | |
| 41 | - | |
| 42 | -import javax.inject.Inject; | |
| 43 | - | |
| 44 | -import org.jboss.arquillian.container.test.api.Deployment; | |
| 45 | -import org.jboss.arquillian.junit.Arquillian; | |
| 46 | -import org.jboss.shrinkwrap.api.spec.JavaArchive; | |
| 47 | -import org.junit.Test; | |
| 48 | -import org.junit.runner.RunWith; | |
| 49 | - | |
| 50 | -import test.Tests; | |
| 51 | -import br.gov.frameworkdemoiselle.security.AuthenticationException; | |
| 52 | -import br.gov.frameworkdemoiselle.security.SecurityContext; | |
| 53 | -import configuration.resource.ConfigurationResourceTest; | |
| 54 | - | |
| 55 | -@RunWith(Arquillian.class) | |
| 56 | -public class ErrorAuthenticatorTest { | |
| 57 | - | |
| 58 | - @Inject | |
| 59 | - private SecurityContext context; | |
| 60 | - | |
| 61 | - @Deployment | |
| 62 | - public static JavaArchive createDeployment() { | |
| 63 | - JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); | |
| 64 | - deployment.addClass(ErrorAuthenticator.class); | |
| 65 | - return deployment; | |
| 66 | - } | |
| 67 | - | |
| 68 | - @Test | |
| 69 | - public void errorDuringLogin() { | |
| 70 | - try { | |
| 71 | - context.login(); | |
| 72 | - fail("Login deveria disparar exceção de runtime"); | |
| 73 | - | |
| 74 | - } catch (AuthenticationException cause) { | |
| 75 | - assertEquals(RuntimeException.class, cause.getCause().getClass()); | |
| 76 | - } | |
| 77 | - } | |
| 78 | - | |
| 79 | - @Test | |
| 80 | - public void errorDuringLogout() { | |
| 81 | - try { | |
| 82 | - context.login(); | |
| 83 | - fail("Logout deveria disparar exceção de runtime"); | |
| 84 | - | |
| 85 | - } catch (AuthenticationException cause) { | |
| 86 | - assertEquals(RuntimeException.class, cause.getCause().getClass()); | |
| 87 | - } | |
| 88 | - } | |
| 89 | - | |
| 90 | -} |
impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticator.java
0 → 100644
| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package security.athentication.error; | |
| 38 | + | |
| 39 | +import br.gov.frameworkdemoiselle.security.Authenticator; | |
| 40 | +import br.gov.frameworkdemoiselle.security.User; | |
| 41 | + | |
| 42 | +public class LoginErrorAuthenticator implements Authenticator { | |
| 43 | + | |
| 44 | + private static final long serialVersionUID = 1L; | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public void authenticate() { | |
| 48 | + throw new RuntimeException(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void unauthenticate() { | |
| 53 | + throw new RuntimeException(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public User getUser() { | |
| 58 | + return null; | |
| 59 | + } | |
| 60 | +} | ... | ... |
impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticatorTest.java
0 → 100644
| ... | ... | @@ -0,0 +1,79 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package security.athentication.error; | |
| 38 | + | |
| 39 | +import static junit.framework.Assert.assertEquals; | |
| 40 | +import static junit.framework.Assert.fail; | |
| 41 | + | |
| 42 | +import javax.inject.Inject; | |
| 43 | + | |
| 44 | +import org.jboss.arquillian.container.test.api.Deployment; | |
| 45 | +import org.jboss.arquillian.junit.Arquillian; | |
| 46 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | |
| 47 | +import org.junit.Test; | |
| 48 | +import org.junit.runner.RunWith; | |
| 49 | + | |
| 50 | +import test.Tests; | |
| 51 | +import br.gov.frameworkdemoiselle.security.AuthenticationException; | |
| 52 | +import br.gov.frameworkdemoiselle.security.SecurityContext; | |
| 53 | +import configuration.resource.ConfigurationResourceTest; | |
| 54 | + | |
| 55 | +@RunWith(Arquillian.class) | |
| 56 | +public class LoginErrorAuthenticatorTest { | |
| 57 | + | |
| 58 | + @Inject | |
| 59 | + private SecurityContext context; | |
| 60 | + | |
| 61 | + @Deployment | |
| 62 | + public static JavaArchive createDeployment() { | |
| 63 | + JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); | |
| 64 | + deployment.addClass(LoginErrorAuthenticator.class); | |
| 65 | + return deployment; | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Test | |
| 69 | + public void errorDuringLogin() { | |
| 70 | + try { | |
| 71 | + context.login(); | |
| 72 | + fail("Login deveria disparar exceção de runtime"); | |
| 73 | + | |
| 74 | + } catch (AuthenticationException cause) { | |
| 75 | + assertEquals(RuntimeException.class, cause.getCause().getClass()); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | +} | ... | ... |
impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticator.java
0 → 100644
| ... | ... | @@ -0,0 +1,78 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package security.athentication.error; | |
| 38 | + | |
| 39 | +import br.gov.frameworkdemoiselle.security.Authenticator; | |
| 40 | +import br.gov.frameworkdemoiselle.security.User; | |
| 41 | + | |
| 42 | +public class LogoutErrorAuthenticator implements Authenticator { | |
| 43 | + | |
| 44 | + private static final long serialVersionUID = 1L; | |
| 45 | + | |
| 46 | + private User currentUser; | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void authenticate() { | |
| 50 | + this.currentUser = new User() { | |
| 51 | + | |
| 52 | + private static final long serialVersionUID = 1L; | |
| 53 | + | |
| 54 | + public String getId() { | |
| 55 | + return "demoiselle"; | |
| 56 | + } | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public Object getAttribute(Object key) { | |
| 60 | + return null; | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + public void setAttribute(Object key, Object value) { | |
| 65 | + } | |
| 66 | + }; | |
| 67 | + } | |
| 68 | + | |
| 69 | + @Override | |
| 70 | + public void unauthenticate() { | |
| 71 | + throw new RuntimeException(); | |
| 72 | + } | |
| 73 | + | |
| 74 | + @Override | |
| 75 | + public User getUser() { | |
| 76 | + return currentUser; | |
| 77 | + } | |
| 78 | +} | ... | ... |
impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticatorTest.java
0 → 100644
| ... | ... | @@ -0,0 +1,82 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package security.athentication.error; | |
| 38 | + | |
| 39 | +import static junit.framework.Assert.assertEquals; | |
| 40 | +import static junit.framework.Assert.assertTrue; | |
| 41 | +import static junit.framework.Assert.fail; | |
| 42 | + | |
| 43 | +import javax.inject.Inject; | |
| 44 | + | |
| 45 | +import org.jboss.arquillian.container.test.api.Deployment; | |
| 46 | +import org.jboss.arquillian.junit.Arquillian; | |
| 47 | +import org.jboss.shrinkwrap.api.spec.JavaArchive; | |
| 48 | +import org.junit.Test; | |
| 49 | +import org.junit.runner.RunWith; | |
| 50 | + | |
| 51 | +import test.Tests; | |
| 52 | +import br.gov.frameworkdemoiselle.security.AuthenticationException; | |
| 53 | +import br.gov.frameworkdemoiselle.security.SecurityContext; | |
| 54 | +import configuration.resource.ConfigurationResourceTest; | |
| 55 | + | |
| 56 | +@RunWith(Arquillian.class) | |
| 57 | +public class LogoutErrorAuthenticatorTest { | |
| 58 | + | |
| 59 | + @Inject | |
| 60 | + private SecurityContext context; | |
| 61 | + | |
| 62 | + @Deployment | |
| 63 | + public static JavaArchive createDeployment() { | |
| 64 | + JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); | |
| 65 | + deployment.addClass(LogoutErrorAuthenticator.class); | |
| 66 | + return deployment; | |
| 67 | + } | |
| 68 | + | |
| 69 | + @Test | |
| 70 | + public void errorDuringLogout() { | |
| 71 | + try { | |
| 72 | + context.login(); | |
| 73 | + assertTrue(context.isLoggedIn()); | |
| 74 | + context.logout(); | |
| 75 | + fail("Logout deveria disparar exceção de runtime"); | |
| 76 | + | |
| 77 | + } catch (AuthenticationException cause) { | |
| 78 | + assertEquals(RuntimeException.class, cause.getCause().getClass()); | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | +} | ... | ... |