@@ -46,22 +46,47 @@ func TestHealthEndpoint_RoutedMode(t *testing.T) {
4646 t .Errorf ("Expected Content-Type 'application/json', got '%s'" , contentType )
4747 }
4848
49- // Check response body
50- var response map [string ]string
49+ // Check response body - use map[string]interface{} to handle mixed types
50+ var response map [string ]interface {}
5151 if err := json .NewDecoder (w .Body ).Decode (& response ); err != nil {
5252 t .Fatalf ("Failed to decode JSON response: %v" , err )
5353 }
5454
55- if response ["status" ] != "ok" {
56- t .Errorf ("Expected status 'ok', got '%s'" , response ["status" ])
55+ // Check status field - should be "healthy" or "unhealthy"
56+ status , ok := response ["status" ].(string )
57+ if ! ok {
58+ t .Error ("Expected 'status' field to be a string" )
59+ }
60+ if status != "healthy" && status != "unhealthy" {
61+ t .Errorf ("Expected status 'healthy' or 'unhealthy', got '%s'" , status )
62+ }
63+
64+ // Check specVersion field (required by spec 8.1.1)
65+ specVersion , ok := response ["specVersion" ].(string )
66+ if ! ok {
67+ t .Error ("Expected 'specVersion' field to be a string" )
68+ }
69+ if specVersion != MCPGatewaySpecVersion {
70+ t .Errorf ("Expected specVersion '%s', got '%s'" , MCPGatewaySpecVersion , specVersion )
5771 }
5872
59- if response ["protocolVersion" ] != MCPProtocolVersion {
60- t .Errorf ("Expected protocolVersion '%s', got '%s'" , MCPProtocolVersion , response ["protocolVersion" ])
73+ // Check gatewayVersion field (required by spec 8.1.1)
74+ gatewayVersion , ok := response ["gatewayVersion" ].(string )
75+ if ! ok {
76+ t .Error ("Expected 'gatewayVersion' field to be a string" )
77+ }
78+ if gatewayVersion == "" {
79+ t .Error ("Expected gatewayVersion to be non-empty" )
6180 }
6281
63- if response ["version" ] == "" {
64- t .Error ("Expected version to be non-empty" )
82+ // Check servers field (required by spec 8.1.1)
83+ servers , ok := response ["servers" ].(map [string ]interface {})
84+ if ! ok {
85+ t .Error ("Expected 'servers' field to be an object" )
86+ }
87+ // With empty config, servers map should be empty
88+ if len (servers ) != 0 {
89+ t .Errorf ("Expected empty servers map with no configured servers, got %d servers" , len (servers ))
6590 }
6691}
6792
@@ -101,22 +126,47 @@ func TestHealthEndpoint_UnifiedMode(t *testing.T) {
101126 t .Errorf ("Expected Content-Type 'application/json', got '%s'" , contentType )
102127 }
103128
104- // Check response body
105- var response map [string ]string
129+ // Check response body - use map[string]interface{} to handle mixed types
130+ var response map [string ]interface {}
106131 if err := json .NewDecoder (w .Body ).Decode (& response ); err != nil {
107132 t .Fatalf ("Failed to decode JSON response: %v" , err )
108133 }
109134
110- if response ["status" ] != "ok" {
111- t .Errorf ("Expected status 'ok', got '%s'" , response ["status" ])
135+ // Check status field - should be "healthy" or "unhealthy"
136+ status , ok := response ["status" ].(string )
137+ if ! ok {
138+ t .Error ("Expected 'status' field to be a string" )
139+ }
140+ if status != "healthy" && status != "unhealthy" {
141+ t .Errorf ("Expected status 'healthy' or 'unhealthy', got '%s'" , status )
112142 }
113143
114- if response ["protocolVersion" ] != MCPProtocolVersion {
115- t .Errorf ("Expected protocolVersion '%s', got '%s'" , MCPProtocolVersion , response ["protocolVersion" ])
144+ // Check specVersion field (required by spec 8.1.1)
145+ specVersion , ok := response ["specVersion" ].(string )
146+ if ! ok {
147+ t .Error ("Expected 'specVersion' field to be a string" )
148+ }
149+ if specVersion != MCPGatewaySpecVersion {
150+ t .Errorf ("Expected specVersion '%s', got '%s'" , MCPGatewaySpecVersion , specVersion )
116151 }
117152
118- if response ["version" ] == "" {
119- t .Error ("Expected version to be non-empty" )
153+ // Check gatewayVersion field (required by spec 8.1.1)
154+ gatewayVersion , ok := response ["gatewayVersion" ].(string )
155+ if ! ok {
156+ t .Error ("Expected 'gatewayVersion' field to be a string" )
157+ }
158+ if gatewayVersion == "" {
159+ t .Error ("Expected gatewayVersion to be non-empty" )
160+ }
161+
162+ // Check servers field (required by spec 8.1.1)
163+ servers , ok := response ["servers" ].(map [string ]interface {})
164+ if ! ok {
165+ t .Error ("Expected 'servers' field to be an object" )
166+ }
167+ // With empty config, servers map should be empty
168+ if len (servers ) != 0 {
169+ t .Errorf ("Expected empty servers map with no configured servers, got %d servers" , len (servers ))
120170 }
121171}
122172
@@ -151,20 +201,35 @@ func TestHealthEndpoint_NoAuth(t *testing.T) {
151201 }
152202
153203 // Verify JSON response
154- var response map [string ]string
204+ var response map [string ]interface {}
155205 if err := json .NewDecoder (w .Body ).Decode (& response ); err != nil {
156206 t .Fatalf ("Failed to decode JSON response: %v" , err )
157207 }
158208
159- if response ["status" ] != "ok" {
160- t .Errorf ("Expected status 'ok', got '%s'" , response ["status" ])
209+ // Check status field - should be "healthy" or "unhealthy"
210+ status , ok := response ["status" ].(string )
211+ if ! ok {
212+ t .Error ("Expected 'status' field to be a string" )
213+ }
214+ if status != "healthy" && status != "unhealthy" {
215+ t .Errorf ("Expected status 'healthy' or 'unhealthy', got '%s'" , status )
161216 }
162217
163- if response ["protocolVersion" ] != MCPProtocolVersion {
164- t .Errorf ("Expected protocolVersion '%s', got '%s'" , MCPProtocolVersion , response ["protocolVersion" ])
218+ // Check specVersion field (required by spec 8.1.1)
219+ specVersion , ok := response ["specVersion" ].(string )
220+ if ! ok {
221+ t .Error ("Expected 'specVersion' field to be a string" )
222+ }
223+ if specVersion != MCPGatewaySpecVersion {
224+ t .Errorf ("Expected specVersion '%s', got '%s'" , MCPGatewaySpecVersion , specVersion )
165225 }
166226
167- if response ["version" ] == "" {
168- t .Error ("Expected version to be non-empty" )
227+ // Check gatewayVersion field (required by spec 8.1.1)
228+ gatewayVersion , ok := response ["gatewayVersion" ].(string )
229+ if ! ok {
230+ t .Error ("Expected 'gatewayVersion' field to be a string" )
231+ }
232+ if gatewayVersion == "" {
233+ t .Error ("Expected gatewayVersion to be non-empty" )
169234 }
170235}
0 commit comments