From 23f9dc9f8d3ca32c983b5d8cfb891030f409c063 Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Thu, 13 Jun 2024 10:23:53 +0100 Subject: [PATCH] Rename ID_CHECK_COMPLETE to _CONFIRM_IDENTITY --- docs/openapi/openapi.yaml | 3 ++- .../{id_check_complete.go => confirm_identity.go} | 13 ++++++++++--- ...ck_complete_test.go => confirm_identity_test.go} | 12 ++++++------ lambda/update/validate.go | 6 ++++-- 4 files changed, 22 insertions(+), 12 deletions(-) rename lambda/update/{id_check_complete.go => confirm_identity.go} (76%) rename lambda/update/{id_check_complete_test.go => confirm_identity_test.go} (84%) diff --git a/docs/openapi/openapi.yaml b/docs/openapi/openapi.yaml index 182ab6bd..c08dda43 100644 --- a/docs/openapi/openapi.yaml +++ b/docs/openapi/openapi.yaml @@ -268,7 +268,8 @@ components: - PERFECT - REGISTER - CERTIFICATE_PROVIDER_OPT_OUT - - ID_CHECK_COMPLETE + - DONOR_CONFIRM_IDENTITY + - CERTIFICATE_PROVIDER_CONFIRM_IDENTITY changes: type: array items: diff --git a/lambda/update/id_check_complete.go b/lambda/update/confirm_identity.go similarity index 76% rename from lambda/update/id_check_complete.go rename to lambda/update/confirm_identity.go index 03ea4925..1c202a28 100644 --- a/lambda/update/id_check_complete.go +++ b/lambda/update/confirm_identity.go @@ -27,7 +27,7 @@ func (idcc IdCheckComplete) Apply(lpa *shared.Lpa) []shared.FieldError { return nil } -func validateIdCheckComplete(changes []shared.Change, lpa *shared.Lpa) (IdCheckComplete, []shared.FieldError) { +func validateConfirmIdentity(prefix string, actor idccActor, changes []shared.Change, lpa *shared.Lpa) (IdCheckComplete, []shared.FieldError) { var existing IdCheckComplete identityCheckParser := func(actor idccActor) func(p *parse.Parser) []shared.FieldError { @@ -64,8 +64,7 @@ func validateIdCheckComplete(changes []shared.Change, lpa *shared.Lpa) (IdCheckC } errors := parse.Changes(changes). - Prefix("/donor/identityCheck", identityCheckParser(donor), parse.Optional()). - Prefix("/certificateProvider/identityCheck", identityCheckParser(certificateProvider), parse.Optional()). + Prefix(prefix, identityCheckParser(actor)). Errors() if existing.Actor == "" { @@ -74,3 +73,11 @@ func validateIdCheckComplete(changes []shared.Change, lpa *shared.Lpa) (IdCheckC return existing, errors } + +func validateDonorConfirmIdentity(changes []shared.Change, lpa *shared.Lpa) (IdCheckComplete, []shared.FieldError) { + return validateConfirmIdentity("/donor/identityCheck", donor, changes, lpa) +} + +func validateCertificateProviderConfirmIdentity(changes []shared.Change, lpa *shared.Lpa) (IdCheckComplete, []shared.FieldError) { + return validateConfirmIdentity("/certificateProvider/identityCheck", certificateProvider, changes, lpa) +} diff --git a/lambda/update/id_check_complete_test.go b/lambda/update/confirm_identity_test.go similarity index 84% rename from lambda/update/id_check_complete_test.go rename to lambda/update/confirm_identity_test.go index 8ca86961..e28b98ea 100644 --- a/lambda/update/id_check_complete_test.go +++ b/lambda/update/confirm_identity_test.go @@ -9,7 +9,7 @@ import ( "github.com/ministryofjustice/opg-data-lpa-store/internal/shared" ) -func TestIdCheckCompleteValidateDonor(t *testing.T) { +func TestConfirmIdentityDonor(t *testing.T) { today := time.Now() changes := []shared.Change{ @@ -30,7 +30,7 @@ func TestIdCheckCompleteValidateDonor(t *testing.T) { }, } - idCheckComplete, errors := validateIdCheckComplete(changes, &shared.Lpa{}) + idCheckComplete, errors := validateDonorConfirmIdentity(changes, &shared.Lpa{}) assert.Len(t, errors, 0) assert.Equal(t, "xyz", idCheckComplete.Reference) @@ -39,7 +39,7 @@ func TestIdCheckCompleteValidateDonor(t *testing.T) { assert.Equal(t, donor, idCheckComplete.Actor) } -func TestIdCheckCompleteValidateCertificateProvider(t *testing.T) { +func TestConfirmIdentityCertificateProvider(t *testing.T) { today := time.Now() changes := []shared.Change{ @@ -60,7 +60,7 @@ func TestIdCheckCompleteValidateCertificateProvider(t *testing.T) { }, } - idCheckComplete, errors := validateIdCheckComplete(changes, &shared.Lpa{}) + idCheckComplete, errors := validateCertificateProviderConfirmIdentity(changes, &shared.Lpa{}) assert.Len(t, errors, 0) assert.Equal(t, "abn", idCheckComplete.Reference) @@ -69,7 +69,7 @@ func TestIdCheckCompleteValidateCertificateProvider(t *testing.T) { assert.Equal(t, certificateProvider, idCheckComplete.Actor) } -func TestIdCheckCompleteApplyDonor(t *testing.T) { +func TestConfirmIdentityApplyDonor(t *testing.T) { check := IdCheckComplete{ Actor: donor, IdentityCheck: &shared.IdentityCheck{}, @@ -82,7 +82,7 @@ func TestIdCheckCompleteApplyDonor(t *testing.T) { assert.Equal(t, check.IdentityCheck, lpa.Donor.IdentityCheck) } -func TestIdCheckCompleteApplyCertificateProvider(t *testing.T) { +func TestConfirmIdentityApplyCertificateProvider(t *testing.T) { check := IdCheckComplete{ Actor: certificateProvider, IdentityCheck: &shared.IdentityCheck{}, diff --git a/lambda/update/validate.go b/lambda/update/validate.go index d7fca458..c3e436c8 100644 --- a/lambda/update/validate.go +++ b/lambda/update/validate.go @@ -22,8 +22,10 @@ func validateUpdate(update shared.Update, lpa *shared.Lpa) (Applyable, []shared. return validateRegister(update.Changes) case "TRUST_CORPORATION_SIGN": return validateTrustCorporationSign(update.Changes, lpa) - case "ID_CHECK_COMPLETE": - return validateIdCheckComplete(update.Changes, lpa) + case "DONOR_CONFIRM_IDENTITY": + return validateDonorConfirmIdentity(update.Changes, lpa) + case "CERTIFICATE_PROVIDER_CONFIRM_IDENTITY": + return validateCertificateProviderConfirmIdentity(update.Changes, lpa) default: return nil, []shared.FieldError{{Source: "/type", Detail: "invalid value"}} }