001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: TestSLAnnotationPermissions.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.security;
025:
026: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.security.ItfSecurityPermissionTester;
027: import org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.security.SFSBSecurityPermissionTester01;
028: import org.ow2.easybeans.tests.common.helper.EJBHelper;
029: import org.testng.annotations.BeforeMethod;
030: import org.testng.annotations.Test;
031:
032: /**
033: * Verifies if the container manages the security roles defined by annotation.
034: * The bean used during the tests is stateless. The chapter verified is the 17.
035: * @reference JSR 220- FINAL RELEASE
036: * @requirement Application Server must be running; the bean
037: * SLSBSecurityPermissionTester00 and SFSBSecurityRoles must be deployed.
038: * @setup gets the reference of SLSBSecurityPermissionTester00.
039: * @author Gisele Pinheiro Souza
040: * @author Eduardo Studzinski Estima de Castro
041: */
042: public class TestSLAnnotationPermissions {
043:
044: /**
045: * Bean used during the tests.
046: */
047: private ItfSecurityPermissionTester tester;
048:
049: /**
050: * Creates the stateful bean used during the tests.
051: * @throws Exception if an error occurs during the lookup.
052: */
053: @BeforeMethod
054: public void setup() throws Exception {
055: tester = EJBHelper.getBeanRemoteInstance(
056: SFSBSecurityPermissionTester01.class,
057: ItfSecurityPermissionTester.class);
058: }
059:
060: /**
061: * Verifies if it is possible to call a method with permitAll annotation.
062: * @input -
063: * @output the correct method execution.
064: */
065: @Test
066: public void testPermitAll() {
067: tester.testPermitAll();
068: }
069:
070: /**
071: * Verifies if it is not possible call a method with denyAll annotation.
072: * @input -
073: * @output the correct method execution. The EJBAccessException is verified in the server site.
074: */
075: @Test
076: public void testDenyAll() {
077: tester.testDenyAll();
078: }
079:
080: /**
081: * Verifies if a method with the allowsRoles annotation can be called by a
082: * bean that is defined in the annotation.
083: * @input -
084: * @output the correct method execution.
085: */
086: @Test
087: public void testAllowedRolesWithTwoRoles() {
088: tester.testAllowedRolesWithTwoRoles();
089: }
090:
091: /**
092: * Verifies if the container does not permit that a bean can call a method
093: * in which it has the access denied.
094: * @input -
095: * @output the correct method execution. The EJBAccessException is verified
096: * in the server site.
097: */
098: @Test
099: public void testAllowedRolesWithOneRole() {
100: tester.testAllowedRolesWithOneRole();
101: }
102: }
|