TSK-1029: Add test to trigger permission bug

This commit is contained in:
Benjamin Eckstein 2020-01-20 11:52:44 +01:00 committed by Holger Hagen
parent 6801edc72d
commit 5a08fd4b03
2 changed files with 29 additions and 0 deletions

View File

@ -48,6 +48,14 @@ public class RestHelper {
return headers;
}
public HttpHeaders getHeadersBusinessAdmin() {
HttpHeaders headers = new HttpHeaders();
// businessadmin:businessadmin
headers.add("Authorization", "Basic YnVzaW5lc3NhZG1pbjpidXNpbmVzc2FkbWlu");
headers.add("Content-Type", "application/hal+json");
return headers;
}
/**
* Return a REST template which is capable of dealing with responses in HAL format.
*

View File

@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.Link;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -107,6 +108,26 @@ class WorkbasketControllerIntTest {
assertNotNull(response.getBody().getLink(Link.REL_PREVIOUS));
}
/**
* Bug Ticket TSK-1029
*
* <p>Businessadmin is allowed to delete any workbasket ticket without user related access
* restrictions
*/
@Test
void testWorkbasketDeletePermission() {
String workbasketID = "WBI:100000000000000000000000000000000005";
ResponseEntity<?> response =
template.exchange(
restHelper.toUrl(Mapping.URL_WORKBASKET_ID, workbasketID),
HttpMethod.DELETE,
new HttpEntity<>(restHelper.getHeadersBusinessAdmin()),
Void.class);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
}
@Test
void testRemoveWorkbasketAsDistributionTarget() {
ResponseEntity<?> response =