Skip to content

Commit

Permalink
util: fix unstable test TestCheckCN (#37016)
Browse files Browse the repository at this point in the history
ref #36866
  • Loading branch information
hawkingrei authored Aug 10, 2022
1 parent 0ddf413 commit c3d14dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions util/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ go_test(
data = glob(["tls_test/**"]),
embed = [":util"],
flaky = True,
shard_count = 2,
deps = [
"//config",
"//kv",
Expand Down
7 changes: 3 additions & 4 deletions util/security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,16 @@ func TestCheckCN(t *testing.T) {

resp, err := util.ClientWithTLS(clientTLS1).Get(url)
require.NoError(t, err)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "This an example server", string(body))
require.NoError(t, resp.Body.Close())

// client2 can't visit server
resp, err = util.ClientWithTLS(clientTLS2).Get(url)
require.Regexp(t, ".*tls: bad certificate", err.Error())
if resp != nil {
err = resp.Body.Close()
require.NoError(t, err)
require.NoError(t, resp.Body.Close())
}
}

Expand Down

0 comments on commit c3d14dc

Please sign in to comment.