Skip to content

Commit

Permalink
js/grpc: Test for report an error in case of tls fail
Browse files Browse the repository at this point in the history
  • Loading branch information
codebien committed Feb 3, 2022
1 parent d57b01c commit 344e68f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion js/modules/k6/grpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package grpc
import (
"bytes"
"context"
"crypto/tls"
"errors"
"fmt"
"net/url"
Expand Down Expand Up @@ -161,6 +162,24 @@ func TestClient(t *testing.T) {
}

tests := []testcase{
{
name: "BadTLS",
setup: func(tb *httpmultibin.HTTPMultiBin) {
// changing the pointer's value
// for affecting the lib.State
// that uses the same pointer
*tb.TLSClientConfig = tls.Config{
MinVersion: tls.VersionTLS13,
}
},
initString: codeBlock{
code: `var client = new grpc.Client();`,
},
vuString: codeBlock{
code: `client.connect("GRPCBIN_ADDR", {timeout: '1s'})`,
err: "certificate signed by unknown authority",
},
},
{
name: "New",
initString: codeBlock{
Expand Down Expand Up @@ -670,7 +689,8 @@ func TestClient(t *testing.T) {

ts := setup(t)

ctx := common.WithRuntime(context.Background(), ts.rt)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mvu := &modulestest.VU{
RuntimeField: ts.rt,
InitEnvField: ts.env,
Expand Down

0 comments on commit 344e68f

Please sign in to comment.