diff --git a/crypto/storage/external/client.go b/crypto/storage/external/client.go index 3bda87927..e810b8a2d 100644 --- a/crypto/storage/external/client.go +++ b/crypto/storage/external/client.go @@ -30,7 +30,6 @@ import ( "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/crypto/storage/spi" "github.com/nuts-foundation/nuts-node/crypto/util" - safeHttp "github.com/nuts-foundation/nuts-node/http/client" ) // StorageType is the name of this storage type, used in health check reports and configuration. @@ -83,7 +82,7 @@ func NewAPIClient(config Config) (spi.Storage, error) { if _, err := url.ParseRequestURI(config.Address); err != nil { return nil, err } - client, _ := NewClientWithResponses(config.Address, WithHTTPClient(safeHttp.New(config.Timeout))) + client, _ := NewClientWithResponses(config.Address, WithHTTPClient(&http.Client{Timeout: config.Timeout})) return &APIClient{httpClient: client}, nil } diff --git a/vcr/test/openid4vci_integration_test.go b/vcr/test/openid4vci_integration_test.go index fc7f87732..3e90ed076 100644 --- a/vcr/test/openid4vci_integration_test.go +++ b/vcr/test/openid4vci_integration_test.go @@ -23,7 +23,6 @@ import ( "encoding/json" "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/jsonld" - "github.com/nuts-foundation/nuts-node/network/log" "github.com/nuts-foundation/nuts-node/vcr/issuer" "github.com/nuts-foundation/nuts-node/vcr/openid4vci" "github.com/nuts-foundation/nuts-node/vdr/didsubject" @@ -31,9 +30,7 @@ import ( "github.com/stretchr/testify/assert" "io" "net/http" - "net/http/httptrace" "net/url" - "sync" "testing" "time" @@ -80,76 +77,6 @@ func TestOpenID4VCIHappyFlow(t *testing.T) { }, 5*time.Second, "credential not retrieved by holder") } -func TestOpenID4VCIConnectionReuse(t *testing.T) { - // Our safe http Transport has MaxConnsPerHost = 5 - // for 2 http.Transport instance (one for issuer, one for wallet), - // so we expect max 10 connections in total. - const maxExpectedConnCount = 10 - - ctx := audit.TestContext() - _, baseURL, system := node.StartServer(t) - vcrService := system.FindEngineByName("vcr").(vcr.VCR) - - issuerDID := registerDID(t, system) - registerBaseURL(t, baseURL, system, issuerDID) - holderDID := registerDID(t, system) - registerBaseURL(t, baseURL, system, holderDID) - - credential := testCredential() - credential.Issuer = issuerDID.URI() - credential.ID, _ = ssi.ParseURI(issuerDID.URI().String() + "#1") - credential.CredentialSubject = append(credential.CredentialSubject, map[string]interface{}{ - "id": holderDID.URI().String(), - "purposeOfUse": "test", - }) - - newConns := map[string]int{} - mux := sync.Mutex{} - openid4vci.HttpClientTrace = &httptrace.ClientTrace{ - ConnectStart: func(network, addr string) { - log.Logger().Infof("Conn: %s/%s", network, addr) - mux.Lock() - defer mux.Unlock() - newConns[network+"/"+addr]++ - }, - } - - const numCreds = 12 - errChan := make(chan error, numCreds) - wg := sync.WaitGroup{} - for i := 0; i < numCreds; i++ { - wg.Add(1) - go func() { - defer wg.Done() - _, err := vcrService.Issuer().Issue(ctx, credential, issuer.CredentialOptions{ - Publish: true, - Public: false, - }) - if err != nil { - errChan <- err - return - } - }() - } - - wg.Wait() - // Drain errs channel, non-blocking - close(errChan) - var errs []string - for { - err := <-errChan - if err == nil { - break - - } - errs = append(errs, err.Error()) - } - assert.Empty(t, errs, "error issuing credential") - for host, v := range newConns { - assert.LessOrEqualf(t, v, maxExpectedConnCount, "number of created HTTP connections should be at most %d for host %s", 5, host) - } -} - // TestOpenID4VCIDisabled tests the issuer won't try to issue over OpenID4VCI when it's disabled. func TestOpenID4VCIDisabled(t *testing.T) { _, baseURL, system := node.StartServer(t, func(_, _ string) {