|
40 | 40 | import org.springframework.context.annotation.Bean;
|
41 | 41 | import org.springframework.context.annotation.Configuration;
|
42 | 42 | import org.springframework.context.annotation.Role;
|
43 |
| -import org.springframework.http.HttpStatusCode; |
44 |
| -import org.springframework.http.ResponseEntity; |
45 | 43 | import org.springframework.security.access.AccessDeniedException;
|
46 | 44 | import org.springframework.security.access.PermissionEvaluator;
|
47 | 45 | import org.springframework.security.access.annotation.Secured;
|
|
66 | 64 | import org.springframework.security.test.context.support.WithMockUser;
|
67 | 65 | import org.springframework.stereotype.Component;
|
68 | 66 | import org.springframework.test.context.junit.jupiter.SpringExtension;
|
69 |
| -import org.springframework.web.servlet.ModelAndView; |
70 | 67 |
|
71 | 68 | import static org.assertj.core.api.Assertions.assertThat;
|
72 | 69 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
@@ -363,48 +360,6 @@ public void findByIdWhenUnauthorizedResultThenDenies() {
|
363 | 360 | assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(() -> flight.getAltitude().block());
|
364 | 361 | }
|
365 | 362 |
|
366 |
| - @Test |
367 |
| - @WithMockUser(authorities = "airplane:read") |
368 |
| - public void findByIdWhenAuthorizedResponseEntityThenAuthorizes() { |
369 |
| - this.spring.register(AuthorizeResultConfig.class).autowire(); |
370 |
| - FlightRepository flights = this.spring.getContext().getBean(FlightRepository.class); |
371 |
| - Flight flight = flights.webFindById("1").block().getBody(); |
372 |
| - assertThatNoException().isThrownBy(() -> flight.getAltitude().block()); |
373 |
| - assertThatNoException().isThrownBy(() -> flight.getSeats().block()); |
374 |
| - } |
375 |
| - |
376 |
| - @Test |
377 |
| - @WithMockUser(authorities = "seating:read") |
378 |
| - public void findByIdWhenUnauthorizedResponseEntityThenDenies() { |
379 |
| - this.spring.register(AuthorizeResultConfig.class).autowire(); |
380 |
| - FlightRepository flights = this.spring.getContext().getBean(FlightRepository.class); |
381 |
| - Flight flight = flights.webFindById("1").block().getBody(); |
382 |
| - assertThatNoException().isThrownBy(() -> flight.getSeats().block()); |
383 |
| - assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(() -> flight.getAltitude().block()); |
384 |
| - } |
385 |
| - |
386 |
| - @Test |
387 |
| - @WithMockUser(authorities = "airplane:read") |
388 |
| - public void findByIdWhenAuthorizedModelAndViewThenAuthorizes() { |
389 |
| - this.spring.register(AuthorizeResultConfig.class).autowire(); |
390 |
| - FlightRepository flights = this.spring.getContext().getBean(FlightRepository.class); |
391 |
| - Flight flight = (Flight) flights.webViewFindById("1").block().getModel().get("flight"); |
392 |
| - assertThatNoException().isThrownBy(() -> flight.getAltitude().block()); |
393 |
| - assertThatNoException().isThrownBy(() -> flight.getSeats().block()); |
394 |
| - assertThat(flights.webViewFindById("5").block().getModel().get("flight")).isNull(); |
395 |
| - } |
396 |
| - |
397 |
| - @Test |
398 |
| - @WithMockUser(authorities = "seating:read") |
399 |
| - public void findByIdWhenUnauthorizedModelAndViewThenDenies() { |
400 |
| - this.spring.register(AuthorizeResultConfig.class).autowire(); |
401 |
| - FlightRepository flights = this.spring.getContext().getBean(FlightRepository.class); |
402 |
| - Flight flight = (Flight) flights.webViewFindById("1").block().getModel().get("flight"); |
403 |
| - assertThatNoException().isThrownBy(() -> flight.getSeats().block()); |
404 |
| - assertThatExceptionOfType(AccessDeniedException.class).isThrownBy(() -> flight.getAltitude().block()); |
405 |
| - assertThat(flights.webViewFindById("5").block().getModel().get("flight")).isNull(); |
406 |
| - } |
407 |
| - |
408 | 363 | @Test
|
409 | 364 | @WithMockUser(authorities = "seating:read")
|
410 | 365 | public void findAllWhenUnauthorizedResultThenDenies() {
|
@@ -752,22 +707,6 @@ Mono<Void> remove(String id) {
|
752 | 707 | return Mono.empty();
|
753 | 708 | }
|
754 | 709 |
|
755 |
| - Mono<ResponseEntity<Flight>> webFindById(String id) { |
756 |
| - Flight flight = this.flights.get(id); |
757 |
| - if (flight == null) { |
758 |
| - return Mono.just(ResponseEntity.notFound().build()); |
759 |
| - } |
760 |
| - return Mono.just(ResponseEntity.ok(flight)); |
761 |
| - } |
762 |
| - |
763 |
| - Mono<ModelAndView> webViewFindById(String id) { |
764 |
| - Flight flight = this.flights.get(id); |
765 |
| - if (flight == null) { |
766 |
| - return Mono.just(new ModelAndView("error", HttpStatusCode.valueOf(404))); |
767 |
| - } |
768 |
| - return Mono.just(new ModelAndView("flights", Map.of("flight", flight))); |
769 |
| - } |
770 |
| - |
771 | 710 | }
|
772 | 711 |
|
773 | 712 | @AuthorizeReturnObject
|
|
0 commit comments