mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
context propagation: pkg/csplugin (#3273)
This commit is contained in:
parent
50d115b914
commit
8ff58ee74e
11 changed files with 66 additions and 33 deletions
|
@ -180,9 +180,7 @@ func NewAPITestForwardedFor(t *testing.T, ctx context.Context) (*gin.Engine, csc
|
|||
return router, config
|
||||
}
|
||||
|
||||
func ValidateMachine(t *testing.T, machineID string, config *csconfig.DatabaseCfg) {
|
||||
ctx := context.TODO()
|
||||
|
||||
func ValidateMachine(t *testing.T, ctx context.Context, machineID string, config *csconfig.DatabaseCfg) {
|
||||
dbClient, err := database.NewClient(ctx, config)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -269,7 +267,7 @@ func readDecisionsStreamResp(t *testing.T, resp *httptest.ResponseRecorder) (map
|
|||
return response, resp.Code
|
||||
}
|
||||
|
||||
func CreateTestMachine(t *testing.T, router *gin.Engine, token string) string {
|
||||
func CreateTestMachine(t *testing.T, ctx context.Context, router *gin.Engine, token string) string {
|
||||
regReq := MachineTest
|
||||
regReq.RegistrationToken = token
|
||||
b, err := json.Marshal(regReq)
|
||||
|
@ -277,8 +275,6 @@ func CreateTestMachine(t *testing.T, router *gin.Engine, token string) string {
|
|||
|
||||
body := string(b)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequestWithContext(ctx, http.MethodPost, "/v1/watchers", strings.NewReader(body))
|
||||
req.Header.Set("User-Agent", UserAgent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue