diff --git a/source/java/org/alfresco/rest/api/impl/AuthenticationsImpl.java b/source/java/org/alfresco/rest/api/impl/AuthenticationsImpl.java index dafc57d093..2a6d4dfb0e 100644 --- a/source/java/org/alfresco/rest/api/impl/AuthenticationsImpl.java +++ b/source/java/org/alfresco/rest/api/impl/AuthenticationsImpl.java @@ -35,6 +35,7 @@ import org.alfresco.rest.api.People; import org.alfresco.rest.api.model.LoginTicket; import org.alfresco.rest.api.model.LoginTicketResponse; import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; +import org.alfresco.rest.framework.core.exceptions.NotFoundException; import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException; import org.alfresco.rest.framework.resource.parameters.Parameters; import org.alfresco.rest.framework.webscripts.WithResponse; @@ -114,12 +115,12 @@ public class AuthenticationsImpl implements Authentications // or the user is not fully authenticated if (currentUser == null || !currentUser.equals(ticketUser)) { - withResponse.setStatus(Status.STATUS_NOT_FOUND); + throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket }); } } catch (AuthenticationException e) { - withResponse.setStatus(Status.STATUS_NOT_FOUND); + throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket }); } LoginTicketResponse response = new LoginTicketResponse(); response.setId(ticket); @@ -144,7 +145,7 @@ public class AuthenticationsImpl implements Authentications // or the user is not fully authenticated if (currentUser == null || !currentUser.equals(ticketUser)) { - withResponse.setStatus(Status.STATUS_NOT_FOUND); + throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket }); } else { @@ -154,7 +155,7 @@ public class AuthenticationsImpl implements Authentications } catch (AuthenticationException e) { - withResponse.setStatus(Status.STATUS_NOT_FOUND); + throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket }); } } diff --git a/source/test-java/org/alfresco/rest/api/tests/AuthenticationsTest.java b/source/test-java/org/alfresco/rest/api/tests/AuthenticationsTest.java index 040aadeab9..61ce4829d0 100644 --- a/source/test-java/org/alfresco/rest/api/tests/AuthenticationsTest.java +++ b/source/test-java/org/alfresco/rest/api/tests/AuthenticationsTest.java @@ -35,6 +35,7 @@ import org.alfresco.rest.api.model.LoginTicket; import org.alfresco.rest.api.model.LoginTicketResponse; import org.alfresco.rest.api.sites.SiteEntityResource; import org.alfresco.rest.api.tests.client.HttpResponse; +import org.alfresco.rest.api.tests.client.PublicApiClient; import org.alfresco.rest.api.tests.client.PublicApiClient.Paging; import org.alfresco.rest.api.tests.client.data.Document; import org.alfresco.rest.api.tests.client.data.Folder; @@ -134,7 +135,10 @@ public class AuthenticationsTest extends AbstractSingleNetworkSiteTest setRequestContext(user1); // Check the ticket has been invalidated - the difference with the above is that the API call is authorized - getSingle(TICKETS_URL, People.DEFAULT_USER, ticket, null, TICKETS_API_NAME, 404); + response = getSingle(TICKETS_URL, People.DEFAULT_USER, ticket, null, TICKETS_API_NAME, 404); + PublicApiClient.ExpectedErrorResponse error = RestApiUtil.parseErrorResponse(response.getJsonResponse()); + // Double check that we've retrieved a standard error response (REPO-1773) + assertEquals(404, error.getStatusCode()); // Ticket has already been invalidated delete(TICKETS_URL, People.DEFAULT_USER, ticket, null, TICKETS_API_NAME, 404);