Skip to content

Commit

Permalink
Rename ID_CHECK_COMPLETE to <actor>_CONFIRM_IDENTITY
Browse files Browse the repository at this point in the history
  • Loading branch information
townxelliot committed Jun 13, 2024
1 parent fa1bc95 commit 23f9dc9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion docs/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 == "" {
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
Expand All @@ -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{
Expand All @@ -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)
Expand All @@ -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{},
Expand All @@ -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{},
Expand Down
6 changes: 4 additions & 2 deletions lambda/update/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}
}
Expand Down

0 comments on commit 23f9dc9

Please sign in to comment.