Merged 5.2.0 (5.2.0) to HEAD (5.2)

134066 mward: Merged 5.2.N (5.2.1) to 5.2.0 (5.2.0)
      134044 mward: REPO-1773: Validate ticket API call returns incorrect body with 404 status code


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@134205 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2017-01-11 10:37:23 +00:00
parent 5584458b2f
commit 282a62c418
2 changed files with 10 additions and 5 deletions

View File

@@ -35,6 +35,7 @@ import org.alfresco.rest.api.People;
import org.alfresco.rest.api.model.LoginTicket; import org.alfresco.rest.api.model.LoginTicket;
import org.alfresco.rest.api.model.LoginTicketResponse; import org.alfresco.rest.api.model.LoginTicketResponse;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; 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.core.exceptions.PermissionDeniedException;
import org.alfresco.rest.framework.resource.parameters.Parameters; import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rest.framework.webscripts.WithResponse; import org.alfresco.rest.framework.webscripts.WithResponse;
@@ -114,12 +115,12 @@ public class AuthenticationsImpl implements Authentications
// or the user is not fully authenticated // or the user is not fully authenticated
if (currentUser == null || !currentUser.equals(ticketUser)) 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) catch (AuthenticationException e)
{ {
withResponse.setStatus(Status.STATUS_NOT_FOUND); throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket });
} }
LoginTicketResponse response = new LoginTicketResponse(); LoginTicketResponse response = new LoginTicketResponse();
response.setId(ticket); response.setId(ticket);
@@ -144,7 +145,7 @@ public class AuthenticationsImpl implements Authentications
// or the user is not fully authenticated // or the user is not fully authenticated
if (currentUser == null || !currentUser.equals(ticketUser)) if (currentUser == null || !currentUser.equals(ticketUser))
{ {
withResponse.setStatus(Status.STATUS_NOT_FOUND); throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket });
} }
else else
{ {
@@ -154,7 +155,7 @@ public class AuthenticationsImpl implements Authentications
} }
catch (AuthenticationException e) catch (AuthenticationException e)
{ {
withResponse.setStatus(Status.STATUS_NOT_FOUND); throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] { ticket });
} }
} }

View File

@@ -35,6 +35,7 @@ import org.alfresco.rest.api.model.LoginTicket;
import org.alfresco.rest.api.model.LoginTicketResponse; import org.alfresco.rest.api.model.LoginTicketResponse;
import org.alfresco.rest.api.sites.SiteEntityResource; import org.alfresco.rest.api.sites.SiteEntityResource;
import org.alfresco.rest.api.tests.client.HttpResponse; 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.PublicApiClient.Paging;
import org.alfresco.rest.api.tests.client.data.Document; import org.alfresco.rest.api.tests.client.data.Document;
import org.alfresco.rest.api.tests.client.data.Folder; import org.alfresco.rest.api.tests.client.data.Folder;
@@ -134,7 +135,10 @@ public class AuthenticationsTest extends AbstractSingleNetworkSiteTest
setRequestContext(user1); setRequestContext(user1);
// Check the ticket has been invalidated - the difference with the above is that the API call is authorized // 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 // Ticket has already been invalidated
delete(TICKETS_URL, People.DEFAULT_USER, ticket, null, TICKETS_API_NAME, 404); delete(TICKETS_URL, People.DEFAULT_USER, ticket, null, TICKETS_API_NAME, 404);