This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 80492c85 authored by Eduard Frankford's avatar Eduard Frankford
Browse files

added test for user without authorities liking and unliking stuff

parent 196e2d22
2 merge requests!55June Release,!54thumbs_up button implementation
......@@ -242,7 +242,7 @@ public class LikesResourceIT {
@Test
@Transactional
public void testLikeWorkflow() throws Exception {
public void testLikeWorkflowWithAuthorities() throws Exception {
// Initialize the database
likesRepository.saveAndFlush(likes);
......@@ -265,7 +265,7 @@ public class LikesResourceIT {
assertEquals(1, likesRepository.findNumberOfLikesByProjectID(1000));
//unlike project
restLikesMockMvc.perform(delete("/api/unlikeProject/{projectID}", 1000).with(csrf().asHeader()).accept(MediaType.APPLICATION_JSON))
.andExpect(status().isNoContent());
......@@ -273,6 +273,33 @@ public class LikesResourceIT {
}
@Test
@Transactional
public void testLikeWorkflowWithOutAuthorities() throws Exception {
// Initialize the database
likesRepository.saveAndFlush(likes);
// generate new like
Likes newLike = new Likes();
newLike.setProjectID(1000);
//user likes a project and nothing should happen
restLikesMockMvc.perform(put("/api/likeProject").contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(newLike))).andExpect(status().isForbidden());
assertEquals(0, likesRepository.findNumberOfLikesByProjectID(1000));
//unlike project
restLikesMockMvc.perform(delete("/api/unlikeProject/{projectID}", 1000).accept(MediaType.APPLICATION_JSON))
.andExpect(status().isForbidden());
assertEquals(0, likesRepository.findNumberOfLikesByProjectID(1000));
}
@Test
@Transactional
public void getLikesByIdFiltering() throws Exception {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment