Skip to content

Commit

Permalink
Merge 439e00c into 6445fdd
Browse files Browse the repository at this point in the history
  • Loading branch information
1-alex98 committed May 1, 2019
2 parents 6445fdd + 439e00c commit 5b138c1
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 83 deletions.
12 changes: 6 additions & 6 deletions src/inttest/java/com/faforever/api/data/AvatarElideTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void moderatorCanAssignAvatar() throws Exception {
.setSelected(false);
mockMvc.perform(
post("/data/player/{playerId}/avatarAssignments", player.getId())
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(avatarAssignment)))
.andExpect(status().isCreated())
.andExpect(jsonPath("$.data.relationships.player.data.id", is(player.getId())))
Expand Down Expand Up @@ -87,7 +87,7 @@ public void userCannotAssignAvatar() throws Exception {
.setSelected(false);
mockMvc.perform(
post("/data/player/{playerId}/avatarAssignments", player.getId())
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(avatarAssignment))
).andExpect(status().isForbidden());
}
Expand All @@ -112,7 +112,7 @@ public void moderatorCanUpdateAvatarAssignmentExpiration() throws Exception {
.setId("1");
mockMvc.perform(
patch("/data/avatarAssignment/{assignmentId}", 1)
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(avatarAssignment)))
.andExpect(status().isNoContent());
mockMvc.perform(
Expand All @@ -130,7 +130,7 @@ public void userCannotUpdateAvatarAssignmentExpiration() throws Exception {
.setId("1");
mockMvc.perform(
patch("/data/avatarAssignment/{assignmentId}", 1)
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(avatarAssignment)))
.andExpect(status().isForbidden());
}
Expand All @@ -143,7 +143,7 @@ public void ownerCanUpdateAvatarAssignmentSelection() throws Exception {
.setId("1");
mockMvc.perform(
patch("/data/avatarAssignment/{assignmentId}", 1)
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(avatarAssignment)))
.andExpect(status().isNoContent());
mockMvc.perform(
Expand All @@ -160,7 +160,7 @@ public void nonOwnerCannotUpdateAvatarAssignmentSelection() throws Exception {
.setId("1");
mockMvc.perform(
patch("/data/avatarAssignment/{assignmentId}", 1)
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(avatarAssignment)))
.andExpect(status().isForbidden());
}
Expand Down
10 changes: 5 additions & 5 deletions src/inttest/java/com/faforever/api/data/BanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void cannotReadSpecificBanInfoAsUser() throws Exception {
@WithUserDetails(AUTH_USER)
public void cannotCreateBanInfoAsUser() throws Exception {
mockMvc.perform(post("/data/banInfo")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(testPost))
.andExpect(status().isForbidden());
}
Expand All @@ -110,7 +110,7 @@ public void canCreateBanInfoAsModerator() throws Exception {
assertThat(playerRepository.getOne(3).getBans().size(), is(0));

mockMvc.perform(post("/data/banInfo")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(testPost))
.andExpect(status().isCreated());

Expand All @@ -126,7 +126,7 @@ public void canCreateBanInfoBasedOnModerationReportAsModerator() throws Exceptio
.setPlayer((Player) new Player().setId("3"))
.setModerationReport((ModerationReport) new ModerationReport().setId("1"));
mockMvc.perform(post("/data/banInfo")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(banInfo)))
.andExpect(status().isCreated())
.andExpect(jsonPath("$.data.relationships.moderationReport.data.id", is("1")));
Expand All @@ -141,7 +141,7 @@ public void moderatorCanRevokeBan() throws Exception {
banInfo.setRevokeReason("revoke reason");

mockMvc.perform(patch("/data/banInfo/3")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(banInfo)))
.andExpect(status().isNoContent());

Expand All @@ -157,7 +157,7 @@ public void userCanNotRevokeBan() throws Exception {
banInfo.setRevokeReason("new revoke reason");

mockMvc.perform(patch("/data/banInfo/3")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(banInfo)))
.andExpect(status().isForbidden());
}
Expand Down
6 changes: 3 additions & 3 deletions src/inttest/java/com/faforever/api/data/ClanElideTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void canTransferLeadershipAsLeader() throws Exception {

mockMvc.perform(
patch("/data/clan/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(generateTransferLeadershipContent(1, 12))) // magic value from prepClanData.sql
.andExpect(status().isNoContent());

Expand All @@ -124,7 +124,7 @@ public void cannotTransferLeadershipAsMember() throws Exception {

mockMvc.perform(
patch("/data/clan/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(generateTransferLeadershipContent(1, 12))) // magic value from prepClanData.sql
.andExpect(status().isForbidden())
.andExpect(jsonPath("$.errors[0]", is("ForbiddenAccessException")));
Expand All @@ -137,7 +137,7 @@ public void cannotTransferLeadershipAsMember() throws Exception {
public void cannotTransferLeadershipToNonClanMember() throws Exception {
mockMvc.perform(
patch("/data/clan/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(generateTransferLeadershipContent(1, 1))) // magic value from prepClanData.sql
.andExpect(status().is4xxClientError()); // TODO: Catch javax.validation.ConstraintViolationException and wrap it into a regular ApiException
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void canReadSpecificDomainBlacklistAsModerator() throws Exception {
public void cannotCreateDomainBlacklistAsUser() throws Exception {
mockMvc.perform(
post("/data/domainBlacklist")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(NEW_DOMAIN))
.andExpect(status().isForbidden());
}
Expand All @@ -67,7 +67,7 @@ public void cannotCreateDomainBlacklistAsUser() throws Exception {
public void canCreateDomainBlacklistAsModerator() throws Exception {
mockMvc.perform(
post("/data/domainBlacklist")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(NEW_DOMAIN))
.andExpect(status().isCreated());
}
Expand Down
4 changes: 2 additions & 2 deletions src/inttest/java/com/faforever/api/data/Ladder1v1MapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Ladder1v1MapTest extends AbstractIntegrationTest {
public void cannotCreateLadderMapAsUser() throws Exception {
mockMvc.perform(
post("/data/ladder1v1Map")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
.andExpect(status().isForbidden());
}
Expand All @@ -32,7 +32,7 @@ public void cannotCreateLadderMapAsUser() throws Exception {
public void canCreateLadderMapAsModerator() throws Exception {
mockMvc.perform(
post("/data/ladder1v1Map")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
.andExpect(status().isCreated());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class MapVersionElideTest extends AbstractIntegrationTest {
public void testUpdateHideToTrueDoesWork() throws Exception {
mockMvc.perform(
patch("/data/mapVersion/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(MAP_VERSION_HIDE_TRUE_ID_1))
.andExpect(status().isNoContent());
}
Expand All @@ -68,7 +68,7 @@ public void testUpdateHideToTrueDoesWork() throws Exception {
public void testUpdateHideToFalseDoesNotWork() throws Exception {
mockMvc.perform(
patch("/data/mapVersion/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(MAP_VERSION_HIDE_FALSE_ID_1))
.andExpect(status().isForbidden());
}
Expand All @@ -79,7 +79,7 @@ public void testUpdateHideToFalseDoesNotWork() throws Exception {
public void testUpdateRankedToFalseDoesWork() throws Exception {
mockMvc.perform(
patch("/data/mapVersion/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(MAP_VERSION_RANKED_FALSE_ID_1))
.andExpect(status().isNoContent());
}
Expand All @@ -89,7 +89,7 @@ public void testUpdateRankedToFalseDoesWork() throws Exception {
public void testUpdateRankedToTrueDoesNotWork() throws Exception {
mockMvc.perform(
patch("/data/mapVersion/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(MAP_VERSION_RANKED_TRUE_ID_1))
.andExpect(status().isForbidden());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void canReadSpecificTutorialAsModerator() throws Exception {
@WithUserDetails(AUTH_USER)
public void cannotPostTutorialAsUser() throws Exception {
mockMvc.perform(post("/data/tutorial")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(tutorial())))
.andExpect(status().isForbidden());
}
Expand All @@ -89,7 +89,7 @@ public void cannotDeleteTutorialAsUser() throws Exception {
public void moderatorCanPostTutorial() throws Exception {
MvcResult mvcResult = mockMvc.perform(
post("/data/tutorial")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(createJsonApiContent(tutorial())))
.andExpect(status().isCreated())
.andReturn();
Expand Down
4 changes: 2 additions & 2 deletions src/inttest/java/com/faforever/api/data/UserNoteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void cannotReadSpecificUserNoteAsUser() throws Exception {
@WithUserDetails(AUTH_USER)
public void cannotCreateUserNoteAsUser() throws Exception {
mockMvc.perform(post("/data/userNote")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(testPost))
.andExpect(status().isForbidden());
}
Expand All @@ -96,7 +96,7 @@ public void canCreateUserNoteAsModerator() throws Exception {
assertThat(playerRepository.getOne(3).getUserNotes().size(), is(0));

mockMvc.perform(post("/data/userNote")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(testPost))
.andExpect(status().isCreated());

Expand Down
4 changes: 2 additions & 2 deletions src/inttest/java/com/faforever/api/data/VotingElideTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public void everyBodySeesVotingChoices() throws Exception {
public void testRevealWinnerOnEndedSubjectWorks() throws Exception {
mockMvc.perform(
patch("/data/votingSubject/2")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(PATCH_VOTING_SUBJECT_REVEAL_ID_2))
.andExpect(status().isNoContent());
VotingQuestion question = votingQuestionRepository.getOne(2);
Expand All @@ -284,7 +284,7 @@ public void testRevealWinnerOnEndedSubjectWorks() throws Exception {
public void testRevealWinnerOnNoneEndedSubjectFails() throws Exception {
mockMvc.perform(
patch("/data/votingSubject/1")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(PATCH_VOTING_SUBJECT_REVEAL_ID_1))
.andExpect(status().is4xxClientError());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faforever.api.event;

import com.faforever.api.AbstractIntegrationTest;
import com.faforever.api.data.DataController;
import com.faforever.api.data.JsonApiMediaType;
import com.faforever.api.security.OAuthScope;
import com.google.common.collect.Lists;
import org.hamcrest.Matchers;
Expand All @@ -27,7 +27,7 @@ public void singleExistingPlayerEventCanBeUpdated() throws Exception {
List<EventUpdateRequest> updatedEvents = Lists.newArrayList(new EventUpdateRequest(1, "15b6c19a-6084-4e82-ada9-6c30e282191f", 10));
mockMvc.perform(
patch("/events/update")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(objectMapper.writeValueAsString(updatedEvents))
.with(getOAuthToken(OAuthScope._WRITE_EVENTS)))
.andExpect(status().isOk())
Expand All @@ -41,7 +41,7 @@ public void singleNonExistingPlayerEventCanBeCreated() throws Exception {
List<EventUpdateRequest> updatedEvents = Lists.newArrayList(new EventUpdateRequest(1, "cc791f00-343c-48d4-b5b3-8900b83209c0", 10));
mockMvc.perform(
patch("/events/update")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(objectMapper.writeValueAsString(updatedEvents))
.with(getOAuthToken(OAuthScope._WRITE_EVENTS)))
.andExpect(status().isOk())
Expand All @@ -58,7 +58,7 @@ public void multipleExistingPlayerEventsCanBeUpdated() throws Exception {
);
mockMvc.perform(
patch("/events/update")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(objectMapper.writeValueAsString(updatedEvents))
.with(getOAuthToken(OAuthScope._WRITE_EVENTS)))
.andExpect(status().isOk())
Expand All @@ -72,7 +72,7 @@ public void authWithoutCorrectScopeShouldFail() throws Exception {
List<EventUpdateRequest> updatedEvents = Lists.newArrayList(new EventUpdateRequest(1, "15b6c19a-6084-4e82-ada9-6c30e282191f", 10));
mockMvc.perform(
patch("/events/update")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(objectMapper.writeValueAsString(updatedEvents)))
.andExpect(status().isForbidden());
}
Expand All @@ -82,7 +82,7 @@ public void nonExistingEventShouldFail() throws Exception {
List<EventUpdateRequest> updatedEvents = Lists.newArrayList(new EventUpdateRequest(1, "non-existing-event-id", 10));
mockMvc.perform(
patch("/events/update")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(objectMapper.writeValueAsString(updatedEvents))
.with(getOAuthToken(OAuthScope._WRITE_EVENTS)))
.andExpect(status().isUnprocessableEntity());
Expand All @@ -93,7 +93,7 @@ public void nonExistingPlayerShouldFail() throws Exception {
List<EventUpdateRequest> updatedEvents = Lists.newArrayList(new EventUpdateRequest(-1, "15b6c19a-6084-4e82-ada9-6c30e282191f", 10));
mockMvc.perform(
patch("/events/update")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(objectMapper.writeValueAsString(updatedEvents))
.with(getOAuthToken(OAuthScope._WRITE_EVENTS)))
.andExpect(status().isUnprocessableEntity());
Expand All @@ -104,7 +104,7 @@ public void negativeCountShouldFail() throws Exception {
List<EventUpdateRequest> updatedEvents = Lists.newArrayList(new EventUpdateRequest(1, "15b6c19a-6084-4e82-ada9-6c30e282191f", -10));
mockMvc.perform(
patch("/events/update")
.header(HttpHeaders.CONTENT_TYPE, DataController.JSON_API_MEDIA_TYPE)
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
.content(objectMapper.writeValueAsString(updatedEvents))
.with(getOAuthToken(OAuthScope._WRITE_EVENTS)))
.andExpect(status().isUnprocessableEntity());
Expand Down
Loading

0 comments on commit 5b138c1

Please sign in to comment.