From 8c135838d4eb0a8a0dca770e3d8d8ea4c9249be3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 07:07:47 +0000 Subject: [PATCH 1/2] build(deps): bump github.com/mitchellh/go-testing-interface Bumps [github.com/mitchellh/go-testing-interface](https://github.com/mitchellh/go-testing-interface) from 1.14.0 to 1.14.1. - [Commits](https://github.com/mitchellh/go-testing-interface/compare/v1.14.0...v1.14.1) --- updated-dependencies: - dependency-name: github.com/mitchellh/go-testing-interface dependency-version: 1.14.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6ba90e08da3..04aaf0a55b5 100644 --- a/go.mod +++ b/go.mod @@ -87,7 +87,7 @@ require ( github.com/miekg/dns v1.1.50 github.com/mitchellh/cli v1.1.4 github.com/mitchellh/copystructure v1.2.0 - github.com/mitchellh/go-testing-interface v1.14.0 + github.com/mitchellh/go-testing-interface v1.14.1 github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 github.com/mitchellh/hashstructure/v2 v2.0.2 github.com/mitchellh/mapstructure v1.5.0 diff --git a/go.sum b/go.sum index 1d0a418928a..38e1bcedce2 100644 --- a/go.sum +++ b/go.sum @@ -692,8 +692,8 @@ github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.14.0 h1:/x0XQ6h+3U3nAyk1yx+bHPURrKa9sVVvYbuqZ7pIAtI= -github.com/mitchellh/go-testing-interface v1.14.0/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= +github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= From 6d72a357d136bd41b0e80cc207e405c5d971260f Mon Sep 17 00:00:00 2001 From: Vikramarjuna Date: Thu, 26 Jun 2025 17:42:35 +0530 Subject: [PATCH 2/2] fix: updated the UT to fix issues related to updating go-testing-interface package to 1.14.1 --- agent/connect/testing_ca.go | 11 +++++++++-- agent/proxycfg/state_test.go | 24 ++++++++++++------------ agent/proxycfg/testing.go | 26 +++++++++++++------------- agent/proxycfg/testing_mesh_gateway.go | 4 ++-- agent/structs/testing_catalog.go | 5 +++-- 5 files changed, 39 insertions(+), 31 deletions(-) diff --git a/agent/connect/testing_ca.go b/agent/connect/testing_ca.go index a852d9130c8..2dae37e3edf 100644 --- a/agent/connect/testing_ca.go +++ b/agent/connect/testing_ca.go @@ -334,7 +334,7 @@ func TestServerLeaf(t testing.T, dc string, root *structs.CARoot) (string, strin // TestCSR returns a CSR to sign the given service along with the PEM-encoded // private key for this certificate. -func TestCSR(t testing.T, uri CertURI) (string, string) { +func TestCSR(t Fatalfer, uri CertURI) (string, string) { template := &x509.CertificateRequest{ URIs: []*url.URL{uri.URI()}, SignatureAlgorithm: x509.ECDSAWithSHA256, @@ -387,7 +387,7 @@ func testKeyID(t testing.T, raw interface{}) []byte { // which will be the same for multiple CAs/Leafs. Also note that our UUID // generator also reads from crypto rand and is called far more often during // tests than this will be. -func testPrivateKey(t testing.T, keyType string, keyBits int) (crypto.Signer, string) { +func testPrivateKey(t Fatalfer, keyType string, keyBits int) (crypto.Signer, string) { pk, pkPEM, err := GeneratePrivateKeyWithConfig(keyType, keyBits) if err != nil { t.Fatalf("error generating private key: %s", err) @@ -396,6 +396,13 @@ func testPrivateKey(t testing.T, keyType string, keyBits int) (crypto.Signer, st return pk, pkPEM } +// Fatalfer is a subset of testing.T that only has the Fatalf method. This is +// used to avoid import cycles in the connect package, since we use this in +// places that need to call Fatalf but don't need the full testing.T interface. +type Fatalfer interface { + Fatalf(format string, args ...any) +} + // testSerialNumber generates a serial number suitable for a certificate. For // testing, this just sets it to a random number, but one that can fit in a // uint64 since we use that in our datastructures and assume cert serials will diff --git a/agent/proxycfg/state_test.go b/agent/proxycfg/state_test.go index 43743eb40a0..307b81c65c2 100644 --- a/agent/proxycfg/state_test.go +++ b/agent/proxycfg/state_test.go @@ -1365,7 +1365,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { Address: "10.30.1.1", Datacenter: "dc4", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.1", 8443, structs.ServiceAddress{Address: "10.0.1.1", Port: 8443}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), @@ -1377,7 +1377,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { Address: "10.30.1.2", Datacenter: "dc4", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.2", 8443, structs.ServiceAddress{Address: "10.30.1.2", Port: 8443}, structs.ServiceAddress{Address: "456.us-west-2.elb.notaws.com", Port: 443}), @@ -1411,7 +1411,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { Address: "10.30.1.1", Datacenter: "dc5", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.1", 8443, structs.ServiceAddress{Address: "10.0.1.1", Port: 8443}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), @@ -1423,7 +1423,7 @@ func TestState_WatchesAndUpdates(t *testing.T) { Address: "10.30.1.2", Datacenter: "dc5", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.2", 8443, structs.ServiceAddress{Address: "10.30.1.2", Port: 8443}, structs.ServiceAddress{Address: "456.us-west-2.elb.notaws.com", Port: 443}), @@ -4163,7 +4163,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.1.1", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "123.us-west-1.elb.notaws.com", Port: 443}), @@ -4173,7 +4173,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.2.2", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), @@ -4190,7 +4190,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "gateway.mydomain", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "123.us-west-1.elb.notaws.com", Port: 443}), @@ -4200,7 +4200,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.2.2", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), @@ -4212,7 +4212,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "gateway.mydomain", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "123.us-west-1.elb.notaws.com", Port: 443}), @@ -4228,7 +4228,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "gateway.mydomain", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "8.8.8.8", Port: 443}), @@ -4238,7 +4238,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.2.2", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), @@ -4250,7 +4250,7 @@ func Test_hostnameEndpoints(t *testing.T) { Node: "mesh-gateway", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.2.2", 8443, structs.ServiceAddress{}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), diff --git a/agent/proxycfg/testing.go b/agent/proxycfg/testing.go index bdd565ec045..f029fd24677 100644 --- a/agent/proxycfg/testing.go +++ b/agent/proxycfg/testing.go @@ -395,7 +395,7 @@ func TestGatewayNodesDC1(t testing.T) structs.CheckServiceNodes { Address: "10.10.1.1", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.10.1.1", 8443, structs.ServiceAddress{Address: "10.10.1.1", Port: 8443}, structs.ServiceAddress{Address: "198.118.1.1", Port: 443}), @@ -407,7 +407,7 @@ func TestGatewayNodesDC1(t testing.T) structs.CheckServiceNodes { Address: "10.10.1.2", Datacenter: "dc1", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.10.1.2", 8443, structs.ServiceAddress{Address: "10.0.1.2", Port: 8443}, structs.ServiceAddress{Address: "198.118.1.2", Port: 443}), @@ -424,7 +424,7 @@ func TestGatewayNodesDC2(t testing.T) structs.CheckServiceNodes { Address: "10.0.1.1", Datacenter: "dc2", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.1.1", 8443, structs.ServiceAddress{Address: "10.0.1.1", Port: 8443}, structs.ServiceAddress{Address: "198.18.1.1", Port: 443}), @@ -436,7 +436,7 @@ func TestGatewayNodesDC2(t testing.T) structs.CheckServiceNodes { Address: "10.0.1.2", Datacenter: "dc2", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.1.2", 8443, structs.ServiceAddress{Address: "10.0.1.2", Port: 8443}, structs.ServiceAddress{Address: "198.18.1.2", Port: 443}), @@ -453,7 +453,7 @@ func TestGatewayNodesDC3(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.1", Datacenter: "dc3", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.1", 8443, structs.ServiceAddress{Address: "10.0.1.1", Port: 8443}, structs.ServiceAddress{Address: "198.38.1.1", Port: 443}), @@ -465,7 +465,7 @@ func TestGatewayNodesDC3(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.2", Datacenter: "dc3", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.2", 8443, structs.ServiceAddress{Address: "10.30.1.2", Port: 8443}, structs.ServiceAddress{Address: "198.38.1.2", Port: 443}), @@ -482,7 +482,7 @@ func TestGatewayNodesDC4Hostname(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.1", Datacenter: "dc4", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.1", 8443, structs.ServiceAddress{Address: "10.0.1.1", Port: 8443}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), @@ -494,7 +494,7 @@ func TestGatewayNodesDC4Hostname(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.2", Datacenter: "dc4", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.2", 8443, structs.ServiceAddress{Address: "10.30.1.2", Port: 8443}, structs.ServiceAddress{Address: "456.us-west-2.elb.notaws.com", Port: 443}), @@ -506,7 +506,7 @@ func TestGatewayNodesDC4Hostname(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.3", Datacenter: "dc4", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.3", 8443, structs.ServiceAddress{Address: "10.30.1.3", Port: 8443}, structs.ServiceAddress{Address: "198.38.1.1", Port: 443}), @@ -523,7 +523,7 @@ func TestGatewayNodesDC5Hostname(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.1", Datacenter: "dc5", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.1", 8443, structs.ServiceAddress{Address: "10.0.1.1", Port: 8443}, structs.ServiceAddress{Address: "123.us-west-2.elb.notaws.com", Port: 443}), @@ -535,7 +535,7 @@ func TestGatewayNodesDC5Hostname(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.2", Datacenter: "dc5", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.2", 8443, structs.ServiceAddress{Address: "10.30.1.2", Port: 8443}, structs.ServiceAddress{Address: "456.us-west-2.elb.notaws.com", Port: 443}), @@ -547,7 +547,7 @@ func TestGatewayNodesDC5Hostname(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.3", Datacenter: "dc5", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.3", 8443, structs.ServiceAddress{Address: "10.30.1.3", Port: 8443}, structs.ServiceAddress{Address: "198.38.1.1", Port: 443}), @@ -564,7 +564,7 @@ func TestGatewayNodesDC6Hostname(t testing.T) structs.CheckServiceNodes { Address: "10.30.1.1", Datacenter: "dc6", }, - Service: structs.TestNodeServiceMeshGatewayWithAddrs(t, + Service: structs.TestNodeServiceMeshGatewayWithAddrs( "10.30.1.1", 8443, structs.ServiceAddress{Address: "10.0.1.1", Port: 8443}, structs.ServiceAddress{Address: "123.us-east-1.elb.notaws.com", Port: 443}), diff --git a/agent/proxycfg/testing_mesh_gateway.go b/agent/proxycfg/testing_mesh_gateway.go index 80d37220ccd..32720a601ea 100644 --- a/agent/proxycfg/testing_mesh_gateway.go +++ b/agent/proxycfg/testing_mesh_gateway.go @@ -420,7 +420,7 @@ func TestConfigSnapshotMeshGateway(t testing.T, variant string, nsFn func(ns *st // Create a duplicate entry in FedStateGateways, with a high ModifyIndex, to // verify that fresh data in the federation state is preferred over stale data // in GatewayGroups. - svc := structs.TestNodeServiceMeshGatewayWithAddrs(t, + svc := structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.1.3", 8443, structs.ServiceAddress{Address: "10.0.1.3", Port: 8443}, structs.ServiceAddress{Address: "198.18.1.3", Port: 443}, @@ -437,7 +437,7 @@ func TestConfigSnapshotMeshGateway(t testing.T, variant string, nsFn func(ns *st // Create a duplicate entry in FedStateGateways, with a low ModifyIndex, to // verify that stale data in the federation state is ignored in favor of the // fresher data in GatewayGroups. - svc := structs.TestNodeServiceMeshGatewayWithAddrs(t, + svc := structs.TestNodeServiceMeshGatewayWithAddrs( "10.0.1.3", 8443, structs.ServiceAddress{Address: "10.0.1.3", Port: 8443}, structs.ServiceAddress{Address: "198.18.1.3", Port: 443}, diff --git a/agent/structs/testing_catalog.go b/agent/structs/testing_catalog.go index 8047695bba5..c90af67d061 100644 --- a/agent/structs/testing_catalog.go +++ b/agent/structs/testing_catalog.go @@ -168,7 +168,7 @@ func TestNodeServiceExpose(t testing.T) *NodeService { // TestNodeServiceMeshGateway returns a *NodeService representing a valid Mesh Gateway func TestNodeServiceMeshGateway(t testing.T) *NodeService { - return TestNodeServiceMeshGatewayWithAddrs(t, + return TestNodeServiceMeshGatewayWithAddrs( "10.1.2.3", 8443, ServiceAddress{Address: "10.1.2.3", Port: 8443}, @@ -192,7 +192,8 @@ func TestNodeServiceTerminatingGateway(t testing.T, address string) *NodeService } } -func TestNodeServiceMeshGatewayWithAddrs(t testing.T, address string, port int, lanAddr, wanAddr ServiceAddress) *NodeService { +// TestNodeServiceMeshGatewayWithAddrs returns a *NodeService representing a valid Mesh Gateway with custom addresses. +func TestNodeServiceMeshGatewayWithAddrs(address string, port int, lanAddr, wanAddr ServiceAddress) *NodeService { return &NodeService{ Kind: ServiceKindMeshGateway, Service: "mesh-gateway",