File tree Expand file tree Collapse file tree
src/test/java/my/bookshop Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using {my .bookshop as my } from ' ../db/index' ;
22
33@ path : ' browse '
4- service CatalogService {
4+ service CatalogService @ ( requires : ' any ' ) {
55 @ readonly
66 entity Books as projection on my .Books excluding {
77 createdBy ,
Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ public class CatalogServiceITest {
3434
3535 private static final String USER_USER_STRING = "user" ;
3636 private static final String ADMIN_USER_STRING = "admin" ;
37- private static final String AUTHENTICATED_USER_STRING = "authenticated" ; // given by default
3837
3938 @ Autowired
4039 private MockMvc mockMvc ;
@@ -48,15 +47,13 @@ public void cleanup() {
4847 }
4948
5049 @ Test
51- @ WithMockUser (AUTHENTICATED_USER_STRING )
5250 public void testDiscountApplied () throws Exception {
5351 mockMvc .perform (get (booksURI + "?$filter=stock gt 200&top=1" ))
5452 .andExpect (status ().isOk ())
5553 .andExpect (jsonPath ("$.value[0].title" ).value (containsString ("11% discount" )));
5654 }
5755
5856 @ Test
59- @ WithMockUser (AUTHENTICATED_USER_STRING )
6057 public void testDiscountNotApplied () throws Exception {
6158 mockMvc .perform (get (booksURI + "?$filter=stock lt 100&top=1" ))
6259 .andExpect (status ().isOk ())
@@ -67,7 +64,7 @@ public void testDiscountNotApplied() throws Exception {
6764 public void testCreateReviewNotAuthenticated () throws Exception {
6865 String payload = createTestReview ().toJson ();
6966 mockMvc .perform (post (addReviewURI ).contentType (MediaType .APPLICATION_JSON ).content (payload ))
70- .andExpect (status ().isUnauthorized ());
67+ .andExpect (status ().isForbidden ());
7168 }
7269
7370 @ Test
You can’t perform that action at this time.
0 commit comments