Skip to content

Commit

Permalink
[Test] compatibility fix for fingerprint test on OSX using go>1.18 (#478
Browse files Browse the repository at this point in the history
) (#479)

Co-authored-by: Laurent Saint-Félix <[email protected]>
  • Loading branch information
github-actions[bot] and Anaethelion authored Apr 14, 2022
1 parent a53f695 commit 4f482c7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions elasticsearch_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,23 +850,26 @@ tuSVaQmm5eqgaAxMamBXSyw1lir07byemyuEDg0mJ1rNUGsAY8P+LWr579gvKMme

// Without certificate and authority, client should fail on TLS
client, _ := NewClient(config)
res, err := client.Info()
if _, ok := err.(x509.UnknownAuthorityError); !ok {
t.Fatalf("Uknown error, expected UnknownAuthorityError, got: %s", err)
_, err = client.Info()

if err.Error() != `x509: “instance” certificate is not standards compliant` {
if _, ok := err.(x509.UnknownAuthorityError); !ok {
t.Fatalf("Uknown error, expected UnknownAuthorityError, got: %s", err)
}
}

// We add the fingerprint corresponding ton testcert.LocalhostCert
// We add the fingerprint corresponding to testcert.LocalhostCert
//
config.CertificateFingerprint = "7A3A6031CD097DA0EE84D65137912A84576B50194045B41F4F4B8AC1A98116BE"
client, _ = NewClient(config)
res, err = client.Info()
res, err := client.Info()
if err != nil {
t.Fatal(err)
}
defer res.Body.Close()

data, _ := ioutil.ReadAll(res.Body)
if bytes.Compare(data, body) != 0 {
if !bytes.Equal(data, body) {
t.Fatalf("unexpected payload returned: expected: %s, got: %s", body, data)
}
}

0 comments on commit 4f482c7

Please sign in to comment.