001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: SecurityImplTest.java,v $
031: * Revision 1.7 2005/10/11 18:53:07 colinmacleod
032: * Fixed some checkstyle and javadoc issues.
033: *
034: * Revision 1.6 2005/09/29 14:17:03 colinmacleod
035: * Split UserGroupDO off from GroupDO.
036: * Moved UserGroupDO, Right classes to security subproject (from
037: * addressbook).
038: * Centralized user right handling into Rights and RightsImpl.
039: *
040: * Revision 1.5 2005/09/15 10:23:23 colinmacleod
041: * Upgraded Maven to 1.1 (beta-2).
042: * Upgraded Hibernate to 3.0.5.
043: *
044: * Revision 1.4 2005/04/10 20:32:01 colinmacleod
045: * Added new themes.
046: * Changed id type to String.
047: * Changed i tag to em and b tag to strong.
048: * Improved PicoContainerFactory with NanoContainer scripts.
049: *
050: * Revision 1.3 2005/04/09 17:19:11 colinmacleod
051: * Changed copyright text to GPL v2 explicitly.
052: *
053: * Revision 1.2 2005/03/16 12:47:28 colinmacleod
054: * Fixed SecurityImpl constructor.
055: *
056: * Revision 1.1.1.1 2005/03/10 17:50:14 colinmacleod
057: * Restructured ivata op around Hibernate/PicoContainer.
058: * Renamed ivata groupware.
059: *
060: * Revision 1.4 2004/11/12 18:17:25 colinmacleod
061: * Ordered imports.
062: *
063: * Revision 1.3 2004/11/12 15:57:07 colinmacleod
064: * Removed dependencies on SSLEXT.
065: * Moved Persistence classes to ivata masks.
066: *
067: * Revision 1.2 2004/09/30 15:15:53 colinmacleod
068: * Split off addressbook elements into security subproject.
069: *
070: * Revision 1.1 2004/07/13 19:41:17 colinmacleod
071: * Moved project to POJOs from EJBs.
072: * Applied PicoContainer to services layer (replacing session EJBs).
073: * Applied Hibernate to persistence layer (replacing entity EJBs).
074: * -----------------------------------------------------------------------------
075: */
076: package com.ivata.groupware.admin.security;
077:
078: import com.ivata.groupware.admin.AdminTestCase;
079: import com.ivata.groupware.business.addressbook.person.PersonDO;
080: import com.ivata.mask.persistence.PersistenceSession;
081: import com.ivata.mask.persistence.QueryPersistenceManager;
082: import com.ivata.mask.util.SystemException;
083:
084: /**
085: * Test <code>SecurityImpl</code>.
086: *
087: * @author Colin MacLeod
088: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
089: * @since ivata groupware 0.10 (Jun 3, 2004)
090: * @version $Revision: 1.7 $
091: */
092: public class SecurityImplTest extends AdminTestCase {
093: /**
094: * Persistence manager, used to prepare/test object persistence.
095: */
096: private QueryPersistenceManager persistenceManager;
097: /**
098: * Persistence session, used to prepare/test object persistence.
099: */
100: private PersistenceSession persistenceSession;
101:
102: /**
103: * Person object (for testing person security).
104: */
105: private PersonDO person = null;
106:
107: /**
108: * Constructor for SecurityImplTest.
109: * @param arg0 {@inheritDoc}.
110: */
111: public SecurityImplTest(final String arg0) {
112: super (arg0);
113: }
114:
115: /**
116: * Prepare the test environment.
117: *
118: * @throws Exception Any exception which prevented the test from finishing.
119: */
120: protected synchronized void setUp() throws Exception {
121: super .setUp();
122: persistenceManager = getHibernateManager();
123: persistenceSession = getHibernateSession();
124: /*TODO SecurityServer server =
125: * new PlainTextSecurityServer(persistenceManager);
126: security = new SecurityImpl(persistenceManager, server,
127: new DefaultMaskFactory(new DefaultFieldValueConvertorFactory()),
128: Boolean.FALSE);*/
129: }
130:
131: /**
132: * {@inheritDoc}.
133: *
134: * @throws Exception Any exception preventing orderly finalization.
135: */
136: protected void tearDown() throws Exception {
137: super .tearDown();
138: if (person != null) {
139: persistenceManager.remove(persistenceSession, person);
140: }
141: }
142:
143: /*TODO private PersonDO createTestPerson() throws SystemException {
144: person = new PersonDO();
145: person.setCompany("test company");
146: person.setFileAs("file as");
147: person.setFirstNames("first names");
148: person.setLastName("security test");
149: persistenceManager.add(persistenceSession, person);
150: return person;
151: }*/
152:
153: /**
154: * Test {@link SecurityImpl#addUserToPerson SecurityImpl.addUserToPerson}.
155: * @throws SystemException see
156: * {@link SecurityImpl#addUserToPerson SecurityImpl.addUserToPerson}.
157: */
158: public void testAddUserToPerson() throws SystemException {
159: /* TODO
160: PersonDO person = createTestPerson();
161:
162: security.addUserToPerson(
163: securitySession, person, "security test user", true);
164:
165: String id = person.getId();
166: person = (PersonDO)
167: persistenceManager.findByPrimaryKey(
168: persistenceSession, PersonDO.class,
169: id);
170: assertEquals(id, person.getId());
171: UserDO user = (UserDO)
172: persistenceManager.findInstance(
173: persistenceSession, "adminUserByName",
174: new Object [] {"security test user"});
175: assertNotNull(user.getId());
176: assertEquals(person.getUser(), user);
177: assertEquals("security test user", user.getName());
178: assertTrue(user.isEnabled());
179: assertFalse(user.isDeleted());
180: */
181: }
182: }
|