(t *testing.T)
| 94 | } |
| 95 | |
| 96 | func TestInteropTLS(t *testing.T) { |
| 97 | a := assertions.New(t) |
| 98 | |
| 99 | config := &component.Config{ |
| 100 | ServiceBase: config.ServiceBase{ |
| 101 | TLS: tlsconfig.Config{ |
| 102 | ServerAuth: tlsconfig.ServerAuth{ |
| 103 | Certificate: "testdata/servercert.pem", |
| 104 | Key: "testdata/serverkey.pem", |
| 105 | }, |
| 106 | Client: tlsconfig.Client{ |
| 107 | RootCA: "testdata/serverca.pem", |
| 108 | }, |
| 109 | }, |
| 110 | Interop: config.InteropServer{ |
| 111 | ListenTLS: ":9188", |
| 112 | SenderClientCA: config.SenderClientCA{ |
| 113 | Source: "directory", |
| 114 | Directory: "testdata", |
| 115 | }, |
| 116 | }, |
| 117 | }, |
| 118 | } |
| 119 | |
| 120 | mockInterop := &mockInterop{} |
| 121 | c := component.MustNew(test.GetLogger(t), config) |
| 122 | c.RegisterInterop(mockInterop) |
| 123 | |
| 124 | test.Must[any](nil, c.Start()) |
| 125 | defer c.Close() |
| 126 | |
| 127 | certPool := x509.NewCertPool() |
| 128 | certContent, err := os.ReadFile("testdata/serverca.pem") |
| 129 | a.So(err, should.BeNil) |
| 130 | certPool.AppendCertsFromPEM(certContent) |
| 131 | client := http.Client{ |
| 132 | Transport: &http.Transport{ |
| 133 | TLSClientConfig: &tls.Config{ |
| 134 | RootCAs: certPool, |
| 135 | GetClientCertificate: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) { |
| 136 | cert, err := tls.LoadX509KeyPair("testdata/clientcert.pem", "testdata/clientkey.pem") |
| 137 | if err != nil { |
| 138 | return nil, err |
| 139 | } |
| 140 | return &cert, nil |
| 141 | }, |
| 142 | }, |
| 143 | }, |
| 144 | } |
| 145 | |
| 146 | // Correct SenderID. |
| 147 | { |
| 148 | req := &interop.JoinReq{ |
| 149 | NsJsMessageHeader: interop.NsJsMessageHeader{ |
| 150 | MessageHeader: interop.MessageHeader{ |
| 151 | MessageType: interop.MessageTypeJoinReq, |
| 152 | ProtocolVersion: "1.0", |
| 153 | }, |
nothing calls this directly
no test coverage detected