diff --git a/NOTICE.txt b/NOTICE.txt index b44d1d2667..79370a98f0 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1594,12 +1594,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- -Dependency : github.com/gofrs/uuid -Version: v4.4.0+incompatible +Dependency : github.com/gofrs/uuid/v5 +Version: v5.2.0 Licence type (autodetected): MIT -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid@v4.4.0+incompatible/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/v5@v5.2.0/LICENSE: Copyright (C) 2013-2018 by Maxim Bublis @@ -12024,36 +12024,6 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Dependency : github.com/gofrs/uuid/v5 -Version: v5.2.0 -Licence type (autodetected): MIT --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/v5@v5.2.0/LICENSE: - -Copyright (C) 2013-2018 by Maxim Bublis - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -------------------------------------------------------------------------------- Dependency : github.com/gogo/protobuf Version: v1.3.2 diff --git a/go.mod b/go.mod index 24465945f3..04f2a442b1 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/elastic/go-ucfg v0.8.8 github.com/fxamacker/cbor/v2 v2.8.0 github.com/go-chi/chi/v5 v5.2.1 - github.com/gofrs/uuid v4.4.0+incompatible + github.com/gofrs/uuid/v5 v5.2.0 github.com/google/go-cmp v0.7.0 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-version v1.7.0 @@ -61,7 +61,6 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect - github.com/gofrs/uuid/v5 v5.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index dfec22228f..d6faa43014 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,6 @@ github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= -github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM= github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= diff --git a/internal/pkg/api/handleEnroll.go b/internal/pkg/api/handleEnroll.go index 7853052563..01ea555d45 100644 --- a/internal/pkg/api/handleEnroll.go +++ b/internal/pkg/api/handleEnroll.go @@ -33,7 +33,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/rollback" "github.com/elastic/fleet-server/v7/internal/pkg/sqn" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/hashicorp/go-version" "github.com/miolini/datacounter" "github.com/rs/zerolog" diff --git a/internal/pkg/apikey/apikey_integration_test.go b/internal/pkg/apikey/apikey_integration_test.go index e0a29c71ff..068ed4ad62 100644 --- a/internal/pkg/apikey/apikey_integration_test.go +++ b/internal/pkg/apikey/apikey_integration_test.go @@ -7,14 +7,13 @@ package apikey import ( - "context" "errors" "testing" testlog "github.com/elastic/fleet-server/v7/internal/pkg/testing/log" "github.com/elastic/go-elasticsearch/v8" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" ) @@ -32,9 +31,7 @@ const testFleetRoles = ` ` func TestRead_existingKey(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) cfg := elasticsearch.Config{ Username: "elastic", @@ -84,9 +81,7 @@ func TestRead_existingKey(t *testing.T) { } func TestRead_noKey(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) cfg := elasticsearch.Config{ Username: "elastic", @@ -116,9 +111,7 @@ func TestCreateAPIKeyWithMetadata(t *testing.T) { for _, tt := range tts { t.Run(tt.name, func(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) cfg := elasticsearch.Config{ Username: "elastic", diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index e6208c371b..bd50d02c4b 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -11,7 +11,7 @@ import ( "strings" "sync" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/rs/zerolog" "github.com/elastic/fleet-server/v7/version" diff --git a/internal/pkg/config/config_test.go b/internal/pkg/config/config_test.go index fd978e199a..57f337ecbc 100644 --- a/internal/pkg/config/config_test.go +++ b/internal/pkg/config/config_test.go @@ -13,7 +13,7 @@ import ( testlog "github.com/elastic/fleet-server/v7/internal/pkg/testing/log" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/rs/zerolog" diff --git a/internal/pkg/dl/action_results_integration_test.go b/internal/pkg/dl/action_results_integration_test.go index 6ad197c4c6..f1dd732f03 100644 --- a/internal/pkg/dl/action_results_integration_test.go +++ b/internal/pkg/dl/action_results_integration_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/elastic/fleet-server/v7/internal/pkg/bulk" @@ -101,9 +101,7 @@ func (acrs ActionsResults) find(ar model.ActionResult) *model.ActionResult { } func TestActionsResultsStored(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker, acrs := setupActionResults(ctx, t) diff --git a/internal/pkg/dl/agent_integration_test.go b/internal/pkg/dl/agent_integration_test.go index 8266cb7b67..13b7ef2454 100644 --- a/internal/pkg/dl/agent_integration_test.go +++ b/internal/pkg/dl/agent_integration_test.go @@ -7,12 +7,11 @@ package dl import ( - "context" "encoding/json" "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,9 +22,7 @@ import ( ) func TestFindAgent_NewModel(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, FleetAgents) diff --git a/internal/pkg/dl/enrollment_api_key_integration_test.go b/internal/pkg/dl/enrollment_api_key_integration_test.go index 45dab91f8d..6f3331fba0 100644 --- a/internal/pkg/dl/enrollment_api_key_integration_test.go +++ b/internal/pkg/dl/enrollment_api_key_integration_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/rs/xid" @@ -53,9 +53,7 @@ func storeRandomEnrollmentAPIKey(ctx context.Context, bulker bulk.Bulk, index st } func TestSearchEnrollmentAPIKeyByID(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, FleetEnrollmentAPIKeys) @@ -86,9 +84,7 @@ func TestSearchEnrollmentAPIKeyByID(t *testing.T) { func TestSearchEnrollmentAPIKeyByPolicyID(t *testing.T) { t.Skip("Flaky test see https://github.com/elastic/fleet-server/issues/1289") - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, FleetEnrollmentAPIKeys) @@ -118,9 +114,7 @@ func TestSearchEnrollmentAPIKeyByPolicyID(t *testing.T) { } func TestSearchEnrollmentAPIKeyByPolicyIDWithInactiveIDs(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, FleetEnrollmentAPIKeys) diff --git a/internal/pkg/dl/migration_integration_test.go b/internal/pkg/dl/migration_integration_test.go index e99bc746a8..25d0445ab0 100644 --- a/internal/pkg/dl/migration_integration_test.go +++ b/internal/pkg/dl/migration_integration_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -72,9 +72,7 @@ func createSomeAgents(ctx context.Context, t *testing.T, n int, apiKey bulk.APIK } func TestMigrateOutputs_withDefaultAPIKeyHistory(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) now, err := time.Parse(time.RFC3339, nowStr) require.NoError(t, err, "could not parse time "+nowStr) @@ -164,9 +162,7 @@ func TestMigrateOutputs_withDefaultAPIKeyHistory(t *testing.T) { } func TestMigrateOutputs_dontMigrateTwice(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) now, err := time.Parse(time.RFC3339, nowStr) require.NoError(t, err, "could not parse time "+nowStr) @@ -193,9 +189,7 @@ func TestMigrateOutputs_dontMigrateTwice(t *testing.T) { } func TestMigrateOutputs_nil_DefaultAPIKeyHistory(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) wantOutputType := "elasticsearch" @@ -294,9 +288,7 @@ func TestMigrateOutputs_nil_DefaultAPIKeyHistory(t *testing.T) { } func TestMigrateOutputs_no_agent_document(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) now, err := time.Parse(time.RFC3339, nowStr) require.NoError(t, err, "could not parse time "+nowStr) diff --git a/internal/pkg/dl/output_health.go b/internal/pkg/dl/output_health.go index 2282fb6990..d8bfe2699e 100644 --- a/internal/pkg/dl/output_health.go +++ b/internal/pkg/dl/output_health.go @@ -11,7 +11,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/bulk" "github.com/elastic/fleet-server/v7/internal/pkg/model" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" ) func CreateOutputHealth(ctx context.Context, bulker bulk.Bulk, doc model.OutputHealth) error { diff --git a/internal/pkg/dl/policies_integration_test.go b/internal/pkg/dl/policies_integration_test.go index fecf1b3cf9..9d94821142 100644 --- a/internal/pkg/dl/policies_integration_test.go +++ b/internal/pkg/dl/policies_integration_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" @@ -56,9 +56,7 @@ func storeRandomPolicy(ctx context.Context, bulker bulk.Bulk, index string) (mod } func TestQueryLatestPolicies(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, FleetPolicies) @@ -87,9 +85,7 @@ func TestQueryLatestPolicies(t *testing.T) { } func TestCreatePolicy(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, FleetPolicies) @@ -107,9 +103,7 @@ func TestCreatePolicy(t *testing.T) { } func TestQueryOutputFromPolicy(t *testing.T) { - ctx, cn := context.WithCancel(context.Background()) - defer cn() - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, FleetPolicies) diff --git a/internal/pkg/dsl/tmpl.go b/internal/pkg/dsl/tmpl.go index e9e4a3c026..0e8cccba02 100644 --- a/internal/pkg/dsl/tmpl.go +++ b/internal/pkg/dsl/tmpl.go @@ -11,7 +11,7 @@ import ( "fmt" "strings" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" ) const kPrefix = "TMPL." diff --git a/internal/pkg/es/result_test.go b/internal/pkg/es/result_test.go index a70224c154..6eabde4a21 100644 --- a/internal/pkg/es/result_test.go +++ b/internal/pkg/es/result_test.go @@ -10,7 +10,7 @@ import ( "encoding/json" "testing" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/rs/xid" diff --git a/internal/pkg/file/uploader/upload.go b/internal/pkg/file/uploader/upload.go index 55bf6fa7dd..3ce35a4c96 100644 --- a/internal/pkg/file/uploader/upload.go +++ b/internal/pkg/file/uploader/upload.go @@ -16,7 +16,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/cache" "github.com/elastic/fleet-server/v7/internal/pkg/file" "github.com/elastic/go-elasticsearch/v8" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "go.elastic.co/apm/v2" ) diff --git a/internal/pkg/logger/http.go b/internal/pkg/logger/http.go index ef38612067..62ae923e93 100644 --- a/internal/pkg/logger/http.go +++ b/internal/pkg/logger/http.go @@ -16,7 +16,7 @@ import ( "sync/atomic" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/rs/zerolog" "go.elastic.co/apm/module/apmzerolog/v2" diff --git a/internal/pkg/policy/monitor_integration_test.go b/internal/pkg/policy/monitor_integration_test.go index 2ce96544c7..70a6e29788 100644 --- a/internal/pkg/policy/monitor_integration_test.go +++ b/internal/pkg/policy/monitor_integration_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/stretchr/testify/require" "github.com/elastic/fleet-server/v7/internal/pkg/config" @@ -34,7 +34,7 @@ var intPolData = model.PolicyData{ } func TestMonitor_Integration(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() ctx = testlog.SetLogger(t).WithContext(ctx) @@ -74,7 +74,7 @@ func TestMonitor_Integration(t *testing.T) { merr = nil } }() - err = m.(*monitorT).waitStart(ctx) + err = pm.waitStart(ctx) require.NoError(t, err) agentID := uuid.Must(uuid.NewV4()).String() @@ -130,7 +130,7 @@ func TestMonitor_Integration(t *testing.T) { } func TestMonitor_Debounce_Integration(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() ctx = testlog.SetLogger(t).WithContext(ctx) @@ -170,7 +170,7 @@ func TestMonitor_Debounce_Integration(t *testing.T) { merr = nil } }() - err = m.(*monitorT).waitStart(ctx) + err = pm.waitStart(ctx) require.NoError(t, err) agentID := uuid.Must(uuid.NewV4()).String() @@ -321,7 +321,7 @@ func TestMonitor_Debounce_Integration(t *testing.T) { } func TestMonitor_Revisions(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() ctx = testlog.SetLogger(t).WithContext(ctx) @@ -361,7 +361,7 @@ func TestMonitor_Revisions(t *testing.T) { merr = nil } }() - err = m.(*monitorT).waitStart(ctx) + err = pm.waitStart(ctx) require.NoError(t, err) agentID := uuid.Must(uuid.NewV4()).String() @@ -443,7 +443,7 @@ func TestMonitor_Revisions(t *testing.T) { } func TestMonitor_KickDeploy(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() ctx = testlog.SetLogger(t).WithContext(ctx) @@ -483,7 +483,7 @@ func TestMonitor_KickDeploy(t *testing.T) { merr = nil } }() - err = m.(*monitorT).waitStart(ctx) + err = pm.waitStart(ctx) require.NoError(t, err) agentID := uuid.Must(uuid.NewV4()).String() diff --git a/internal/pkg/policy/monitor_test.go b/internal/pkg/policy/monitor_test.go index f822802fa8..869420da97 100644 --- a/internal/pkg/policy/monitor_test.go +++ b/internal/pkg/policy/monitor_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/rs/xid" "github.com/stretchr/testify/assert" diff --git a/internal/pkg/policy/policy_output_integration_test.go b/internal/pkg/policy/policy_output_integration_test.go index d771612161..41cf6a22e5 100644 --- a/internal/pkg/policy/policy_output_integration_test.go +++ b/internal/pkg/policy/policy_output_integration_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -48,7 +48,7 @@ func TestRenderUpdatePainlessScript(t *testing.T) { outputName := "output_" + tt.name outputAPIKey := bulk.APIKey{ID: "new_ID", Key: "new-key"} - ctx := testlog.SetLogger(t).WithContext(context.Background()) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, dl.FleetAgents) now := time.Now().UTC() @@ -132,7 +132,7 @@ func TestRenderUpdatePainlessScript(t *testing.T) { } func TestPolicyOutputESPrepareRealES(t *testing.T) { - ctx := testlog.SetLogger(t).WithContext(context.Background()) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, dl.FleetAgents) agentID := createAgent(ctx, t, index, bulker, map[string]*model.PolicyOutput{}) @@ -205,7 +205,7 @@ func createAgent(ctx context.Context, t *testing.T, index string, bulker bulk.Bu } func TestPolicyOutputESPrepareRemoteES(t *testing.T) { - ctx := testlog.SetLogger(t).WithContext(context.Background()) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, dl.FleetAgents) agentID := createAgent(ctx, t, index, bulker, map[string]*model.PolicyOutput{}) @@ -254,7 +254,7 @@ func TestPolicyOutputESPrepareRemoteES(t *testing.T) { } func TestPolicyOutputESPrepareESRetireRemoteAPIKeys(t *testing.T) { - ctx := testlog.SetLogger(t).WithContext(context.Background()) + ctx := testlog.SetLogger(t).WithContext(t.Context()) index, bulker := ftesting.SetupCleanIndex(ctx, t, dl.FleetAgents) // simulate a previous remote output, that is removed from outputMap diff --git a/internal/pkg/policy/self_test.go b/internal/pkg/policy/self_test.go index b7dc7cccd8..b678a77964 100644 --- a/internal/pkg/policy/self_test.go +++ b/internal/pkg/policy/self_test.go @@ -17,7 +17,7 @@ import ( "time" "github.com/elastic/elastic-agent-client/v7/pkg/client" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/rs/xid" "github.com/stretchr/testify/mock" diff --git a/internal/pkg/server/agent_integration_test.go b/internal/pkg/server/agent_integration_test.go index 4d883ac94a..e6552a753f 100644 --- a/internal/pkg/server/agent_integration_test.go +++ b/internal/pkg/server/agent_integration_test.go @@ -24,7 +24,7 @@ import ( "github.com/elastic/elastic-agent-client/v7/pkg/client/mock" "github.com/elastic/elastic-agent-client/v7/pkg/proto" "github.com/elastic/go-ucfg" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/hashicorp/go-cleanhttp" "github.com/rs/zerolog" "github.com/stretchr/testify/assert" diff --git a/internal/pkg/server/fleet_integration_test.go b/internal/pkg/server/fleet_integration_test.go index 6458cf2cd3..caeb5f65df 100644 --- a/internal/pkg/server/fleet_integration_test.go +++ b/internal/pkg/server/fleet_integration_test.go @@ -22,7 +22,7 @@ import ( "testing" "time" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/google/go-cmp/cmp" "github.com/hashicorp/go-cleanhttp" "github.com/rs/zerolog" @@ -296,7 +296,7 @@ func (m *MockReporter) UpdateState(state client.UnitState, message string, paylo } func TestServerConfigErrorReload(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // don't use startTestServer as we need failing initial config. @@ -402,7 +402,7 @@ func TestServerConfigErrorReload(t *testing.T) { } func TestServerUnauthorized(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server @@ -503,7 +503,7 @@ func stubAPMServer(t *testing.T, ch chan<- struct{}) http.Handler { } func TestServerInstrumentation(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() tracerConnected := make(chan struct{}, 1) @@ -592,13 +592,10 @@ func TestServerInstrumentation(t *testing.T) { // make a followup checkin request to get the policy action // make another followup ack request for the action func Test_SmokeTest_Agent_Calls(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) cli := cleanhttp.DefaultClient() @@ -741,13 +738,11 @@ func Test_Agent_Enrollment_Id(t *testing.T) { "tags": [] } }` - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) t.Log("Enroll the first agent with enrollment_id") firstEnroll := EnrollAgent(t, ctx, srv, enrollBodyWEnrollmentID) @@ -788,13 +783,11 @@ func Test_Agent_Enrollment_Id_Invalidated_API_key(t *testing.T) { "tags": [] } }` - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) t.Log("Enroll the first agent with enrollment_id") firstEnroll := EnrollAgent(t, ctx, srv, enrollBodyWEnrollmentID) @@ -846,13 +839,11 @@ func Test_Agent_Id_No_ReplaceToken(t *testing.T) { "tags": [] } }` - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) t.Log("Enroll the first agent with id") firstEnroll := EnrollAgent(t, ctx, srv, enrollBodyWID) @@ -890,13 +881,11 @@ func Test_Agent_Id_ReplaceToken_Mismatch(t *testing.T) { "tags": [] } }` - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) t.Log("Enroll the first agent with id") firstEnroll := EnrollAgent(t, ctx, srv, enrollBodyWID) @@ -945,13 +934,11 @@ func Test_Agent_Id(t *testing.T) { "tags": [] } }` - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) t.Log("Enroll the first agent with id") firstEnroll := EnrollAgent(t, ctx, srv, enrollBodyWID) @@ -992,13 +979,10 @@ func Test_Agent_Id(t *testing.T) { } func Test_Agent_Auth_errors(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) cli := cleanhttp.DefaultClient() @@ -1117,13 +1101,10 @@ func Test_Agent_Auth_errors(t *testing.T) { } func Test_Agent_request_errors(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) cli := cleanhttp.DefaultClient() t.Run("no auth", func(t *testing.T) { @@ -1199,13 +1180,10 @@ func Test_Agent_request_errors(t *testing.T) { } func Test_SmokeTest_CheckinPollTimeout(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - // Start test server - srv, err := startTestServer(t, ctx, policyData) + srv, err := startTestServer(t, t.Context(), policyData) require.NoError(t, err) - ctx = testlog.SetLogger(t).WithContext(ctx) + ctx := testlog.SetLogger(t).WithContext(t.Context()) cli := cleanhttp.DefaultClient() @@ -1275,7 +1253,7 @@ func Test_SmokeTest_CheckinPollTimeout(t *testing.T) { require.Equal(t, http.StatusOK, res.StatusCode) t.Logf("checkin 2: agent %s poll_timeout 3m", agentID) - ctx, cancel = context.WithTimeout(ctx, 3*time.Minute) + ctx, cancel := context.WithTimeout(ctx, 3*time.Minute) defer cancel() req, err = http.NewRequestWithContext(ctx, "POST", srv.baseURL()+"/api/fleet/agents/"+agentID+"/checkin", strings.NewReader(fmt.Sprintf(`{ "ack_token": "%s", @@ -1331,7 +1309,7 @@ func Test_SmokeTest_CheckinPollTimeout(t *testing.T) { } func Test_SmokeTest_CheckinPollShutdown(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server @@ -1445,7 +1423,7 @@ func Test_SmokeTest_CheckinPollShutdown(t *testing.T) { // Test_SmokeTest_Verify_v85Migrate will ensure that the policy regenerates output keys when the agent doc contains an empty key func Test_SmokeTest_Verify_v85Migrate(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server @@ -1589,7 +1567,7 @@ func Test_SmokeTest_Verify_v85Migrate(t *testing.T) { } func Test_SmokeTest_AuditUnenroll(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server diff --git a/internal/pkg/server/fleet_secrets_integration_test.go b/internal/pkg/server/fleet_secrets_integration_test.go index a156f05493..246583312d 100644 --- a/internal/pkg/server/fleet_secrets_integration_test.go +++ b/internal/pkg/server/fleet_secrets_integration_test.go @@ -17,7 +17,7 @@ import ( "testing" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/hashicorp/go-cleanhttp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -157,7 +157,7 @@ func createAgentPolicyWithSecrets(t *testing.T, ctx context.Context, bulker bulk } func Test_Agent_Policy_Secrets(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server diff --git a/internal/pkg/server/namespaces_integration_test.go b/internal/pkg/server/namespaces_integration_test.go index 819af82922..5cc0ba865f 100644 --- a/internal/pkg/server/namespaces_integration_test.go +++ b/internal/pkg/server/namespaces_integration_test.go @@ -21,7 +21,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/apikey" "github.com/elastic/fleet-server/v7/internal/pkg/dl" "github.com/elastic/fleet-server/v7/internal/pkg/model" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/hashicorp/go-cleanhttp" "github.com/stretchr/testify/require" ) @@ -154,7 +154,7 @@ func CheckActionResultsNamespace(t *testing.T, ctx context.Context, srv *tserver func Test_Agent_Namespace_test1(t *testing.T) { testNamespace := "test1" - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server diff --git a/internal/pkg/server/remote_es_output_integration_test.go b/internal/pkg/server/remote_es_output_integration_test.go index 27d606502a..77ebf86890 100644 --- a/internal/pkg/server/remote_es_output_integration_test.go +++ b/internal/pkg/server/remote_es_output_integration_test.go @@ -23,7 +23,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/bulk" "github.com/elastic/fleet-server/v7/internal/pkg/dl" "github.com/elastic/fleet-server/v7/internal/pkg/model" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/hashicorp/go-cleanhttp" "github.com/stretchr/testify/require" ) @@ -100,7 +100,7 @@ func Checkin(t *testing.T, ctx context.Context, srv *tserver, agentID, key strin } func getRemoteElasticsearchCa(t *testing.T) string { - data, err := base64.StdEncoding.DecodeString(strings.Replace(os.Getenv("REMOTE_ELASTICSEARCH_CA_CRT_BASE64"), " ", "", -1)) + data, err := base64.StdEncoding.DecodeString(strings.ReplaceAll(os.Getenv("REMOTE_ELASTICSEARCH_CA_CRT_BASE64"), " ", "")) require.NoError(t, err) return string(data) @@ -140,7 +140,7 @@ func Ack(t *testing.T, ctx context.Context, srv *tserver, actionID, agentID, key } func Test_Agent_Remote_ES_Output(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server @@ -294,7 +294,7 @@ func verifyRemoteAPIKey(t *testing.T, ctx context.Context, apiKeyID string, inva } func Test_Agent_Remote_ES_Output_ForceUnenroll(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server @@ -415,7 +415,7 @@ func Test_Agent_Remote_ES_Output_ForceUnenroll(t *testing.T) { } func Test_Agent_Remote_ES_Output_Unenroll(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() // Start test server diff --git a/internal/pkg/testing/actions.go b/internal/pkg/testing/actions.go index b62c299eda..b7b39160cf 100644 --- a/internal/pkg/testing/actions.go +++ b/internal/pkg/testing/actions.go @@ -16,7 +16,7 @@ import ( "github.com/elastic/fleet-server/v7/internal/pkg/model" "github.com/elastic/fleet-server/v7/internal/pkg/testing/rnd" - "github.com/gofrs/uuid" + "github.com/gofrs/uuid/v5" "github.com/rs/xid" )