3
This commit is contained in:
@@ -565,6 +565,43 @@ func TestQUICFabricServerHandlesWebIngressForwardFrames(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendFabricControlForwardUsesQUICStream(t *testing.T) {
|
||||
tlsConfig := testQUICTLSConfig(t)
|
||||
server, err := StartQUICFabricServer(context.Background(), QUICFabricServerConfig{
|
||||
ListenAddr: "127.0.0.1:0",
|
||||
TLSConfig: tlsConfig,
|
||||
FabricControlHandler: func(_ context.Context, payload []byte) ([]byte, error) {
|
||||
if string(payload) != `{"method":"GET","path":"/auth/login"}` {
|
||||
return nil, ErrForwardRuntimeUnavailable
|
||||
}
|
||||
return []byte(`{"status_code":200,"body":{"ok":true}}`), nil
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("start quic fabric server: %v", err)
|
||||
}
|
||||
defer server.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
result, err := SendFabricControlForward(ctx, NewQUICFabricTransport(nil), FabricRegistryEndpoint{
|
||||
EndpointID: "control-a",
|
||||
Address: "quic://" + server.Addr().String(),
|
||||
Transport: "direct_quic",
|
||||
PeerCertSHA256: testQUICCertSHA256(t, tlsConfig),
|
||||
}, []byte(`{"method":"GET","path":"/auth/login"}`), time.Second)
|
||||
if err != nil {
|
||||
t.Fatalf("send fabric control forward: %v", err)
|
||||
}
|
||||
var response quicFabricControlForwardResponse
|
||||
if err := json.Unmarshal(result.Payload, &response); err != nil {
|
||||
t.Fatalf("decode response: %v", err)
|
||||
}
|
||||
if response.Error != "" || string(response.Payload) != `{"status_code":200,"body":{"ok":true}}` {
|
||||
t.Fatalf("response = %+v", response)
|
||||
}
|
||||
}
|
||||
|
||||
func startQUICFabricEchoServer(t *testing.T) *quic.Listener {
|
||||
t.Helper()
|
||||
return startQUICFabricEchoServerWithTLS(t, testQUICTLSConfig(t))
|
||||
|
||||
Reference in New Issue
Block a user