use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class LoginTest method testAuthentication.
/**
* Positive test - login and retrieve a ticket via get - return xml,
* - via get method
* validate ticket
* logout
* fail to validate ticket
* fail to get ticket
*/
public void testAuthentication() throws Exception {
/**
* Login via get method to return xml
*/
String loginURL = "/api/login?u=" + USER_ONE + "&pw=" + USER_ONE;
Response resp = sendRequest(new GetRequest(loginURL), Status.STATUS_OK);
String xmlFragment = resp.getContentAsString();
assertNotNull("xmlFragment");
assertTrue("xmlFragment contains ticket", xmlFragment.contains("<ticket>"));
String ticket = parseTicket(xmlFragment);
String ticketURL = "/api/login/ticket/" + ticket;
/**
* Negative test - validate as AuthenticationUtil.getAdminUserName() - should fail with a 404
*/
setDefaultRunAs(AuthenticationUtil.getAdminUserName());
sendRequest(new GetRequest(ticketURL), Status.STATUS_NOT_FOUND);
/**
* Validate the ticket - should succeed
*/
setDefaultRunAs(USER_ONE);
sendRequest(new GetRequest(ticketURL), Status.STATUS_OK);
/**
* Logout
*/
sendRequest(new DeleteRequest(ticketURL), Status.STATUS_OK);
/**
* Validate the ticket - should fail now
*/
sendRequest(new GetRequest(ticketURL), Status.STATUS_NOT_FOUND);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ReadOnlyTransactionInGetRestApiTest method testGetSiteLink.
public void testGetSiteLink() throws Exception {
Response response = sendRequest(new GetRequest(URL_GET_SITE_LINK), 404);
logResponse(response);
assertEquals(Status.STATUS_NOT_FOUND, response.getStatus());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ReadOnlyTransactionInGetRestApiTest method testGetSiteForumPosts.
public void testGetSiteForumPosts() throws Exception {
Response response = sendRequest(new GetRequest(URL_GET_SITE_FORUM_POSTS), 200);
logResponse(response);
assertEquals(Status.STATUS_OK, response.getStatus());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class ReadOnlyTransactionInGetRestApiTest method testGetSiteBlog.
public void testGetSiteBlog() throws Exception {
// TODO: Fixme - This REST API still requires a readwrite transaction to be successful
// Also add tests for all other blog GET REST APIs
Response response = sendRequest(new GetRequest(URL_GET_SITE_BLOG), 200);
logResponse(response);
assertEquals(Status.STATUS_OK, response.getStatus());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class RepositoryContainerTest method testRunAsAdmin.
/**
* Person should be current user irrespective of runas user.
*/
public void testRunAsAdmin() throws Exception {
authenticationComponent.setCurrentUser(USER_ONE);
// No runas specified within our webscript descriptor
Response response = sendRequest(new GetRequest("/test/runas"), STATUS_OK);
assertEquals(USER_ONE, response.getContentAsString());
authenticationComponent.setCurrentUser(USER_TWO);
// runas "Admin" specified within our webscript descriptor
response = sendRequest(new GetRequest("/test/runasadmin"), STATUS_OK);
assertEquals(USER_TWO, response.getContentAsString());
authenticationComponent.setSystemUserAsCurrentUser();
}
Aggregations