@@ -67,8 +67,11 @@ public class SqlInjectionReportingServiceIntegrationTest extends BaseLoanIntegra
6767 private RequestSpecification requestSpec ;
6868 private ResponseSpecification responseSpec ;
6969 private Long testReportId = null ;
70+ private Long booleanReportId = null ;
7071 private static final String TEST_REPORT_NAME = "SQL_Injection_Test_Report" ;
7172 private static final String TEST_REPORT_SQL = "SELECT 1 as test_column, 'Test Data' as test_name" ;
73+ private static final String BOOLEAN_REPORT_SQL = "SELECT id, active FROM m_client" ;
74+ private String booleanReportName ;
7275
7376 @ BeforeEach
7477 public void setup () {
@@ -92,6 +95,13 @@ public void cleanup() {
9295 log .warn ("Failed to clean up test report: " + e .getMessage ());
9396 }
9497 }
98+ if (booleanReportId != null ) {
99+ try {
100+ deleteBooleanReport ();
101+ } catch (Exception e ) {
102+ log .warn ("Failed to clean up boolean test report: " + e .getMessage ());
103+ }
104+ }
95105 }
96106
97107 private void createTestReportIfNotExists () {
@@ -161,6 +171,31 @@ private void createTestReportIfNotExists() {
161171 }
162172 }
163173
174+ private void createBooleanReport () {
175+ booleanReportName = "BOOLEAN_Runreports_Test_Report_" + System .currentTimeMillis ();
176+
177+ String reportJson = "{" + "\" reportName\" : \" " + booleanReportName + "\" ," + "\" reportType\" : \" Table\" ,"
178+ + "\" reportCategory\" : \" Client\" ," + "\" reportSql\" : \" " + BOOLEAN_REPORT_SQL + "\" ,"
179+ + "\" description\" : \" Test report for BOOLEAN runreports support\" ," + "\" useReport\" : true" + "}" ;
180+
181+ Response postResponse = given ().spec (requestSpec ).contentType (ContentType .JSON ).body (reportJson ).when ()
182+ .post ("/fineract-provider/api/v1/reports" );
183+
184+ if (postResponse .getStatusCode () == 200 || postResponse .getStatusCode () == 201 ) {
185+ String response = postResponse .asString ();
186+ if (response .contains ("resourceId" )) {
187+ String idStr = response .replaceAll (".*\" resourceId\" :(\\ d+).*" , "$1" );
188+ booleanReportId = Long .parseLong (idStr );
189+ log .info ("Created BOOLEAN test report with ID: {}" , booleanReportId );
190+ } else {
191+ throw new RuntimeException ("BOOLEAN test report creation failed - no resourceId in response: " + response );
192+ }
193+ } else {
194+ throw new RuntimeException (
195+ "BOOLEAN test report creation failed with status " + postResponse .getStatusCode () + ": " + postResponse .asString ());
196+ }
197+ }
198+
164199 private void deleteTestReport () {
165200 if (testReportId != null ) {
166201 try {
@@ -172,6 +207,17 @@ private void deleteTestReport() {
172207 }
173208 }
174209
210+ private void deleteBooleanReport () {
211+ if (booleanReportId != null ) {
212+ try {
213+ Utils .performServerDelete (requestSpec , responseSpec , "/fineract-provider/api/v1/reports/" + booleanReportId , "" );
214+ log .info ("Deleted BOOLEAN test report with ID: {}" , booleanReportId );
215+ } catch (Exception e ) {
216+ log .warn ("Failed to delete BOOLEAN test report: " + e .getMessage ());
217+ }
218+ }
219+ }
220+
175221 /**
176222 * UC1: Test legitimate report execution works correctly Validates that the SQL injection prevention doesn't break
177223 * normal functionality
@@ -496,6 +542,19 @@ void uc10_testCrossDatabaseCompatibility() {
496542 }
497543 }
498544
545+ @ Test
546+ void shouldExecuteReportSuccessfullyWhenReportContainsBooleanColumn () {
547+ createBooleanReport ();
548+
549+ String response = Utils .performServerGet (requestSpec , responseSpec ,
550+ "/fineract-provider/api/v1/runreports/" + booleanReportName + "?genericResultSet=false" , null );
551+
552+ assertNotNull (response );
553+ assertFalse (response .isBlank ());
554+ assertFalse (response .contains ("Data type 'BOOLEAN' is not supported" ));
555+ assertTrue (response .contains ("columnHeaders" ) || response .contains ("data" ));
556+ }
557+
499558 /**
500559 * Helper method to convert parameters map to query string
501560 */
@@ -513,3 +572,4 @@ private String toQueryString(Map<String, String> params) {
513572 return sb .toString ();
514573 }
515574}
575+
0 commit comments