TestHeadersHTTPStatusGRPCStatus tests requests with certain headers get a certain HTTP and gRPC status back.
(t *testing.T)
| 2212 | // TestHeadersHTTPStatusGRPCStatus tests requests with certain headers get a |
| 2213 | // certain HTTP and gRPC status back. |
| 2214 | func (s) TestHeadersHTTPStatusGRPCStatus(t *testing.T) { |
| 2215 | tests := []struct { |
| 2216 | name string |
| 2217 | headers []struct { |
| 2218 | name string |
| 2219 | values []string |
| 2220 | } |
| 2221 | httpStatusWant string |
| 2222 | grpcStatusWant string |
| 2223 | grpcMessageWant string |
| 2224 | }{ |
| 2225 | // Note: multiple authority headers are handled by the framer itself, |
| 2226 | // which will cause a stream error. Thus, it will never get to |
| 2227 | // operateHeaders with the check in operateHeaders for possible |
| 2228 | // grpc-status sent back. |
| 2229 | |
| 2230 | // multiple :authority or multiple Host headers would make the eventual |
| 2231 | // :authority ambiguous as per A41. This takes precedence even over the |
| 2232 | // fact a request is non grpc. All of these requests should be rejected |
| 2233 | // with grpc-status Internal. Thus, requests with multiple hosts should |
| 2234 | // get rejected with HTTP Status 400 and gRPC status Internal, |
| 2235 | // regardless of whether the client is speaking gRPC or not. |
| 2236 | { |
| 2237 | name: "Multiple host headers non grpc", |
| 2238 | headers: []struct { |
| 2239 | name string |
| 2240 | values []string |
| 2241 | }{ |
| 2242 | {name: ":method", values: []string{"POST"}}, |
| 2243 | {name: ":path", values: []string{"foo"}}, |
| 2244 | {name: ":authority", values: []string{"localhost"}}, |
| 2245 | {name: "host", values: []string{"localhost", "localhost2"}}, |
| 2246 | }, |
| 2247 | httpStatusWant: "400", |
| 2248 | grpcStatusWant: "13", |
| 2249 | grpcMessageWant: "both must only have 1 value as per HTTP/2 spec", |
| 2250 | }, |
| 2251 | { |
| 2252 | name: "Multiple host headers grpc", |
| 2253 | headers: []struct { |
| 2254 | name string |
| 2255 | values []string |
| 2256 | }{ |
| 2257 | {name: ":method", values: []string{"POST"}}, |
| 2258 | {name: ":path", values: []string{"foo"}}, |
| 2259 | {name: ":authority", values: []string{"localhost"}}, |
| 2260 | {name: "content-type", values: []string{"application/grpc"}}, |
| 2261 | {name: "host", values: []string{"localhost", "localhost2"}}, |
| 2262 | }, |
| 2263 | httpStatusWant: "400", |
| 2264 | grpcStatusWant: "13", |
| 2265 | grpcMessageWant: "both must only have 1 value as per HTTP/2 spec", |
| 2266 | }, |
| 2267 | // If the client sends an HTTP/2 request with a :method header with a |
| 2268 | // value other than POST, as specified in the gRPC over HTTP/2 |
| 2269 | // specification, the server should fail the RPC. |
| 2270 | { |
| 2271 | name: "Client Sending Wrong Method", |
nothing calls this directly
no test coverage detected