From 5211322548d47cb5d54c94390f8e2369258bc6e2 Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 23 Oct 2023 13:54:30 +0100 Subject: [PATCH] [BCF-2710] Randomize external_initiators.name (#11036) --- core/bridges/external_initiator_test.go | 4 +++- core/bridges/orm_test.go | 7 +++++-- core/cmd/shell_remote_test.go | 3 ++- core/web/ping_controller_test.go | 4 +++- core/web/router_test.go | 6 ++++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/core/bridges/external_initiator_test.go b/core/bridges/external_initiator_test.go index 923fed74f70..9f59c8e0030 100644 --- a/core/bridges/external_initiator_test.go +++ b/core/bridges/external_initiator_test.go @@ -3,6 +3,7 @@ package bridges_test import ( "testing" + "github.com/google/uuid" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink/v2/core/auth" @@ -18,8 +19,9 @@ func TestNewExternalInitiator(t *testing.T) { assert.Len(t, eia.Secret, 64) url := cltest.WebURL(t, "http://localhost:8888") + name := uuid.New().String() eir := &bridges.ExternalInitiatorRequest{ - Name: "bitcoin", + Name: name, URL: &url, } ei, err := bridges.NewExternalInitiator(eia, eir) diff --git a/core/bridges/orm_test.go b/core/bridges/orm_test.go index 8034d3f05d2..db043393350 100644 --- a/core/bridges/orm_test.go +++ b/core/bridges/orm_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "github.com/google/uuid" "github.com/smartcontractkit/sqlx" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -159,8 +160,9 @@ func TestORM_CreateExternalInitiator(t *testing.T) { _, orm := setupORM(t) token := auth.NewToken() + name := uuid.New().String() req := bridges.ExternalInitiatorRequest{ - Name: "externalinitiator", + Name: name, } exi, err := bridges.NewExternalInitiator(token, &req) require.NoError(t, err) @@ -175,8 +177,9 @@ func TestORM_DeleteExternalInitiator(t *testing.T) { _, orm := setupORM(t) token := auth.NewToken() + name := uuid.New().String() req := bridges.ExternalInitiatorRequest{ - Name: "externalinitiator", + Name: name, } exi, err := bridges.NewExternalInitiator(token, &req) require.NoError(t, err) diff --git a/core/cmd/shell_remote_test.go b/core/cmd/shell_remote_test.go index 8fb1a9fb646..c1d15df9ec8 100644 --- a/core/cmd/shell_remote_test.go +++ b/core/cmd/shell_remote_test.go @@ -12,6 +12,7 @@ import ( "testing" "time" + "github.com/google/uuid" "github.com/kylelemons/godebug/diff" "github.com/pelletier/go-toml" "github.com/stretchr/testify/assert" @@ -220,7 +221,7 @@ func TestShell_DestroyExternalInitiator(t *testing.T) { token := auth.NewToken() exi, err := bridges.NewExternalInitiator(token, - &bridges.ExternalInitiatorRequest{Name: "name"}, + &bridges.ExternalInitiatorRequest{Name: uuid.New().String()}, ) require.NoError(t, err) err = app.BridgeORM().CreateExternalInitiator(exi) diff --git a/core/web/ping_controller_test.go b/core/web/ping_controller_test.go index 7798c5a672e..8e1862cd8c7 100644 --- a/core/web/ping_controller_test.go +++ b/core/web/ping_controller_test.go @@ -5,6 +5,8 @@ import ( "strings" "testing" + "github.com/google/uuid" + "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -43,7 +45,7 @@ func TestPingController_Show_ExternalInitiatorCredentials(t *testing.T) { } eir_url := cltest.WebURL(t, "http://localhost:8888") eir := &bridges.ExternalInitiatorRequest{ - Name: "bitcoin", + Name: uuid.New().String(), URL: &eir_url, } diff --git a/core/web/router_test.go b/core/web/router_test.go index e08d474154a..18177a1ac28 100644 --- a/core/web/router_test.go +++ b/core/web/router_test.go @@ -6,6 +6,8 @@ import ( "net/http/httptest" "testing" + "github.com/google/uuid" + "github.com/smartcontractkit/chainlink/v2/core/auth" "github.com/smartcontractkit/chainlink/v2/core/bridges" "github.com/smartcontractkit/chainlink/v2/core/internal/cltest" @@ -57,7 +59,7 @@ func TestTokenAuthRequired_TokenCredentials(t *testing.T) { eia := auth.NewToken() url := cltest.WebURL(t, "http://localhost:8888") eir := &bridges.ExternalInitiatorRequest{ - Name: "bitcoin", + Name: uuid.New().String(), URL: &url, } ea, err := bridges.NewExternalInitiator(eia, eir) @@ -89,7 +91,7 @@ func TestTokenAuthRequired_BadTokenCredentials(t *testing.T) { eia := auth.NewToken() url := cltest.WebURL(t, "http://localhost:8888") eir := &bridges.ExternalInitiatorRequest{ - Name: "bitcoin", + Name: uuid.New().String(), URL: &url, } ea, err := bridges.NewExternalInitiator(eia, eir)