From 6b5389eb6dd02348c6fe935a0fbd41448733dc63 Mon Sep 17 00:00:00 2001 From: Cleverson Sacramento Date: Mon, 15 Apr 2013 15:49:14 -0300 Subject: [PATCH] Início da implementação dos testes de segurança --- impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java | 4 ++-- impl/core/src/test/java/security/SecurityTests.java | 60 ------------------------------------------------------------ impl/core/src/test/java/security/athentication/ambiguity/AmbiguousAuthenticatorTest.java | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/security/athentication/ambiguity/DuplicatedCustomAuthenticator.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/security/athentication/custom/CustomAuthenticator.java | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/security/athentication/custom/CustomAuthenticatorTest.java | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/security/athentication/selection/SelectedAuthenticatorTest.java | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/security/athentication/undefined/UndefinedAuthenticatorTest.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ impl/core/src/test/java/util/Tests.java | 5 ++++- impl/core/src/test/resources/security/authenticator/selection/demoiselle.properties | 36 ++++++++++++++++++++++++++++++++++++ 10 files changed, 487 insertions(+), 63 deletions(-) delete mode 100644 impl/core/src/test/java/security/SecurityTests.java create mode 100644 impl/core/src/test/java/security/athentication/ambiguity/AmbiguousAuthenticatorTest.java create mode 100644 impl/core/src/test/java/security/athentication/ambiguity/DuplicatedCustomAuthenticator.java create mode 100644 impl/core/src/test/java/security/athentication/custom/CustomAuthenticator.java create mode 100644 impl/core/src/test/java/security/athentication/custom/CustomAuthenticatorTest.java create mode 100644 impl/core/src/test/java/security/athentication/selection/SelectedAuthenticatorTest.java create mode 100644 impl/core/src/test/java/security/athentication/undefined/UndefinedAuthenticatorTest.java create mode 100644 impl/core/src/test/resources/security/authenticator/selection/demoiselle.properties diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java index f3fb999..9f56cba 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java @@ -85,8 +85,8 @@ public class DefaultAuthenticator implements Authenticator { } private DemoiselleException getException() { - return new DemoiselleException(getBundle().getString("authenticator-not-defined", - SecurityContext.class.getSimpleName())); + return new AuthenticationException(getBundle().getString("authenticator-not-defined", + SecurityContext.class.getSimpleName()), new ClassNotFoundException()); } private static ResourceBundle getBundle() { diff --git a/impl/core/src/test/java/security/SecurityTests.java b/impl/core/src/test/java/security/SecurityTests.java deleted file mode 100644 index 1b2f08a..0000000 --- a/impl/core/src/test/java/security/SecurityTests.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; - -import java.io.File; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.EmptyAsset; -import org.jboss.shrinkwrap.api.spec.JavaArchive; - -public final class SecurityTests { - - private SecurityTests() { - } - - public static JavaArchive createDeployment(Class baseClass) { - return ShrinkWrap - .create(JavaArchive.class) - .addPackages(true, "br") - .addPackages(true, baseClass.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") - .addAsManifestResource( - new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), - "services/javax.enterprise.inject.spi.Extension"); - } -} diff --git a/impl/core/src/test/java/security/athentication/ambiguity/AmbiguousAuthenticatorTest.java b/impl/core/src/test/java/security/athentication/ambiguity/AmbiguousAuthenticatorTest.java new file mode 100644 index 0000000..bdfafc6 --- /dev/null +++ b/impl/core/src/test/java/security/athentication/ambiguity/AmbiguousAuthenticatorTest.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.ambiguity; + +import static junit.framework.Assert.assertEquals; + +import javax.enterprise.inject.AmbiguousResolutionException; +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 security.athentication.custom.CustomAuthenticator; +import util.Tests; +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.security.SecurityContext; +import configuration.resource.ConfigurationResourceTest; + +@RunWith(Arquillian.class) +public class AmbiguousAuthenticatorTest { + + @Inject + private SecurityContext context; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); + deployment.addClass(CustomAuthenticator.class); + deployment.addClass(DuplicatedCustomAuthenticator.class); + return deployment; + } + + @Test + public void ambiguousAuthenticatorStrategy() { + try { + context.isLoggedIn(); + } catch (DemoiselleException cause) { + assertEquals(AmbiguousResolutionException.class, cause.getCause().getClass()); + } + } +} diff --git a/impl/core/src/test/java/security/athentication/ambiguity/DuplicatedCustomAuthenticator.java b/impl/core/src/test/java/security/athentication/ambiguity/DuplicatedCustomAuthenticator.java new file mode 100644 index 0000000..7260b81 --- /dev/null +++ b/impl/core/src/test/java/security/athentication/ambiguity/DuplicatedCustomAuthenticator.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.ambiguity; + +import java.security.Principal; + +import br.gov.frameworkdemoiselle.security.AuthenticationException; +import br.gov.frameworkdemoiselle.security.Authenticator; + +public class DuplicatedCustomAuthenticator implements Authenticator { + + private static final long serialVersionUID = 1L; + + @Override + public void authenticate() throws AuthenticationException { + } + + @Override + public void unAuthenticate() { + } + + @Override + public Principal getUser() { + return null; + } +} diff --git a/impl/core/src/test/java/security/athentication/custom/CustomAuthenticator.java b/impl/core/src/test/java/security/athentication/custom/CustomAuthenticator.java new file mode 100644 index 0000000..933ae66 --- /dev/null +++ b/impl/core/src/test/java/security/athentication/custom/CustomAuthenticator.java @@ -0,0 +1,69 @@ +/* + * 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.custom; + +import java.security.Principal; + +import br.gov.frameworkdemoiselle.security.AuthenticationException; +import br.gov.frameworkdemoiselle.security.Authenticator; + +public class CustomAuthenticator implements Authenticator { + + private static final long serialVersionUID = 1L; + + private Principal currentUser; + + @Override + public void authenticate() throws AuthenticationException { + this.currentUser = new Principal() { + + public String getName() { + return "demoiselle"; + } + }; + } + + @Override + public void unAuthenticate() { + this.currentUser = null; + } + + @Override + public Principal getUser() { + return this.currentUser; + } +} diff --git a/impl/core/src/test/java/security/athentication/custom/CustomAuthenticatorTest.java b/impl/core/src/test/java/security/athentication/custom/CustomAuthenticatorTest.java new file mode 100644 index 0000000..ec8c49e --- /dev/null +++ b/impl/core/src/test/java/security/athentication/custom/CustomAuthenticatorTest.java @@ -0,0 +1,89 @@ +/* + * 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.custom; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +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 util.Tests; +import br.gov.frameworkdemoiselle.security.SecurityContext; +import configuration.resource.ConfigurationResourceTest; + +@RunWith(Arquillian.class) +public class CustomAuthenticatorTest { + + @Inject + private SecurityContext context; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); + deployment.addClass(CustomAuthenticator.class); + return deployment; + } + + @Test + public void unauthenticated() { + assertFalse(context.isLoggedIn()); + assertNull(context.getCurrentUser()); + } + + @Test + public void loginProcess() { + context.login(); + assertTrue(context.isLoggedIn()); + assertEquals("demoiselle", context.getCurrentUser().getName()); + } + + @Test + public void logoutProcess() { + context.login(); + context.logout(); + assertFalse(context.isLoggedIn()); + assertNull(context.getCurrentUser()); + } +} diff --git a/impl/core/src/test/java/security/athentication/selection/SelectedAuthenticatorTest.java b/impl/core/src/test/java/security/athentication/selection/SelectedAuthenticatorTest.java new file mode 100644 index 0000000..c799210 --- /dev/null +++ b/impl/core/src/test/java/security/athentication/selection/SelectedAuthenticatorTest.java @@ -0,0 +1,77 @@ +/* + * 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.selection; + +import static junit.framework.Assert.assertEquals; + +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 security.athentication.ambiguity.DuplicatedCustomAuthenticator; +import security.athentication.custom.CustomAuthenticator; +import util.Tests; +import br.gov.frameworkdemoiselle.security.SecurityContext; +import configuration.resource.ConfigurationResourceTest; + +@RunWith(Arquillian.class) +public class SelectedAuthenticatorTest { + + private static final String PATH = "src/test/resources/security/authenticator/selection"; + + @Inject + private SecurityContext context; + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); + deployment.addClass(CustomAuthenticator.class); + deployment.addClass(DuplicatedCustomAuthenticator.class); + deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); + return deployment; + } + + @Test + public void selectedAuthenticatorStrategy() { + context.login(); + assertEquals("demoiselle", context.getCurrentUser().getName()); + } +} diff --git a/impl/core/src/test/java/security/athentication/undefined/UndefinedAuthenticatorTest.java b/impl/core/src/test/java/security/athentication/undefined/UndefinedAuthenticatorTest.java new file mode 100644 index 0000000..3fe88ab --- /dev/null +++ b/impl/core/src/test/java/security/athentication/undefined/UndefinedAuthenticatorTest.java @@ -0,0 +1,72 @@ +/* + * 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.undefined; + +import static junit.framework.Assert.assertEquals; + +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 util.Tests; +import br.gov.frameworkdemoiselle.security.AuthenticationException; +import br.gov.frameworkdemoiselle.security.SecurityContext; + +@RunWith(Arquillian.class) +public class UndefinedAuthenticatorTest { + + @Inject + private SecurityContext context; + + @Deployment + public static JavaArchive createDeployment() { + return Tests.createDeployment(); + } + + @Test + public void undefinedAuthenticatorStrategy() { + try { + context.isLoggedIn(); + } catch (AuthenticationException cause) { + assertEquals(ClassNotFoundException.class, cause.getCause().getClass()); + } + } +} diff --git a/impl/core/src/test/java/util/Tests.java b/impl/core/src/test/java/util/Tests.java index e849132..59fb919 100644 --- a/impl/core/src/test/java/util/Tests.java +++ b/impl/core/src/test/java/util/Tests.java @@ -49,10 +49,13 @@ public final class Tests { } public static JavaArchive createDeployment(Class baseClass) { + return createDeployment().addPackages(true, baseClass.getPackage()); + } + + public static JavaArchive createDeployment() { return ShrinkWrap .create(JavaArchive.class) .addPackages(true, "br") - .addPackages(true, baseClass.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsManifestResource( new File("src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension"), diff --git a/impl/core/src/test/resources/security/authenticator/selection/demoiselle.properties b/impl/core/src/test/resources/security/authenticator/selection/demoiselle.properties new file mode 100644 index 0000000..56a8947 --- /dev/null +++ b/impl/core/src/test/resources/security/authenticator/selection/demoiselle.properties @@ -0,0 +1,36 @@ +# 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. + +frameworkdemoiselle.security.authenticator.class=security.athentication.custom.CustomAuthenticator \ No newline at end of file -- libgit2 0.21.2