Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions system-tests/tests/regression/cre/http/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ type Config struct {
URL string `json:"url"`
TestCase string `json:"testCase"` // Identifies which test case to run
}

const (
TestCaseInvalidKeyType = "invalid-key-type"
TestCaseInvalidPublicKey = "invalid-public-key"
TestCaseNonExistingPublicKey = "non-existing-public-key"
)
10 changes: 5 additions & 5 deletions system-tests/tests/regression/cre/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func RunHTTPRegressionWorkflow(wfCfg config.Config, _ *slog.Logger, _ cre.Secret
var triggerConfig *http.Config

switch wfCfg.TestCase {
case "invalid-key-type":
case config.TestCaseInvalidKeyType:
// Use an invalid key type (non-existent enum value)
triggerConfig = &http.Config{
AuthorizedKeys: []*http.AuthorizedKey{
Expand All @@ -40,23 +40,23 @@ func RunHTTPRegressionWorkflow(wfCfg config.Config, _ *slog.Logger, _ cre.Secret
},
},
}
case "invalid-public-key":
case config.TestCaseInvalidPublicKey:
// Use an invalid public key format
triggerConfig = &http.Config{
AuthorizedKeys: []*http.AuthorizedKey{
{
Type: http.KeyType_KEY_TYPE_ECDSA_EVM,
PublicKey: "invalid-public-key-format",
PublicKey: wfCfg.AuthorizedKey,
},
},
}
case "non-existing-public-key":
case config.TestCaseNonExistingPublicKey:
// Use a non-existing but properly formatted public key
triggerConfig = &http.Config{
AuthorizedKeys: []*http.AuthorizedKey{
{
Type: http.KeyType_KEY_TYPE_ECDSA_EVM,
PublicKey: "0x0000000000000000000000000000000000000000",
PublicKey: wfCfg.AuthorizedKey,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,27 @@ import (
type httpNegativeTest struct {
name string
testCase string
keyToUse string
expectedError string
}

var httpNegativeTests = []httpNegativeTest{
{
name: "invalid AuthorizedKey.Type",
testCase: "invalid-key-type",
testCase: http_config.TestCaseInvalidKeyType,
keyToUse: mustDKGKey(),
expectedError: "unsupported key type",
},
{
name: "invalid AuthorizedKey.PublicKey format",
testCase: "invalid-public-key",
testCase: http_config.TestCaseInvalidPublicKey,
keyToUse: "invalid-public-key-format",
expectedError: "invalid public key",
},
{
name: "non-existing AuthorizedKey.PublicKey",
testCase: "non-existing-public-key",
testCase: http_config.TestCaseNonExistingPublicKey,
keyToUse: "0x0000000000000000000000000000000000000000",
expectedError: "Auth failure",
},
}
Expand Down Expand Up @@ -113,21 +117,8 @@ func HTTPTriggerFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, httpNeg
t_helpers.IgnoreUserLogs(t.Context(), userLogsCh)
testLogger.Info().Msg("Creating HTTP negative test workflow configuration...")

// Determine the authorized key to use based on test case
var authorizedKeyToUse string
switch httpNegativeTest.testCase {
case "invalid-public-key":
authorizedKeyToUse = "0x000000000000000000000000000000000000000"
case "non-existing-public-key":
authorizedKeyToUse = "0x0000000000000000000000000000000000000000"
default:
dkgKey, dErr := dkgrecipientkey.New()
require.NoError(t, dErr, "failed to generate new DKG recipient key")
authorizedKeyToUse = dkgKey.PublicKeyString()
}

workflowConfig := http_config.Config{
AuthorizedKey: authorizedKeyToUse,
AuthorizedKey: httpNegativeTest.keyToUse,
URL: fakeServer.BaseURLHost + "/orders-" + testID,
TestCase: httpNegativeTest.testCase,
}
Expand All @@ -137,7 +128,7 @@ func HTTPTriggerFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, httpNeg

// For invalid key type and invalid public key format, we expect the workflow deployment/trigger setup to fail
// For non-existing public key, we expect the trigger execution to fail with unauthorized error at gateway level
if httpNegativeTest.testCase == "non-existing-public-key" {
if httpNegativeTest.testCase == http_config.TestCaseNonExistingPublicKey {
// Try to execute the trigger with a valid signing key but unauthorized public key
testLogger.Info().Msg("Attempting to execute HTTP trigger with unauthorized key...")
authFailureDetected := executeHTTPTriggerRequestExpectingFailure(t, testEnv, workflowName, signingKey)
Expand Down Expand Up @@ -314,3 +305,11 @@ func startTestOrderServer(t *testing.T, port int, testID string) (*fake.Output,
framework.L.Info().Msgf("Test order server started on port %d at: %s with endpoint %s", port, fakeOutput.BaseURLHost, endpoint)
return fakeOutput, nil
}

func mustDKGKey() string {
dkgKey, dErr := dkgrecipientkey.New()
if dErr != nil {
panic(dErr)
Comment thread
Tofel marked this conversation as resolved.
}
return dkgKey.PublicKeyString()
}
Loading