Skip to content

Commit d7b35a5

Browse files
authored
Make CatalogService public again (#174)
Partially reverts #156, now that we can reasonably opt-out of secure-by-default.
1 parent b85b42a commit d7b35a5

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

srv/cat-service.cds

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using {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,

srv/src/test/java/my/bookshop/CatalogServiceITest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)