Skip to content

Commit 6511fb3

Browse files
committed
Fix tests
1 parent f9fd41b commit 6511fb3

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/inttest/java/com/faforever/api/data/MapPoolElideTest.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:sql/prepDefaultData.sql")
1717
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:sql/prepMapData.sql")
1818
public class MapPoolElideTest extends AbstractIntegrationTest {
19-
private static final String NEW_LADDER_MAP_BODY = "{\"data\":{\"type\":\"mapVersion\",\"id\":\"2\"}}}";
19+
private static final String NEW_LADDER_MAP_BODY = "{\"data\":[{\"type\":\"mapVersion\",\"id\":\"2\"}]}";
2020

2121
@Test
2222
public void cannotCreateMapPoolItemWithoutScope() throws Exception {
2323
mockMvc.perform(
24-
post("/data/mapPool/1/mapVersions")
24+
post("/data/mapPool/1/relationships/mapVersions")
2525
.with(getOAuthTokenWithTestUser(NO_SCOPE, GroupPermission.ROLE_WRITE_MATCHMAKER_MAP))
2626
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
2727
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
@@ -31,7 +31,7 @@ public void cannotCreateMapPoolItemWithoutScope() throws Exception {
3131
@Test
3232
public void cannotCreateMapPoolItemWithoutRole() throws Exception {
3333
mockMvc.perform(
34-
post("/data/mapPool/1/mapVersions")
34+
post("/data/mapPool/1/relationships/mapVersions")
3535
.with(getOAuthTokenWithTestUser(OAuthScope._ADMINISTRATIVE_ACTION, NO_AUTHORITIES))
3636
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
3737
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
@@ -41,34 +41,37 @@ public void cannotCreateMapPoolItemWithoutRole() throws Exception {
4141
@Test
4242
public void canCreateMapPoolItemWithScopeAndRole() throws Exception {
4343
mockMvc.perform(
44-
post("/data/mapPool/1/mapVersions")
44+
post("/data/mapPool/1/relationships/mapVersions")
4545
.with(getOAuthTokenWithTestUser(OAuthScope._ADMINISTRATIVE_ACTION, GroupPermission.ROLE_WRITE_MATCHMAKER_MAP))
4646
.header(HttpHeaders.CONTENT_TYPE, JsonApiMediaType.JSON_API_MEDIA_TYPE)
4747
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
48-
.andExpect(status().isCreated());
48+
.andExpect(status().isNoContent());
4949
}
5050

5151
@Test
5252
public void canDeleteMapPoolItemWithScopeAndRole() throws Exception {
5353
mockMvc.perform(
54-
delete("/data/mapPool/1/mapVersions/1")
55-
.with(getOAuthTokenWithTestUser(OAuthScope._ADMINISTRATIVE_ACTION, GroupPermission.ROLE_WRITE_MATCHMAKER_MAP))) // magic value from prepMapData.sql
54+
delete("/data/mapPool/1/relationships/mapVersions/1")
55+
.with(getOAuthTokenWithTestUser(OAuthScope._ADMINISTRATIVE_ACTION, GroupPermission.ROLE_WRITE_MATCHMAKER_MAP))
56+
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
5657
.andExpect(status().isNoContent());
5758
}
5859

5960
@Test
6061
public void cannotDeleteMapPoolItemWithoutScope() throws Exception {
6162
mockMvc.perform(
62-
delete("/data/mapPool/1/mapVersions/1")
63-
.with(getOAuthTokenWithTestUser(NO_SCOPE, GroupPermission.ROLE_WRITE_MATCHMAKER_MAP))) // magic value from prepMapData.sql
63+
delete("/data/mapPool/1/relationships/mapVersions/1")
64+
.with(getOAuthTokenWithTestUser(NO_SCOPE, GroupPermission.ROLE_WRITE_MATCHMAKER_MAP))
65+
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
6466
.andExpect(status().isForbidden());
6567
}
6668

6769
@Test
6870
public void cannotDeleteMapPoolItemWithoutRole() throws Exception {
6971
mockMvc.perform(
7072
delete("/data/mapPool/1")
71-
.with(getOAuthTokenWithTestUser(OAuthScope._ADMINISTRATIVE_ACTION, NO_AUTHORITIES))) // magic value from prepMapData.sql
73+
.with(getOAuthTokenWithTestUser(OAuthScope._ADMINISTRATIVE_ACTION, NO_AUTHORITIES))
74+
.content(NEW_LADDER_MAP_BODY)) // magic value from prepMapData.sql
7275
.andExpect(status().isForbidden());
7376
}
7477
}

src/main/java/com/faforever/api/data/DataController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.springframework.web.bind.annotation.PostMapping;
1616
import org.springframework.web.bind.annotation.RequestBody;
1717
import org.springframework.web.bind.annotation.RequestMapping;
18-
import org.springframework.web.bind.annotation.RequestMethod;
1918
import org.springframework.web.bind.annotation.RequestParam;
2019
import org.springframework.web.bind.annotation.RestController;
2120
import org.springframework.web.servlet.HandlerMapping;
@@ -117,11 +116,12 @@ public ResponseEntity<String> extensionPatch(@RequestParam final Map<String, Str
117116
@DeleteMapping(value = "/**", produces = JSON_API_MEDIA_TYPE)
118117
@PreAuthorize("isAuthenticated()")
119118
public ResponseEntity<String> delete(@RequestParam final Map<String, String> allRequestParams,
119+
@RequestBody(required = false) final String body,
120120
final HttpServletRequest request,
121121
final Authentication authentication) {
122122
ElideResponse response = elide.delete(
123123
getJsonApiPath(request),
124-
null,
124+
body,
125125
new MultivaluedHashMap<>(allRequestParams),
126126
getPrincipal(authentication)
127127
);

src/main/java/com/faforever/api/data/domain/MapPool.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
import com.yahoo.elide.annotation.CreatePermission;
55
import com.yahoo.elide.annotation.DeletePermission;
66
import com.yahoo.elide.annotation.Include;
7-
import com.yahoo.elide.annotation.SharePermission;
87
import com.yahoo.elide.annotation.UpdatePermission;
98
import lombok.Setter;
10-
import org.hibernate.annotations.Immutable;
119

1210
import javax.persistence.Entity;
1311
import javax.persistence.JoinColumn;
@@ -24,7 +22,6 @@
2422
@CreatePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)
2523
@UpdatePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)
2624
@DeletePermission(expression = WriteMatchmakerMapCheck.EXPRESSION)
27-
@SharePermission
2825
public class MapPool extends AbstractEntity {
2926
private String name;
3027
private Set<MapVersion> mapVersions;

0 commit comments

Comments
 (0)