From 5ead73348afa3c854a68f11903004ef3a60ee84f Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Thu, 13 Jun 2024 14:59:38 +0100 Subject: [PATCH] Reference field is optional for CONFIRM_IDENTITY updates --- lambda/update/confirm_identity.go | 4 +--- lambda/update/confirm_identity_test.go | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lambda/update/confirm_identity.go b/lambda/update/confirm_identity.go index 68c1122a..f1032155 100644 --- a/lambda/update/confirm_identity.go +++ b/lambda/update/confirm_identity.go @@ -46,9 +46,7 @@ func validateConfirmIdentity(prefix string, actor idccActor, ic *shared.Identity Field("/checkedAt", &ic.CheckedAt, parse.Validate(func() []shared.FieldError { return validate.Time("", ic.CheckedAt) }), parse.MustMatchExisting()). - Field("/reference", &ic.Reference, parse.Validate(func() []shared.FieldError { - return validate.Required("", ic.Reference) - }), parse.MustMatchExisting()). + Field("/reference", &ic.Reference, parse.Optional(), parse.MustMatchExisting()). Consumed() }).Errors() diff --git a/lambda/update/confirm_identity_test.go b/lambda/update/confirm_identity_test.go index 18cc673f..be6493e1 100644 --- a/lambda/update/confirm_identity_test.go +++ b/lambda/update/confirm_identity_test.go @@ -47,7 +47,7 @@ func TestConfirmIdentityDonorBadFieldsFails(t *testing.T) { Old: json.RawMessage("null"), New: json.RawMessage(`"` + time.Now().Format(time.RFC3339Nano) + `"`), }, - // empty required field + // empty optional field - does not cause an error message { Key: "/donor/identityCheck/reference", Old: json.RawMessage("null"), @@ -63,9 +63,9 @@ func TestConfirmIdentityDonorBadFieldsFails(t *testing.T) { idCheckComplete, errors := validateDonorConfirmIdentity(changes, &shared.Lpa{}) - // errors: missing "checkedAt" field, invalid value for "type" field, empty "reference" field, + // errors: missing "checkedAt" field, invalid value for "type" field, // unexpected "irrelevantButStillADate" field - assert.Len(t, errors, 4) + assert.Len(t, errors, 3) assert.Equal(t, &shared.IdentityCheck{Type: "rinky-dink-login-system"}, idCheckComplete.IdentityCheck) assert.Equal(t, donor, idCheckComplete.Actor) }