Skip to content

Commit

Permalink
Merge branch 'master' into add-trimaferopathseparator-testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
apatruni authored Jan 21, 2025
2 parents f6d645a + 6b4be5f commit d2a2c53
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/grafana/xk6-dashboard v0.7.5
github.com/grafana/xk6-output-opentelemetry v0.3.0
github.com/grafana/xk6-output-prometheus-remote v0.5.1
github.com/grafana/xk6-redis v0.3.2
github.com/grafana/xk6-redis v0.3.3
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/influxdata/influxdb1-client v0.0.0-20190402204710-8ff2fc3824fc
github.com/jhump/protoreflect v1.17.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ github.com/grafana/xk6-output-opentelemetry v0.3.0 h1:dmclGBFtFVRJijqLncpu2dKVII
github.com/grafana/xk6-output-opentelemetry v0.3.0/go.mod h1:5uUg0J2dxrw+DkC9fCsfiKv2jTpccn7nz6vGmRUr4f8=
github.com/grafana/xk6-output-prometheus-remote v0.5.1 h1:zsB0x/1kuArqnDNh419UWdMUYZwrzqtfjTUswWPIHhI=
github.com/grafana/xk6-output-prometheus-remote v0.5.1/go.mod h1:esXXthLoVp9JUdGkECRthESVYu0TQTR24wrx2nRM9ak=
github.com/grafana/xk6-redis v0.3.2 h1:ZHKdyajrvdj39IqZtx/XfDpVnPzCzCCbDfWrxyKLFHg=
github.com/grafana/xk6-redis v0.3.2/go.mod h1:3e/U9i1Nm3WEaMy4nZSGMjVf8ZsFau+aXurYJhJ7MfQ=
github.com/grafana/xk6-redis v0.3.3 h1:9QiS4OUjYMzvriGzbqrhCn9i/kENmCkibZE+xCJSdPk=
github.com/grafana/xk6-redis v0.3.3/go.mod h1:YL1qfBZXW4o2aAF6/gRa/N9oGoumUg7cJzzCHLxoCOw=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
Expand Down
32 changes: 14 additions & 18 deletions js/modules/k6/grpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"fmt"
"strings"
"testing"
Expand Down Expand Up @@ -1151,20 +1152,25 @@ func TestClient(t *testing.T) {
func TestClient_TlsParameters(t *testing.T) {
t.Parallel()

testingKey := func(s string) string {
t.Helper()
return strings.ReplaceAll(s, "TESTING KEY", "PRIVATE KEY")
}

clientAuthCA := []byte("-----BEGIN CERTIFICATE-----\nMIIBWzCCAQGgAwIBAgIJAIQMBgLi+DV6MAoGCCqGSM49BAMCMBAxDjAMBgNVBAMM\nBU15IENBMCAXDTIyMDEyMTEyMjkzNloYDzMwMjEwNTI0MTIyOTM2WjAQMQ4wDAYD\nVQQDDAVNeSBDQTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABHnrghULHa2hSa/C\nWimwCn42KWdlPqd6/zs3JgLIxTvBHJJlfbhWbBqtybqyovWd3QykHMIpx0NZmpYn\nG8FoWpmjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud\nDgQWBBSkukBA8lgFvvBJAYKsoSUR+PX71jAKBggqhkjOPQQDAgNIADBFAiEAiFF7\nY54CMNRSBSVMgd4mQgrzJInRH88KpLsQ7VeOAaQCIEa0vaLln9zxIDZQKocml4Db\nAEJr8tDzMKIds6sRTBT4\n-----END CERTIFICATE-----")
localHostCert := "-----B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GptxT36Cr7Zk2Bsg0XqwbOvK\\n5d+NTDREkSnUbie4GeutujmX3Dsx88UiV6UY/4lHJa6I5leHUNOHahRbpbWeOfs/\\nWkBKOclmOV2xlTVuPw==\\n-----END CERTIFICATE-----"
clientAuth := "-----BEGIN CERTIFICATE-----\\nMIIBVzCB/6ADAgECAgkAg/SeNG3XqB0wCgYIKoZIzj0EAwIwEDEOMAwGA1UEAwwF\\nTXkgQ0EwIBcNMjIwMTIxMTUxMjM0WhgPMzAyMTA1MjQxNTEyMzRaMBExDzANBgNV\\nBAMMBmNsaWVudDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABKM7OJQMYG4KLtDA\\ngZ8zOg2PimHMmQnjD2HtI4cSwIUJJnvHWLowbFe9fk6XeP9b3dK1ImUI++/EZdVr\\nABAcngejPzA9MA4GA1UdDwEB/wQEAwIBBjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQW\\nBBSttJe1mcPEnBOZ6wvKPG4zL0m1CzAKBggqhkjOPQQDAgNHADBEAiBPSLgKA/r9\\nu/FW6W+oy6Odm1kdNMGCI472iTn545GwJgIgb3UQPOUTOj0IN4JLJYfmYyXviqsy\\nzk9eWNHFXDA9U6U=\\n-----END CERTIFICATE-----"
clientAuthKey := testingKey("-----BEGIN EC TESTING KEY-----\\nMHcCAQEEINDaMGkOT3thu1A0LfLJr3Jd011/aEG6OArmEQaujwgpoAoGCCqGSM49\\nAwEHoUQDQgAEozs4lAxgbgou0MCBnzM6DY+KYcyZCeMPYe0jhxLAhQkme8dYujBs\\nV71+Tpd4/1vd0rUiZQj778Rl1WsAEByeBw==\\n-----END EC TESTING KEY-----")
clientAuthKeyEncrypted := testingKey("-----BEGIN EC TESTING KEY-----\\nProc-Type: 4,ENCRYPTED\\nDEK-Info: AES-256-CBC,3E311E9B602231BFB5C752071EE7D652\\n\\nsAKeqbacug0v4ruE1A0CACwGVEGBQVOl1CiGVp5RsxgNZKXzMS6EsTTNLw378coF\\nKXbF+he05HIuzToOz2ANLXov1iCrVpotKVB4l2obTQvg+5VET902ky99Mc9Us7jd\\nUwW8LpXlSlhcNWuUfK6wyosL42TbcIxjqZWaESW+6ww=\\n-----END EC TESTING KEY-----")
clientAuthKey := ("-----BEGIN EC PRIVATE KEY-----\\nMHcCAQEEINDaMGkOT3thu1A0LfLJr3Jd011/aEG6OArmEQaujwgpoAoGCCqGSM49\\nAwEHoUQDQgAEozs4lAxgbgou0MCBnzM6DY+KYcyZCeMPYe0jhxLAhQkme8dYujBs\\nV71+Tpd4/1vd0rUiZQj778Rl1WsAEByeBw==\\n-----END EC PRIVATE KEY-----")
clientAuthKeyEncrypted := ("-----BEGIN EC PRIVATE KEY-----\\nProc-Type: 4,ENCRYPTED\\nDEK-Info: AES-256-CBC,3E311E9B602231BFB5C752071EE7D652\\n\\nsAKeqbacug0v4ruE1A0CACwGVEGBQVOl1CiGVp5RsxgNZKXzMS6EsTTNLw378coF\\nKXbF+he05HIuzToOz2ANLXov1iCrVpotKVB4l2obTQvg+5VET902ky99Mc9Us7jd\\nUwW8LpXlSlhcNWuUfK6wyosL42TbcIxjqZWaESW+6ww=\\n-----END EC PRIVATE KEY-----")

trivialKeyPassword := "abc123"
trivialWrongKeyPassword := "abc321"

// We need the certificate actually used by the httpmultibin in this test
// as it is the same one for all tests we can get it once here
// This also prevents changes to this to break this test
// as it happened after https://github.com/golang/go/commit/6783377295e0878aa3ad821eefe3d7879064df6d
p := httpmultibin.NewHTTPMultiBin(t)
localHostCert := strings.ReplaceAll(string(pem.EncodeToMemory(
&pem.Block{
Type: "CERTIFICATE",
Bytes: p.ServerHTTP2.TLS.Certificates[0].Certificate[0],
})), "\n", `\n`)

tests := []testcase{
{
name: "ConnectTlsEmptyTlsSuccess",
Expand Down Expand Up @@ -1206,11 +1212,6 @@ func TestClient_TlsParameters(t *testing.T) {
},
},
{
// After https://github.com/golang/go/commit/6783377295e0878aa3ad821eefe3d7879064df6d
// and more accurately the test certificate upgrade, this test do not match any certificate
// apparently because the signature doesn't match
// https://github.com/grafana/k6/issues/3549 likely needs to be implemented to fix them
skip: true,
name: "ConnectTls",
setup: func(tb *httpmultibin.HTTPMultiBin) {
clientCAPool := x509.NewCertPool()
Expand All @@ -1222,7 +1223,6 @@ func TestClient_TlsParameters(t *testing.T) {
vuString: codeBlock{code: fmt.Sprintf(`client.connect("GRPCBIN_ADDR", { tls: { cacerts: ["%s"], cert: "%s", key: "%s" }});`, localHostCert, clientAuth, clientAuthKey)},
},
{
skip: true, // see comment on ConnectTls
name: "ConnectTlsEncryptedKey",
setup: func(tb *httpmultibin.HTTPMultiBin) {
clientCAPool := x509.NewCertPool()
Expand All @@ -1246,7 +1246,6 @@ func TestClient_TlsParameters(t *testing.T) {
},
},
{
skip: true, // see comment on ConnectTls
name: "ConnectTlsInvokeSuccess",
setup: func(tb *httpmultibin.HTTPMultiBin) {
clientCAPool := x509.NewCertPool()
Expand Down Expand Up @@ -1278,9 +1277,6 @@ func TestClient_TlsParameters(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if tt.skip {
t.Skip()
}

ts := newTestState(t)

Expand Down
1 change: 0 additions & 1 deletion js/modules/k6/grpc/teststate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type testcase struct {
setup func(*httpmultibin.HTTPMultiBin)
initString codeBlock // runs in the init context
vuString codeBlock // runs in the vu context
skip bool
}

// callRecorder a helper type that records all calls
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ github.com/grafana/xk6-output-prometheus-remote/pkg/remote
github.com/grafana/xk6-output-prometheus-remote/pkg/remotewrite
github.com/grafana/xk6-output-prometheus-remote/pkg/sigv4
github.com/grafana/xk6-output-prometheus-remote/pkg/stale
# github.com/grafana/xk6-redis v0.3.2
# github.com/grafana/xk6-redis v0.3.3
## explicit; go 1.20
github.com/grafana/xk6-redis/redis
# github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
Expand Down

0 comments on commit d2a2c53

Please sign in to comment.