@@ -564,6 +564,94 @@ private static RuntimeConfig CreateRuntimeConfig(Dictionary<string, Entity> enti
564564 return runtimeConfig ;
565565 }
566566
567+ /// <summary>
568+ /// Verifies that stored procedures are excluded from health check results.
569+ /// Creates a config with both a table entity and a stored procedure entity,
570+ /// then validates that only the table entity appears in the health endpoint response.
571+ /// </summary>
572+ [ TestMethod ]
573+ [ TestCategory ( TestCategory . MSSQL ) ]
574+ public async Task HealthEndpoint_ExcludesStoredProcedures ( )
575+ {
576+ // Create a table entity
577+ Entity tableEntity = new (
578+ Health : new ( enabled : true ) ,
579+ Source : new ( "books" , EntitySourceType . Table , null , null ) ,
580+ Fields : null ,
581+ Rest : new ( Enabled : true ) ,
582+ GraphQL : new ( "book" , "bookLists" , true ) ,
583+ Permissions : new [ ] { ConfigurationTests . GetMinimalPermissionConfig ( AuthorizationResolver . ROLE_ANONYMOUS ) } ,
584+ Relationships : null ,
585+ Mappings : null ) ;
586+
587+ // Create a stored procedure entity
588+ Entity storedProcEntity = new (
589+ Health : new ( enabled : true ) ,
590+ Source : new ( "GetData" , EntitySourceType . StoredProcedure , null , null ) ,
591+ Fields : null ,
592+ Rest : new ( Enabled : true ) ,
593+ GraphQL : new ( "getData" , "getDataList" , true ) ,
594+ Permissions : new [ ] { ConfigurationTests . GetMinimalPermissionConfig ( AuthorizationResolver . ROLE_ANONYMOUS ) } ,
595+ Relationships : null ,
596+ Mappings : null ) ;
597+
598+ Dictionary < string , Entity > entityMap = new ( )
599+ {
600+ { "Book" , tableEntity } ,
601+ { "GetData" , storedProcEntity }
602+ } ;
603+
604+ RuntimeConfig runtimeConfig = CreateRuntimeConfig (
605+ entityMap ,
606+ enableGlobalRest : true ,
607+ enableGlobalGraphql : true ,
608+ enabledGlobalMcp : true ,
609+ enableGlobalHealth : true ,
610+ enableDatasourceHealth : true ,
611+ hostMode : HostMode . Development ) ;
612+
613+ WriteToCustomConfigFile ( runtimeConfig ) ;
614+
615+ string [ ] args = new [ ]
616+ {
617+ $ "--ConfigFileName={ CUSTOM_CONFIG_FILENAME } "
618+ } ;
619+
620+ using ( TestServer server = new ( Program . CreateWebHostBuilder ( args ) ) )
621+ using ( HttpClient client = server . CreateClient ( ) )
622+ {
623+ HttpRequestMessage healthRequest = new ( HttpMethod . Get , $ "{ BASE_DAB_URL } /health") ;
624+ HttpResponseMessage response = await client . SendAsync ( healthRequest ) ;
625+
626+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode , "Health endpoint should return OK" ) ;
627+
628+ string responseBody = await response . Content . ReadAsStringAsync ( ) ;
629+ Dictionary < string , JsonElement > responseProperties = JsonSerializer . Deserialize < Dictionary < string , JsonElement > > ( responseBody ) ;
630+
631+ // Get the checks array
632+ Assert . IsTrue ( responseProperties . TryGetValue ( "checks" , out JsonElement checksElement ) , "Response should contain 'checks' property" ) ;
633+ Assert . AreEqual ( JsonValueKind . Array , checksElement . ValueKind , "Checks should be an array" ) ;
634+
635+ // Get all entity names from the health check results
636+ List < string > entityNamesInHealthCheck = new ( ) ;
637+ foreach ( JsonElement check in checksElement . EnumerateArray ( ) )
638+ {
639+ if ( check . TryGetProperty ( "name" , out JsonElement nameElement ) )
640+ {
641+ entityNamesInHealthCheck . Add ( nameElement . GetString ( ) ) ;
642+ }
643+ }
644+
645+ // Verify that the table entity (Book) appears in health checks
646+ Assert . IsTrue ( entityNamesInHealthCheck . Contains ( "Book" ) ,
647+ "Table entity 'Book' should be included in health check results" ) ;
648+
649+ // Verify that the stored procedure entity (GetData) does NOT appear in health checks
650+ Assert . IsFalse ( entityNamesInHealthCheck . Contains ( "GetData" ) ,
651+ "Stored procedure entity 'GetData' should be excluded from health check results" ) ;
652+ }
653+ }
654+
567655 private static void WriteToCustomConfigFile ( RuntimeConfig runtimeConfig )
568656 {
569657 File . WriteAllText (
0 commit comments