Skip to content

Commit

Permalink
fix: SMS inbound and outbound lists stack overflow [DHIS2-18542]
Browse files Browse the repository at this point in the history
  • Loading branch information
jbee committed Dec 2, 2024
1 parent f016834 commit 2319cdb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
package org.hisp.dhis.webapi.controller;

import static org.hisp.dhis.test.webapi.Assertions.assertWebMessage;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.hisp.dhis.http.HttpStatus;
import org.hisp.dhis.jsontree.JsonObject;
import org.hisp.dhis.sms.incoming.IncomingSms;
import org.hisp.dhis.sms.incoming.IncomingSmsService;
import org.hisp.dhis.test.webapi.H2ControllerIntegrationTestBase;
Expand All @@ -51,6 +53,12 @@ class SmsInboundControllerTest extends H2ControllerIntegrationTestBase {

@Test
void testGetInboundSMSMessage() {
JsonObject list = GET("/sms/inbound").content();
assertEquals(0, list.getArray("inboundsmss").size());
}

@Test
void testGetInboundSMSMessage_Forbidden() {
User guestUser = createUserWithAuth("guestuser", "NONE");
injectSecurityContextUser(guestUser);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
package org.hisp.dhis.webapi.controller;

import static org.hisp.dhis.test.webapi.Assertions.assertWebMessage;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.hisp.dhis.http.HttpStatus;
import org.hisp.dhis.jsontree.JsonObject;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.sms.outbound.OutboundSmsService;
import org.hisp.dhis.test.webapi.H2ControllerIntegrationTestBase;
Expand All @@ -52,6 +54,12 @@ class SmsOutboundControllerTest extends H2ControllerIntegrationTestBase {

@Test
void testGetOutboundSMSMessage() {
JsonObject list = GET("/sms/outbound").content();
assertEquals(0, list.getArray("outboundsmss").size());
}

@Test
void testGetOutboundSMSMessage_Forbidden() {
User guestUser = createUserWithAuth("guestuser", "NONE");
injectSecurityContextUser(guestUser);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public class SmsInboundController extends AbstractCrudController<IncomingSms, Ge
GetObjectListParams params,
HttpServletResponse response,
@CurrentUser UserDetails currentUser)
throws ForbiddenException, BadRequestException {
return getObjectList(params, response, currentUser);
throws ForbiddenException, BadRequestException, ConflictException {
return super.getObjectList(params, response, currentUser);
}

@PostMapping(produces = APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.hisp.dhis.common.OpenApi;
import org.hisp.dhis.dxf2.webmessage.WebMessage;
import org.hisp.dhis.feedback.BadRequestException;
import org.hisp.dhis.feedback.ConflictException;
import org.hisp.dhis.feedback.ForbiddenException;
import org.hisp.dhis.message.MessageSender;
import org.hisp.dhis.outboundmessage.OutboundMessageResponse;
Expand Down Expand Up @@ -97,8 +98,8 @@ public SmsOutboundController(
GetObjectListParams params,
HttpServletResponse response,
@CurrentUser UserDetails currentUser)
throws ForbiddenException, BadRequestException {
return getObjectList(params, response, currentUser);
throws ForbiddenException, BadRequestException, ConflictException {
return super.getObjectList(params, response, currentUser);
}

// -------------------------------------------------------------------------
Expand Down

0 comments on commit 2319cdb

Please sign in to comment.