Search in sources :

Example 56 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class WorkspaceServiceTest method shouldUpdateTheWorkspace.

@Test
public void shouldUpdateTheWorkspace() throws Exception {
    final WorkspaceImpl workspace = createWorkspace(createConfigDto());
    when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
    when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
    final WorkspaceDto workspaceDto = DtoConverter.asDto(workspace);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(workspaceDto).when().put(SECURE_PATH + "/workspace/" + workspace.getId());
    assertEquals(response.getStatusCode(), 200);
    assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
    verify(validator).validateWorkspace(any());
}
Also used : Response(com.jayway.restassured.response.Response) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Test(org.testng.annotations.Test)

Example 57 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class UserServiceTest method shouldNotCreateUserFromEntityIfEntityIsNull.

@Test
public void shouldNotCreateUserFromEntityIfEntityIsNull() throws Exception {
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().contentType("application/json").post(SECURE_PATH + "/user");
    assertEquals(response.statusCode(), 400);
    assertEquals(unwrapError(response), "User required");
}
Also used : Response(com.jayway.restassured.response.Response) Test(org.testng.annotations.Test)

Example 58 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class UserServiceTest method shouldNotCreateUserFromEntityIfPasswordIsNotValid.

@Test
public void shouldNotCreateUserFromEntityIfPasswordIsNotValid() throws Exception {
    final UserDto newUser = newDto(UserDto.class).withEmail("test@codenvy.com").withName("test").withPassword("1");
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().body(newUser).contentType("application/json").post(SECURE_PATH + "/user");
    assertEquals(response.statusCode(), 400);
    assertEquals(unwrapError(response), "Password should contain at least 8 characters");
}
Also used : Response(com.jayway.restassured.response.Response) UserDto(org.eclipse.che.api.user.shared.dto.UserDto) Test(org.testng.annotations.Test)

Example 59 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class UserServiceTest method shouldUpdatePassword.

@Test
public void shouldUpdatePassword() throws Exception {
    final UserImpl testUser = copySubject();
    when(userManager.getById(testUser.getId())).thenReturn(testUser);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/x-www-form-urlencoded").body("password=password12345").when().post(SECURE_PATH + "/user/password");
    verify(userManager).update(userCaptor.capture());
    final User fetchedUser = userCaptor.getValue();
    assertEquals(fetchedUser.getPassword(), "password12345");
}
Also used : Response(com.jayway.restassured.response.Response) User(org.eclipse.che.api.core.model.user.User) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 60 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class UserServiceTest method shouldNotUpdatePasswordIfPasswordContainsLessThan8Chars.

@Test
public void shouldNotUpdatePasswordIfPasswordContainsLessThan8Chars() throws Exception {
    final UserImpl testUser = copySubject();
    when(userManager.getById(testUser.getId())).thenReturn(testUser);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/x-www-form-urlencoded").body("password=0xf").when().post(SECURE_PATH + "/user/password");
    assertEquals(response.getStatusCode(), 400);
    assertEquals(unwrapError(response), "Password should contain at least 8 characters");
}
Also used : Response(com.jayway.restassured.response.Response) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Aggregations

Response (com.jayway.restassured.response.Response)214 Test (org.testng.annotations.Test)129 Test (org.junit.Test)73 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)35 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)31 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)27 Matchers.anyString (org.mockito.Matchers.anyString)21 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)19 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)15 IOException (java.io.IOException)14 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)14 XPathExpressionException (javax.xml.xpath.XPathExpressionException)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 Map (java.util.Map)11 Factory (org.eclipse.che.api.core.model.factory.Factory)11 FactoryDto (org.eclipse.che.api.factory.shared.dto.FactoryDto)11 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)11 DtoFactory (org.eclipse.che.dto.server.DtoFactory)11 Matchers.containsString (org.hamcrest.Matchers.containsString)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)9