Commit 4f5ab1c8 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

allow USER role to register callback

parent 95ce8537
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class HubApiController implements HubApi {
    }

    @Override
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')")
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN', 'ROLE_USER')")
    public ResponseEntity<EventSubscription> registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information", required = true) @Valid @RequestBody EventSubscriptionInput data) {
        try {
            EventSubscription eventSubscription = eventSubscriptionRepoService.addEventSubscription(data);
@@ -86,7 +86,7 @@ public class HubApiController implements HubApi {
    }

    @Override
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')")
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN', 'ROLE_USER')")
    public ResponseEntity<Void> unregisterListener(@Parameter(description = "The id of the registered listener", required = true) @PathVariable("id") String id) {
        try {
            EventSubscription existing = eventSubscriptionRepoService.findById(id);
+2 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ public class HubApiControllerTest {
                .andExpect(status().isBadRequest());
    }

    @WithMockUser(username = "user", roles = {"USER"})
    @WithMockUser(username = "user", roles = {"OTHER"})
    @Test
    public void testRegisterListenerUnauthorized() throws Exception {
        File resourceSpecFile = new File("src/test/resources/testPCM620EventSubscriptionInput.json");
@@ -196,7 +196,7 @@ public class HubApiControllerTest {
                .andExpect(status().isForbidden());
    }

    @WithMockUser(username = "user", roles = {"USER"})
    @WithMockUser(username = "user", roles = {"OTHER"})
    @Test
    public void testUnregisterListenerUnauthorized() throws Exception {
        // First create a subscription as admin
+4 −4
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class ProductOfferingCallbackIntegrationTest {
    }

    @Test
    @WithMockUser(username = "osadmin", roles = {"ADMIN"})
    @WithMockUser(username = "osadmin", roles = {"USER"})
    public void testCompleteCallbackFlow() throws Exception {
        // Step 1: Register a callback subscription via Hub API
        EventSubscriptionInput subscriptionInput = new EventSubscriptionInput();
@@ -139,7 +139,7 @@ public class ProductOfferingCallbackIntegrationTest {
    }

    @Test
    @WithMockUser(username = "osadmin", roles = {"ADMIN"})
    @WithMockUser(username = "osadmin", roles = {"USER"})
    public void testAttributeValueChangeAndStateChangeCallbacks() throws Exception {
        // Step 1: Register subscription for attribute and state change events
        EventSubscriptionInput subscriptionInput = new EventSubscriptionInput();
@@ -187,7 +187,7 @@ public class ProductOfferingCallbackIntegrationTest {
    }

    @Test
    @WithMockUser(username = "osadmin", roles = {"ADMIN"})
    @WithMockUser(username = "osadmin", roles = {"USER"})
    public void testCallbackFilteringByEventType() throws Exception {
        // Step 1: Register subscription only for create events
        EventSubscriptionInput subscriptionInput = new EventSubscriptionInput();
@@ -222,7 +222,7 @@ public class ProductOfferingCallbackIntegrationTest {
    }

    @Test
    @WithMockUser(username = "osadmin", roles = {"ADMIN"})
    @WithMockUser(username = "osadmin", roles = {"USER"})
    public void testProductOfferingCallbackWithAllEventsQuery() throws Exception {
        // Step 1: Register subscription for all events (empty query)
        EventSubscriptionInput subscriptionInput = new EventSubscriptionInput();