Skip to content

Commit 1b32001

Browse files
committed
capabilities/v2/actions/confidentialrelay/types_test.go: Allow non-hex and arbitrary length execution IDs
Relaxes the validation constraints for the execution_id field on SecretsRequestParams and CapabilityRequestParams. The field is now only validated to be non-empty, and no longer restricted to a 32-byte hex-encoded string.
1 parent a03d6a5 commit 1b32001

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

pkg/capabilities/v2/actions/confidentialrelay/types_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,6 @@ func TestSecretsRequestParams_Validate(t *testing.T) {
204204
p.Owner = "0xZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
205205
}, "owner must be a 0x-prefixed 20-byte hex address"},
206206
{"missing execution_id", func(p *SecretsRequestParams) { p.ExecutionID = "" }, "execution_id is required"},
207-
{"execution_id wrong length", func(p *SecretsRequestParams) { p.ExecutionID = "abcd" }, "execution_id must be 32 bytes hex-encoded"},
208-
{"execution_id with 0x prefix", func(p *SecretsRequestParams) {
209-
p.ExecutionID = "0x" + validExecutionID[:62]
210-
}, "execution_id must be 32 bytes hex-encoded"},
211-
{"execution_id non-hex digits", func(p *SecretsRequestParams) {
212-
p.ExecutionID = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
213-
}, "execution_id must be 32 bytes hex-encoded"},
214207
{"missing enclave_public_key", func(p *SecretsRequestParams) { p.EnclavePublicKey = "" }, "enclave_public_key is required"},
215208
{"enclave_public_key non-hex digits", func(p *SecretsRequestParams) {
216209
p.EnclavePublicKey = "not-hex"
@@ -243,6 +236,12 @@ func TestSecretsRequestParams_Validate(t *testing.T) {
243236
require.NoError(t, validSecretsParams().Validate())
244237
})
245238

239+
t.Run("non-empty execution_id accepted", func(t *testing.T) {
240+
p := validSecretsParams()
241+
p.ExecutionID = "not-a-hex-execution-id"
242+
require.NoError(t, p.Validate())
243+
})
244+
246245
t.Run("optional fields can be empty", func(t *testing.T) {
247246
p := validSecretsParams()
248247
p.OrgID = ""
@@ -264,10 +263,6 @@ func TestCapabilityRequestParams_Validate(t *testing.T) {
264263
p.Owner = "1111111111111111111111111111111111111111"
265264
}, "owner must be a 0x-prefixed 20-byte hex address"},
266265
{"missing execution_id", func(p *CapabilityRequestParams) { p.ExecutionID = "" }, "execution_id is required"},
267-
{"execution_id wrong length", func(p *CapabilityRequestParams) { p.ExecutionID = "abcd" }, "execution_id must be 32 bytes hex-encoded"},
268-
{"execution_id non-hex digits", func(p *CapabilityRequestParams) {
269-
p.ExecutionID = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
270-
}, "execution_id must be 32 bytes hex-encoded"},
271266
{"missing reference_id", func(p *CapabilityRequestParams) { p.ReferenceID = "" }, "reference_id is required"},
272267
{"missing capability_id", func(p *CapabilityRequestParams) { p.CapabilityID = "" }, "capability_id is required"},
273268
{"missing payload", func(p *CapabilityRequestParams) { p.Payload = "" }, "payload is required"},
@@ -286,6 +281,12 @@ func TestCapabilityRequestParams_Validate(t *testing.T) {
286281
require.NoError(t, validCapabilityParams().Validate())
287282
})
288283

284+
t.Run("non-empty execution_id accepted", func(t *testing.T) {
285+
p := validCapabilityParams()
286+
p.ExecutionID = "not-a-hex-execution-id"
287+
require.NoError(t, p.Validate())
288+
})
289+
289290
t.Run("attestation can be empty", func(t *testing.T) {
290291
p := validCapabilityParams()
291292
p.Attestation = ""

0 commit comments

Comments
 (0)