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());
}
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");
}
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");
}
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");
}
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");
}
Aggregations