MCPcopy
hub / github.com/segmentio/kafka-go / TestReadResponseUnexpectedTLSDetection

Function TestReadResponseUnexpectedTLSDetection

protocol/response_test.go:11–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestReadResponseUnexpectedTLSDetection(t *testing.T) {
12 var buf bytes.Buffer
13
14 buf.Write([]byte{tlsAlertByte, 0x03, 0x03, 10, 0, 0, 0})
15
16 correlationID, _, err := ReadResponse(&buf, ApiVersions, 0)
17 if !errors.Is(err, io.ErrUnexpectedEOF) {
18 t.Fatalf("expected an io.ErrUnexpectedEOF from ReadResponse got %v", err)
19 }
20
21 if !strings.Contains(err.Error(), "broker appears to be expecting TLS") {
22 t.Fatalf("expected error messae to contain %s got %s", "broker appears to be expecting TLS", err.Error())
23 }
24
25 if correlationID != 0 {
26 t.Fatalf("expected correlationID of 0 got %d", correlationID)
27 }
28}

Callers

nothing calls this directly

Calls 3

ReadResponseFunction · 0.85
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected