use of com.formkiq.stacks.client.requests.GetDocumentsRequest in project formkiq-core by formkiq.
the class DocumentsRequestTest method testGet01.
/**
* Get Not existing file.
*
* @throws Exception Exception
*/
@Test(timeout = TEST_TIMEOUT)
public void testGet01() throws Exception {
for (FormKiqClientV1 client : getFormKiqClients()) {
// given
GetDocumentsRequest request = new GetDocumentsRequest().date(new Date());
// when
HttpResponse<String> response = client.getDocumentsAsHttpResponse(request);
// then
assertEquals(STATUS_OK, response.statusCode());
assertRequestCorsHeaders(response.headers());
assertTrue(response.body().contains("\"documents\":["));
}
}
use of com.formkiq.stacks.client.requests.GetDocumentsRequest in project formkiq-core by formkiq.
the class DocumentsRequestTest method testGet03.
/**
* Get Not existing file. Test user with 'USERS' roles with/out siteid
*
* @throws Exception Exception
*/
@Test(timeout = TEST_TIMEOUT)
public void testGet03() throws Exception {
// given
final String siteId = "finance";
AuthenticationResultType token = login(USER_EMAIL, USER_PASSWORD);
FormKiqClientConnection connection = new FormKiqClientConnection(getRootHttpUrl()).cognitoIdToken(token.idToken()).header("Origin", Arrays.asList("http://localhost")).header("Access-Control-Request-Method", Arrays.asList("GET"));
FormKiqClientV1 client = new FormKiqClientV1(connection);
GetDocumentsRequest request = new GetDocumentsRequest().date(new Date());
// when
final HttpResponse<String> responseNoSiteId = client.getDocumentsAsHttpResponse(request);
final HttpResponse<String> responseSiteId = client.getDocumentsAsHttpResponse(request.siteId(siteId));
// then
assertEquals(STATUS_OK, responseNoSiteId.statusCode());
assertRequestCorsHeaders(responseNoSiteId.headers());
assertTrue(responseNoSiteId.body().contains("\"documents\":["));
assertEquals(STATUS_FORBIDDEN, responseSiteId.statusCode());
assertRequestCorsHeaders(responseSiteId.headers());
assertEquals("{\"message\":\"Access Denied\"}", responseSiteId.body());
}
Aggregations