@@ -49,22 +49,42 @@ public override IReadOnlyList<ApiHealthSeedRequirement> GetSeedRequirements() =>
4949 public override async Task < IReadOnlyList < ApiTestRunResult > > ExecuteAsync ( CancellationToken ct = default )
5050 {
5151 var results = new List < ApiTestRunResult > ( ) ;
52- var baseUrl = _serviceRegistry . Value . AdminBffServiceApiUrl ? . TrimEnd ( '/' ) ;
52+ var baseUrl = _serviceRegistry . Value . AdminBffServiceUrl ? . TrimEnd ( '/' ) ;
5353
5454 if ( string . IsNullOrWhiteSpace ( baseUrl ) )
5555 {
56- results . Add ( new ApiTestRunResult
56+ const string error = "ServiceRegistry:AdminBffServiceUrl is not configured." ;
57+
58+ foreach ( var endpointName in new [ ]
59+ {
60+ StepNames . InfoGet200 ,
61+ StepNames . HealthGet200
62+ } )
5763 {
58- EndpointKey = $ "{ ServiceName } ::{ StepNames . HealthGet200 } ",
59- ServiceName = ServiceName ,
60- Passed = false ,
61- ErrorMessage = "ServiceRegistry:AdminBffServiceUrl is not configured." ,
62- RequestBody = "Request was not sent because ServiceRegistry:AdminBffServiceUrl is missing." ,
63- ResponseBody = "Response was not received because ServiceRegistry:AdminBffServiceUrl is missing."
64- } ) ;
64+ results . Add ( new ApiTestRunResult
65+ {
66+ EndpointKey = $ "{ ServiceName } ::{ endpointName } ",
67+ ServiceName = ServiceName ,
68+ EndpointName = endpointName ,
69+ Passed = false ,
70+ ExpectedStatusCode = 200 ,
71+ ErrorMessage = error ,
72+ RequestBody = "Request was not sent because the Admin BFF service URL is missing." ,
73+ ResponseBody = "Response was not received because the Admin BFF service URL is missing." ,
74+ ExecutedAt = DateTimeOffset . UtcNow
75+ } ) ;
76+ }
77+
6578 return results ;
6679 }
6780
81+ // --- /api/AdminBff/info ---
82+ results . Add ( await CallRawGetAsync (
83+ StepNames . InfoGet200 ,
84+ baseUrl ,
85+ "/api/info" ,
86+ ct ) ) ;
87+
6888 var adminBffClient = _serviceProvider . GetRequiredService < IAdminBffIntegrationClient > ( ) ;
6989
7090 // --- /api/monitor/health ---
@@ -338,4 +358,83 @@ private static string BuildStatusMismatchMessage(int expectedStatus, int actualS
338358 }
339359 }
340360
361+ private async Task < ApiTestRunResult > CallRawGetAsync (
362+ string endpointName ,
363+ string baseUrl ,
364+ string relativePath ,
365+ CancellationToken ct )
366+ {
367+ var result = new ApiTestRunResult
368+ {
369+ EndpointKey = $ "{ ServiceName } ::{ endpointName } ",
370+ ServiceName = ServiceName ,
371+ EndpointName = endpointName ,
372+ ExpectedStatusCode = 200 ,
373+ ExecutedAt = DateTimeOffset . UtcNow ,
374+ RequestMethod = "GET" ,
375+ RequestUrl = $ "{ baseUrl } { relativePath } ",
376+ RequestBody = "No request body was sent (GET)."
377+ } ;
378+
379+ var sw = Stopwatch . StartNew ( ) ;
380+
381+ try
382+ {
383+ ct . ThrowIfCancellationRequested ( ) ;
384+
385+ var httpClientFactory = _serviceProvider . GetRequiredService < IHttpClientFactory > ( ) ;
386+ var httpClient = httpClientFactory . CreateClient ( "ApiHealthTest" ) ;
387+ using var response = await httpClient . GetAsync (
388+ $ "{ baseUrl } { relativePath } ",
389+ ct ) ;
390+
391+ var responseBody = await response . Content . ReadAsStringAsync ( ct ) ;
392+
393+ sw . Stop ( ) ;
394+
395+ result . ActualStatusCode = ( int ) response . StatusCode ;
396+ result . DurationMs = sw . ElapsedMilliseconds ;
397+ result . Passed = result . ActualStatusCode == 200 ;
398+
399+ result . ResponseBody = string . IsNullOrWhiteSpace ( responseBody )
400+ ? $ "No response body was returned (HTTP { result . ActualStatusCode } )."
401+ : responseBody . Length > 500
402+ ? responseBody [ ..500 ]
403+ : responseBody ;
404+
405+ if ( ! result . Passed )
406+ {
407+ result . ErrorMessage = BuildStatusMismatchMessage (
408+ 200 ,
409+ result . ActualStatusCode ?? 0 ,
410+ result . ResponseBody ,
411+ null ) ;
412+ }
413+ }
414+ catch ( OperationCanceledException ) when ( ct . IsCancellationRequested )
415+ {
416+ throw ;
417+ }
418+ catch ( TaskCanceledException )
419+ {
420+ sw . Stop ( ) ;
421+ result . DurationMs = sw . ElapsedMilliseconds ;
422+ result . Passed = false ;
423+ result . ErrorMessage = "Request timed out." ;
424+ result . ResponseBody =
425+ "No response body was received because the request timed out." ;
426+ }
427+ catch ( HttpRequestException ex )
428+ {
429+ sw . Stop ( ) ;
430+ result . DurationMs = sw . ElapsedMilliseconds ;
431+ result . Passed = false ;
432+ result . ErrorMessage = $ "HTTP error: { ex . Message } ";
433+ result . ResponseBody =
434+ "No response body was received because the HTTP request failed." ;
435+ }
436+
437+ return result ;
438+ }
439+
341440}
0 commit comments