mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-13194: Fix failing unit test + restore ability for web scripts to work on a read-only repository
- Authentication work must settle for read only transaction if system is read only - No need for RemoteAlfrescoTicketServiceTest to start its own read-only transaction! git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@43407 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,8 +24,6 @@ import org.alfresco.repo.remoteconnector.LocalWebScriptConnectorServiceImpl;
|
||||
import org.alfresco.repo.remotecredentials.PasswordCredentialsInfoImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||
import org.alfresco.service.cmr.remotecredentials.BaseCredentialsInfo;
|
||||
import org.alfresco.service.cmr.remotecredentials.RemoteCredentialsService;
|
||||
@@ -53,7 +51,6 @@ public class RemoteAlfrescoTicketServiceTest extends BaseWebScriptTest
|
||||
private static final String INVALID_REMOTE_SYSTEM_ID = "testingInvalidRemoteSystem";
|
||||
|
||||
private MutableAuthenticationService authenticationService;
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
private PersonService personService;
|
||||
|
||||
private RemoteAlfrescoTicketService remoteAlfrescoTicketService;
|
||||
@@ -72,7 +69,6 @@ public class RemoteAlfrescoTicketServiceTest extends BaseWebScriptTest
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
this.retryingTransactionHelper = (RetryingTransactionHelper)getServer().getApplicationContext().getBean("retryingTransactionHelper");
|
||||
this.authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService");
|
||||
this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
|
||||
|
||||
@@ -386,19 +382,13 @@ public class RemoteAlfrescoTicketServiceTest extends BaseWebScriptTest
|
||||
creds.setRemotePassword("INVALID");
|
||||
remoteCredentialsService.updateCredentials(creds);
|
||||
|
||||
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
|
||||
public Void execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
remoteAlfrescoTicketService.refetchAlfrescoTicket(TEST_REMOTE_SYSTEM_ID);
|
||||
fail("Shouldn't be able to refetch with wrong details");
|
||||
}
|
||||
catch(AuthenticationException e) {}
|
||||
return null;
|
||||
}
|
||||
}, true, true);
|
||||
|
||||
try
|
||||
{
|
||||
remoteAlfrescoTicketService.refetchAlfrescoTicket(TEST_REMOTE_SYSTEM_ID);
|
||||
fail("Shouldn't be able to refetch with wrong details");
|
||||
}
|
||||
catch(AuthenticationException e) {}
|
||||
|
||||
// Check it was still marked as invalid, despite a read only transaction
|
||||
creds = (PasswordCredentialsInfoImpl)remoteCredentialsService.getPersonCredentials(TEST_REMOTE_SYSTEM_ID);
|
||||
assertEquals(false, creds.getLastAuthenticationSucceeded());
|
||||
|
@@ -52,6 +52,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -96,7 +97,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
||||
/** Component Dependencies */
|
||||
private Repository repository;
|
||||
private RepositoryImageResolver imageResolver;
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
private TransactionService transactionService;
|
||||
private RetryingTransactionHelper fallbackTransactionHelper;
|
||||
private AuthorityService authorityService;
|
||||
private DescriptorService descriptorService;
|
||||
@@ -137,15 +138,15 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
||||
{
|
||||
this.imageResolver = imageResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param retryingTransactionHelper
|
||||
*/
|
||||
public void setTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
|
||||
{
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param transactionService
|
||||
*/
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fallbackTransactionHelper an unlimited transaction helper used to generate error responses
|
||||
*/
|
||||
@@ -338,7 +339,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
||||
}
|
||||
};
|
||||
|
||||
if (retryingTransactionHelper.doInTransaction(authWork))
|
||||
if (transactionService.getRetryingTransactionHelper().doInTransaction(authWork, transactionService.isReadOnly()))
|
||||
{
|
||||
// Execute Web Script if authentication passed
|
||||
// The Web Script has its own txn management with potential runAs() user
|
||||
@@ -488,7 +489,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
||||
|
||||
try
|
||||
{
|
||||
retryingTransactionHelper.doInTransaction(work, readonly, requiresNew);
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(work, readonly, requiresNew);
|
||||
}
|
||||
catch (TooBusyException e)
|
||||
{
|
||||
@@ -648,7 +649,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer implements Ten
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>()
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
||||
{
|
||||
public Object execute() throws Exception
|
||||
{
|
||||
|
Reference in New Issue
Block a user