diff --git a/impl/core/src/test/java/security/athentication/error/ErrorAuthenticator.java b/impl/core/src/test/java/security/athentication/error/ErrorAuthenticator.java deleted file mode 100644 index f6d1412..0000000 --- a/impl/core/src/test/java/security/athentication/error/ErrorAuthenticator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package security.athentication.error; - -import br.gov.frameworkdemoiselle.security.Authenticator; -import br.gov.frameworkdemoiselle.security.User; - -public class ErrorAuthenticator implements Authenticator { - - private static final long serialVersionUID = 1L; - - @Override - public void authenticate() { - throw new RuntimeException(); - } - - @Override - public void unauthenticate() { - throw new RuntimeException(); - } - - @Override - public User getUser() { - return null; - } -} diff --git a/impl/core/src/test/java/security/athentication/error/ErrorAuthenticatorTest.java b/impl/core/src/test/java/security/athentication/error/ErrorAuthenticatorTest.java deleted file mode 100644 index bb0e1c4..0000000 --- a/impl/core/src/test/java/security/athentication/error/ErrorAuthenticatorTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package security.athentication.error; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.fail; - -import javax.inject.Inject; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import test.Tests; -import br.gov.frameworkdemoiselle.security.AuthenticationException; -import br.gov.frameworkdemoiselle.security.SecurityContext; -import configuration.resource.ConfigurationResourceTest; - -@RunWith(Arquillian.class) -public class ErrorAuthenticatorTest { - - @Inject - private SecurityContext context; - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); - deployment.addClass(ErrorAuthenticator.class); - return deployment; - } - - @Test - public void errorDuringLogin() { - try { - context.login(); - fail("Login deveria disparar exceção de runtime"); - - } catch (AuthenticationException cause) { - assertEquals(RuntimeException.class, cause.getCause().getClass()); - } - } - - @Test - public void errorDuringLogout() { - try { - context.login(); - fail("Logout deveria disparar exceção de runtime"); - - } catch (AuthenticationException cause) { - assertEquals(RuntimeException.class, cause.getCause().getClass()); - } - } - -} diff --git a/impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticator.java b/impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticator.java new file mode 100644 index 0000000..e25749b --- /dev/null +++ b/impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticator.java @@ -0,0 +1,60 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package security.athentication.error; + +import br.gov.frameworkdemoiselle.security.Authenticator; +import br.gov.frameworkdemoiselle.security.User; + +public class LoginErrorAuthenticator implements Authenticator { + + private static final long serialVersionUID = 1L; + + @Override + public void authenticate() { + throw new RuntimeException(); + } + + @Override + public void unauthenticate() { + throw new RuntimeException(); + } + + @Override + public User getUser() { + return null; + } +} diff --git a/impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticatorTest.java b/impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticatorTest.java new file mode 100644 index 0000000..8157620 --- /dev/null +++ b/impl/core/src/test/java/security/athentication/error/LoginErrorAuthenticatorTest.java @@ -0,0 +1,79 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package security.athentication.error; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.fail; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.security.AuthenticationException; +import br.gov.frameworkdemoiselle.security.SecurityContext; +import configuration.resource.ConfigurationResourceTest; + +@RunWith(Arquillian.class) +public class LoginErrorAuthenticatorTest { + + @Inject + private SecurityContext context; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); + deployment.addClass(LoginErrorAuthenticator.class); + return deployment; + } + + @Test + public void errorDuringLogin() { + try { + context.login(); + fail("Login deveria disparar exceção de runtime"); + + } catch (AuthenticationException cause) { + assertEquals(RuntimeException.class, cause.getCause().getClass()); + } + } + +} diff --git a/impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticator.java b/impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticator.java new file mode 100644 index 0000000..4f86293 --- /dev/null +++ b/impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticator.java @@ -0,0 +1,78 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package security.athentication.error; + +import br.gov.frameworkdemoiselle.security.Authenticator; +import br.gov.frameworkdemoiselle.security.User; + +public class LogoutErrorAuthenticator implements Authenticator { + + private static final long serialVersionUID = 1L; + + private User currentUser; + + @Override + public void authenticate() { + this.currentUser = new User() { + + private static final long serialVersionUID = 1L; + + public String getId() { + return "demoiselle"; + } + + @Override + public Object getAttribute(Object key) { + return null; + } + + @Override + public void setAttribute(Object key, Object value) { + } + }; + } + + @Override + public void unauthenticate() { + throw new RuntimeException(); + } + + @Override + public User getUser() { + return currentUser; + } +} diff --git a/impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticatorTest.java b/impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticatorTest.java new file mode 100644 index 0000000..006977a --- /dev/null +++ b/impl/core/src/test/java/security/athentication/error/LogoutErrorAuthenticatorTest.java @@ -0,0 +1,82 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package security.athentication.error; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; +import static junit.framework.Assert.fail; + +import javax.inject.Inject; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.security.AuthenticationException; +import br.gov.frameworkdemoiselle.security.SecurityContext; +import configuration.resource.ConfigurationResourceTest; + +@RunWith(Arquillian.class) +public class LogoutErrorAuthenticatorTest { + + @Inject + private SecurityContext context; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); + deployment.addClass(LogoutErrorAuthenticator.class); + return deployment; + } + + @Test + public void errorDuringLogout() { + try { + context.login(); + assertTrue(context.isLoggedIn()); + context.logout(); + fail("Logout deveria disparar exceção de runtime"); + + } catch (AuthenticationException cause) { + assertEquals(RuntimeException.class, cause.getCause().getClass()); + } + } + +} -- libgit2 0.21.2