From 714481a6ac93d68a422e6dd0f4a53724663e3822 Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Thu, 16 Jul 2009 15:40:58 +0000 Subject: [PATCH] Merged V3.2 to HEAD 15232: Fix failing unit test - Need to test against authentication manager in alfrescoNtlm subsystem git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15235 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../security/authentication/AuthenticationTest.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java index 3d8459f6fa..ec177c75c7 100644 --- a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java +++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java @@ -48,6 +48,8 @@ import net.sf.acegisecurity.providers.dao.SaltSource; import org.alfresco.model.ContentModel; import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.repo.management.subsystems.ApplicationContextFactory; +import org.alfresco.repo.management.subsystems.ChildApplicationContextManager; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.InMemoryTicketComponentImpl.ExpiryMode; import org.alfresco.repo.security.authentication.InMemoryTicketComponentImpl.Ticket; @@ -97,8 +99,6 @@ public class AuthenticationTest extends TestCase private AuthenticationManager authenticationManager; - private SaltSource saltSource; - private TicketComponent ticketComponent; private SimpleCache ticketsCache; @@ -152,8 +152,11 @@ public class AuthenticationTest extends TestCase ticketsCache = (SimpleCache) ctx.getBean("ticketsCache"); dao = (MutableAuthenticationDao) ctx.getBean("authenticationDao"); - authenticationManager = (AuthenticationManager) ctx.getBean("authenticationManager"); - saltSource = (SaltSource) ctx.getBean("saltSource"); + + // Let's look inside the alfresco authentication subsystem to get the DAO-wired authentication manager + ChildApplicationContextManager authenticationChain = (ChildApplicationContextManager) ctx.getBean("Authentication"); + ApplicationContext subsystem = authenticationChain.getApplicationContext(authenticationChain.getInstanceIds().iterator().next()); + authenticationManager = (AuthenticationManager) subsystem.getBean("authenticationManager"); transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName()); userTransaction = transactionService.getUserTransaction(); @@ -412,7 +415,7 @@ public class AuthenticationTest extends TestCase assertTrue(AndyDetails.isCredentialsNonExpired()); assertTrue(AndyDetails.isEnabled()); assertNotSame("cabbage", AndyDetails.getPassword()); - assertEquals(AndyDetails.getPassword(), passwordEncoder.encodePassword("cabbage", saltSource.getSalt(AndyDetails))); + assertEquals(AndyDetails.getPassword(), passwordEncoder.encodePassword("cabbage", dao.getSalt(AndyDetails))); assertEquals(1, AndyDetails.getAuthorities().length); // Object oldSalt = dao.getSalt(AndyDetails);