diff --git a/docs/attorney-sign.json b/docs/attorney-sign.json index 6e34cc83..7e40a369 100644 --- a/docs/attorney-sign.json +++ b/docs/attorney-sign.json @@ -23,8 +23,8 @@ }, { "key": "/attorneys/0/email", - "new": "b@example.com", - "old": "a@example.com" + "new": "a@example.com", + "old": null } ] } diff --git a/docs/example-lpa.json b/docs/example-lpa.json index a954ae8f..4c7e4ff4 100644 --- a/docs/example-lpa.json +++ b/docs/example-lpa.json @@ -24,7 +24,6 @@ "country": "GB" }, "dateOfBirth": "1982-07-24", - "email": "a@example.com", "status": "active", "channel": "paper" } @@ -39,7 +38,6 @@ "town": "Town", "country": "GB" }, - "email": "a@example.com", "status": "active", "channel": "paper" } diff --git a/docs/openapi/openapi.yaml b/docs/openapi/openapi.yaml index 3ee16218..3ebcd503 100644 --- a/docs/openapi/openapi.yaml +++ b/docs/openapi/openapi.yaml @@ -251,9 +251,9 @@ components: items: $ref: "#/components/schemas/Lpa" Lpa: - $ref: "../schemas/2024-04/lpa.json" + $ref: "../schemas/2024-10/lpa.json" DonorDetails: - $ref: "../schemas/2024-04/donor-details.json" + $ref: "../schemas/2024-10/donor-details.json" Update: type: object required: diff --git a/docs/schemas/2024-04/donor-details.json b/docs/schemas/2024-10/donor-details.json similarity index 90% rename from docs/schemas/2024-04/donor-details.json rename to docs/schemas/2024-10/donor-details.json index 57471360..65bb4083 100644 --- a/docs/schemas/2024-04/donor-details.json +++ b/docs/schemas/2024-10/donor-details.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://data-dictionary.opg.service.justice.gov.uk/schema/lpa/2024-04/donor-details.json", + "$id": "https://data-dictionary.opg.service.justice.gov.uk/schema/lpa/2024-10/donor-details.json", "description": "The data that should be provided when an LPA is executed", "type": "object", "required": [ @@ -212,7 +212,7 @@ } ], "type": "object", - "required": ["dateOfBirth", "status"], + "required": ["dateOfBirth", "status", "channel"], "properties": { "dateOfBirth": { "type": "string", @@ -229,13 +229,26 @@ "channel": { "type": "string", "enum": ["paper", "online"] + }, + "if": { + "required": ["channel"], + "properties": { + "channel": { "const": "online" } + } + }, + "then": { + "required": ["email"] } } }, "TrustCorporation": { "type": "object", - "required": ["name", "companyNumber", "email", "address", "status"], + "required": ["name", "companyNumber", "address", "status", "channel", "uid"], "properties": { + "uid": { + "type": "string", + "format": "uuid" + }, "name": { "type": "string" }, @@ -256,6 +269,15 @@ "channel": { "type": "string", "enum": ["paper", "online"] + }, + "if": { + "required": ["channel"], + "properties": { + "channel": { "const": "online" } + } + }, + "then": { + "required": ["email"] } } }, diff --git a/docs/schemas/2024-04/lpa.json b/docs/schemas/2024-10/lpa.json similarity index 98% rename from docs/schemas/2024-04/lpa.json rename to docs/schemas/2024-10/lpa.json index 46744c46..9094ef60 100644 --- a/docs/schemas/2024-04/lpa.json +++ b/docs/schemas/2024-10/lpa.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://data-dictionary.opg.service.justice.gov.uk/schema/lpa/2024-04/lpa.json", + "$id": "https://data-dictionary.opg.service.justice.gov.uk/schema/lpa/2024-10/lpa.json", "description": "A lasting power of attorney document", "allOf": [ { diff --git a/docs/schemas/2024-04/translation.cy.json b/docs/schemas/2024-10/translation.cy.json similarity index 100% rename from docs/schemas/2024-04/translation.cy.json rename to docs/schemas/2024-10/translation.cy.json diff --git a/docs/schemas/2024-04/translation.en.json b/docs/schemas/2024-10/translation.en.json similarity index 100% rename from docs/schemas/2024-04/translation.en.json rename to docs/schemas/2024-10/translation.en.json diff --git a/docs/trust-corporation-sign.json b/docs/trust-corporation-sign.json index ace9f3ea..3ce5e582 100644 --- a/docs/trust-corporation-sign.json +++ b/docs/trust-corporation-sign.json @@ -18,8 +18,8 @@ }, { "key": "/trustCorporations/0/email", - "new": "b@example.com", - "old": "a@example.com" + "new": "a@example.com", + "old": null }, { "key": "/trustCorporations/0/signatories/0/firstNames", diff --git a/fixtures/templates/index.html b/fixtures/templates/index.html index f70142a0..ad46ea6d 100644 --- a/fixtures/templates/index.html +++ b/fixtures/templates/index.html @@ -87,7 +87,7 @@

{{ error.detail }}

required rows="10" data-module="json-schema-editor" - data-module-json-schema-editor-url="assets/schemas/2024-04/lpa.json" + data-module-json-schema-editor-url="assets/schemas/2024-10/lpa.json" > {{- json_data -}} diff --git a/internal/shared/person.go b/internal/shared/person.go index 624c588d..3a51b591 100644 --- a/internal/shared/person.go +++ b/internal/shared/person.go @@ -65,7 +65,7 @@ func (a AttorneyStatus) IsValid() bool { type Attorney struct { Person DateOfBirth Date `json:"dateOfBirth"` - Email string `json:"email"` + Email string `json:"email,omitempty"` Status AttorneyStatus `json:"status"` Mobile string `json:"mobile,omitempty"` SignedAt *time.Time `json:"signedAt,omitempty"` @@ -77,7 +77,7 @@ type TrustCorporation struct { UID string `json:"uid"` Name string `json:"name"` CompanyNumber string `json:"companyNumber"` - Email string `json:"email"` + Email string `json:"email,omitempty"` Address Address `json:"address"` Status AttorneyStatus `json:"status"` Mobile string `json:"mobile,omitempty"` diff --git a/lambda/create/main.go b/lambda/create/main.go index 2eebbe46..41463081 100644 --- a/lambda/create/main.go +++ b/lambda/create/main.go @@ -94,7 +94,7 @@ func (l *Lambda) HandleEvent(ctx context.Context, req events.APIGatewayProxyRequ return problem.Respond() } - + data := shared.Lpa{LpaInit: input} data.Uid = uid data.Status = shared.LpaStatusProcessing diff --git a/lambda/create/validate.go b/lambda/create/validate.go index 24f9ff7c..18c59ab5 100644 --- a/lambda/create/validate.go +++ b/lambda/create/validate.go @@ -100,10 +100,13 @@ func validateAttorney(prefix string, attorney shared.Attorney) []shared.FieldErr validate.UUID(fmt.Sprintf("%s/uid", prefix), attorney.UID), validate.Required(fmt.Sprintf("%s/firstNames", prefix), attorney.FirstNames), validate.Required(fmt.Sprintf("%s/lastName", prefix), attorney.LastName), - validate.Required(fmt.Sprintf("%s/status", prefix), string(attorney.Status)), validate.Date(fmt.Sprintf("%s/dateOfBirth", prefix), attorney.DateOfBirth), validate.Address(fmt.Sprintf("%s/address", prefix), attorney.Address), validate.IsValid(fmt.Sprintf("%s/status", prefix), attorney.Status), + validate.IsValid(fmt.Sprintf("%s/channel", prefix), attorney.Channel), + validate.IfElse(attorney.Channel == shared.ChannelOnline, + validate.Required(fmt.Sprintf("%s/email", prefix), attorney.Email), + validate.Empty(fmt.Sprintf("%s/email", prefix), attorney.Email)), ) } @@ -125,10 +128,10 @@ func validateTrustCorporation(prefix string, trustCorporation shared.TrustCorpor validate.Required(fmt.Sprintf("%s/name", prefix), trustCorporation.Name), validate.Required(fmt.Sprintf("%s/companyNumber", prefix), trustCorporation.CompanyNumber), validate.Address(fmt.Sprintf("%s/address", prefix), trustCorporation.Address), - validate.IsValid(fmt.Sprintf("%s/channel", prefix), trustCorporation.Channel), validate.IsValid(fmt.Sprintf("%s/status", prefix), trustCorporation.Status), - //validate.IfElse(trustCorporation.Channel == shared.ChannelOnline, - // validate.Required(fmt.Sprintf("%s/email", prefix), trustCorporation.Email), - // validate.Empty(fmt.Sprintf("%s/email", prefix), trustCorporation.Email)), + validate.IsValid(fmt.Sprintf("%s/channel", prefix), trustCorporation.Channel), + validate.IfElse(trustCorporation.Channel == shared.ChannelOnline, + validate.Required(fmt.Sprintf("%s/email", prefix), trustCorporation.Email), + validate.Empty(fmt.Sprintf("%s/email", prefix), trustCorporation.Email)), ) } diff --git a/lambda/create/validate_test.go b/lambda/create/validate_test.go index 9416ed02..f480bf55 100644 --- a/lambda/create/validate_test.go +++ b/lambda/create/validate_test.go @@ -46,6 +46,8 @@ func TestValidateAttorneyEmpty(t *testing.T) { assert.Contains(t, errors, shared.FieldError{Source: "/test/dateOfBirth", Detail: "field is required"}) assert.Contains(t, errors, shared.FieldError{Source: "/test/address/line1", Detail: "field is required"}) assert.Contains(t, errors, shared.FieldError{Source: "/test/address/country", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/channel", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/uid", Detail: "field is required"}) } func TestValidateAttorneyValid(t *testing.T) { @@ -58,6 +60,8 @@ func TestValidateAttorneyValid(t *testing.T) { }, DateOfBirth: newDate("1928-01-18"), Status: shared.AttorneyStatusActive, + Channel: shared.ChannelOnline, + Email: "a@example.com", } errors := validateAttorney("/test", attorney) @@ -67,6 +71,7 @@ func TestValidateAttorneyValid(t *testing.T) { func TestValidateAttorneyMalformedDateOfBirth(t *testing.T) { attorney := shared.Attorney{ Person: shared.Person{ + UID: "0a266ff6-1c7b-49b7-acd0-047f1dcda2ce", FirstNames: "Lesia", LastName: "Lathim", Address: validAddress, @@ -82,6 +87,7 @@ func TestValidateAttorneyMalformedDateOfBirth(t *testing.T) { func TestValidateAttorneyInvalidStatus(t *testing.T) { attorney := shared.Attorney{ Person: shared.Person{ + UID: "0a266ff6-1c7b-49b7-acd0-047f1dcda2ce", FirstNames: "Lesia", LastName: "Lathim", Address: validAddress, @@ -104,6 +110,7 @@ func TestValidateTrustCorporationEmpty(t *testing.T) { assert.Contains(t, errors, shared.FieldError{Source: "/test/address/line1", Detail: "field is required"}) assert.Contains(t, errors, shared.FieldError{Source: "/test/address/country", Detail: "field is required"}) assert.Contains(t, errors, shared.FieldError{Source: "/test/channel", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/uid", Detail: "field is required"}) } func TestValidateTrustCorporationValid(t *testing.T) { @@ -203,6 +210,33 @@ func TestValidateLpaInvalid(t *testing.T) { {Source: "/howAttorneysMakeDecisionsDetails", Detail: "field must not be provided"}, }, }, + "online attorney missing email": { + lpa: shared.LpaInit{ + Attorneys: []shared.Attorney{ + { + Channel: shared.ChannelOnline, + Status: shared.AttorneyStatusActive, + }, + }, + }, + contains: []shared.FieldError{ + {Source: "/attorneys/0/email", Detail: "field is required"}, + }, + }, + "paper attorney with email": { + lpa: shared.LpaInit{ + Attorneys: []shared.Attorney{ + { + Channel: shared.ChannelPaper, + Email: "a@example.com", + Status: shared.AttorneyStatusActive, + }, + }, + }, + contains: []shared.FieldError{ + {Source: "/attorneys/0/email", Detail: "field must not be provided"}, + }, + }, "single replacement attorney with decisions": { lpa: shared.LpaInit{ Attorneys: []shared.Attorney{{Status: shared.AttorneyStatusReplacement}}, @@ -299,31 +333,31 @@ func TestValidateLpaInvalid(t *testing.T) { {Source: "/lifeSustainingTreatmentOption", Detail: "field must not be provided"}, }, }, - //"online trust corporation missing email": { - // lpa: shared.LpaInit{ - // TrustCorporations: []shared.TrustCorporation{ - // { - // Channel: shared.ChannelOnline, - // }, - // }, - // }, - // contains: []shared.FieldError{ - // {Source: "/trustCorporations/0/email", Detail: "field is required"}, - // }, - //}, - //"paper trust corporation with email": { - // lpa: shared.LpaInit{ - // TrustCorporations: []shared.TrustCorporation{ - // { - // Channel: shared.ChannelPaper, - // Email: "a@example.com", - // }, - // }, - // }, - // contains: []shared.FieldError{ - // {Source: "/trustCorporations/0/email", Detail: "field must not be provided"}, - // }, - //}, + "online trust corporation missing email": { + lpa: shared.LpaInit{ + TrustCorporations: []shared.TrustCorporation{ + { + Channel: shared.ChannelOnline, + }, + }, + }, + contains: []shared.FieldError{ + {Source: "/trustCorporations/0/email", Detail: "field is required"}, + }, + }, + "paper trust corporation with email": { + lpa: shared.LpaInit{ + TrustCorporations: []shared.TrustCorporation{ + { + Channel: shared.ChannelPaper, + Email: "a@example.com", + }, + }, + }, + contains: []shared.FieldError{ + {Source: "/trustCorporations/0/email", Detail: "field must not be provided"}, + }, + }, } for name, tc := range testcases { @@ -360,6 +394,7 @@ func TestValidateLpaValid(t *testing.T) { DateOfBirth: newDate("1977-10-30"), Status: shared.AttorneyStatusActive, Channel: shared.ChannelOnline, + Email: "a@example.com", }, }, CertificateProvider: shared.CertificateProvider{ @@ -373,8 +408,20 @@ func TestValidateLpaValid(t *testing.T) { Email: "some@example.com", Channel: shared.ChannelOnline, }, + TrustCorporations: []shared.TrustCorporation{ + { + UID: "af2f7aa6-2f8e-4311-af2a-4855c4686d30", + Name: "corp", + CompanyNumber: "5", + Email: "corp@example.com", + Address: validAddress, + Status: shared.AttorneyStatusActive, + Channel: shared.ChannelOnline, + }, + }, LifeSustainingTreatmentOption: shared.LifeSustainingTreatmentOptionA, SignedAt: time.Now(), + HowAttorneysMakeDecisions: shared.HowMakeDecisionsJointly, } errors := Validate(lpa) diff --git a/lambda/update/trust_corporation_sign.go b/lambda/update/trust_corporation_sign.go index 9d84d1c5..e1d6689a 100644 --- a/lambda/update/trust_corporation_sign.go +++ b/lambda/update/trust_corporation_sign.go @@ -46,15 +46,18 @@ func validateTrustCorporationSign(changes []shared.Change, lpa *shared.Lpa) (Tru } data.Index = &i + data.Email = lpa.TrustCorporations[i].Email + data.Channel = lpa.TrustCorporations[i].Channel + return each. Field("/mobile", &data.Mobile). Field("/contactLanguagePreference", &data.ContactLanguagePreference, parse.Validate(func() []shared.FieldError { return validate.IsValid("", data.ContactLanguagePreference) })). - Field("/email", &data.Email, parse.Optional()). + Field("/email", &data.Email, parse.Optional(), parse.MustMatchExisting()). Field("/channel", &data.Channel, parse.Validate(func() []shared.FieldError { return validate.IsValid("", data.Channel) - }), parse.Optional()). + }), parse.Optional(), parse.MustMatchExisting()). Prefix("/signatories", func(prefix *parse.Parser) []shared.FieldError { return prefix. Each(func(i int, each *parse.Parser) []shared.FieldError { diff --git a/lambda/update/trust_corporation_sign_test.go b/lambda/update/trust_corporation_sign_test.go index c2770e3e..101135b4 100644 --- a/lambda/update/trust_corporation_sign_test.go +++ b/lambda/update/trust_corporation_sign_test.go @@ -51,110 +51,123 @@ func TestValidateUpdateTrustCorporationSign(t *testing.T) { testcases := map[string]struct { update shared.Update errors []shared.FieldError + lpa *shared.Lpa }{ "valid": { update: shared.Update{ Type: "TRUST_CORPORATION_SIGN", Changes: []shared.Change{ { - Key: "/trustCorporations/1/mobile", + Key: "/trustCorporations/0/mobile", New: json.RawMessage(`"07777"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/firstNames", + Key: "/trustCorporations/0/signatories/0/firstNames", New: json.RawMessage(`"John"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/lastName", + Key: "/trustCorporations/0/signatories/0/lastName", New: json.RawMessage(`"Smith"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/professionalTitle", + Key: "/trustCorporations/0/signatories/0/professionalTitle", New: json.RawMessage(`"Director"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/signedAt", + Key: "/trustCorporations/0/signatories/0/signedAt", New: json.RawMessage(`"` + time.Now().Format(time.RFC3339) + `"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/1/firstNames", + Key: "/trustCorporations/0/signatories/1/firstNames", New: json.RawMessage(`"Jane"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/1/lastName", + Key: "/trustCorporations/0/signatories/1/lastName", New: json.RawMessage(`"Smith"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/1/professionalTitle", + Key: "/trustCorporations/0/signatories/1/professionalTitle", New: json.RawMessage(`"Deputy Director"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/1/signedAt", + Key: "/trustCorporations/0/signatories/1/signedAt", New: json.RawMessage(`"` + time.Now().Format(time.RFC3339) + `"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/contactLanguagePreference", + Key: "/trustCorporations/0/contactLanguagePreference", New: json.RawMessage(`"cy"`), Old: jsonNull, }, }, }, + lpa: &shared.Lpa{ + LpaInit: shared.LpaInit{ + TrustCorporations: []shared.TrustCorporation{{}}, + }, + }, }, "valid - existing values": { update: shared.Update{ Type: "TRUST_CORPORATION_SIGN", Changes: []shared.Change{ { - Key: "/trustCorporations/1/mobile", + Key: "/trustCorporations/0/mobile", New: json.RawMessage(`"07777"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/firstNames", + Key: "/trustCorporations/0/signatories/0/firstNames", New: json.RawMessage(`"John"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/lastName", + Key: "/trustCorporations/0/signatories/0/lastName", New: json.RawMessage(`"Smith"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/professionalTitle", + Key: "/trustCorporations/0/signatories/0/professionalTitle", New: json.RawMessage(`"Director"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/signedAt", + Key: "/trustCorporations/0/signatories/0/signedAt", New: json.RawMessage(`"` + time.Now().Format(time.RFC3339) + `"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/contactLanguagePreference", + Key: "/trustCorporations/0/contactLanguagePreference", New: json.RawMessage(`"cy"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/email", + Key: "/trustCorporations/0/email", New: json.RawMessage(`"b@example.com"`), Old: json.RawMessage(`"a@example.com"`), }, { - Key: "/trustCorporations/1/channel", + Key: "/trustCorporations/0/channel", New: json.RawMessage(`"online"`), Old: json.RawMessage(`"paper"`), }, }, }, + lpa: &shared.Lpa{ + LpaInit: shared.LpaInit{ + TrustCorporations: []shared.TrustCorporation{ + {Email: "a@example.com", Channel: shared.ChannelPaper}, + }, + }, + }, }, "missing all": { update: shared.Update{Type: "TRUST_CORPORATION_SIGN"}, @@ -167,32 +180,32 @@ func TestValidateUpdateTrustCorporationSign(t *testing.T) { Type: "TRUST_CORPORATION_SIGN", Changes: []shared.Change{ { - Key: "/trustCorporations/1/mobile", + Key: "/trustCorporations/0/mobile", New: json.RawMessage(`"0777"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/firstNames", + Key: "/trustCorporations/0/signatories/0/firstNames", New: json.RawMessage(`"John"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/lastName", + Key: "/trustCorporations/0/signatories/0/lastName", New: json.RawMessage(`"Smith"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/professionalTitle", + Key: "/trustCorporations/0/signatories/0/professionalTitle", New: json.RawMessage(`"Director"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/signedAt", + Key: "/trustCorporations/0/signatories/0/signedAt", New: json.RawMessage(`"` + time.Now().Format(time.RFC3339) + `"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/contactLanguagePreference", + Key: "/trustCorporations/0/contactLanguagePreference", New: json.RawMessage(`"` + shared.LangCy + `"`), Old: jsonNull, }, @@ -202,7 +215,7 @@ func TestValidateUpdateTrustCorporationSign(t *testing.T) { Old: jsonNull, }, { - Key: "/trustCorporations/1/firstNames", + Key: "/trustCorporations/0/firstNames", New: json.RawMessage(`"John"`), Old: jsonNull, }, @@ -212,45 +225,50 @@ func TestValidateUpdateTrustCorporationSign(t *testing.T) { {Source: "/changes/6", Detail: "unexpected change provided"}, {Source: "/changes/7", Detail: "unexpected change provided"}, }, + lpa: &shared.Lpa{ + LpaInit: shared.LpaInit{ + TrustCorporations: []shared.TrustCorporation{{}}, + }, + }, }, "invalid values": { update: shared.Update{ Type: "TRUST_CORPORATION_SIGN", Changes: []shared.Change{ { - Key: "/trustCorporations/1/mobile", + Key: "/trustCorporations/0/mobile", New: json.RawMessage(`"07777"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/firstNames", + Key: "/trustCorporations/0/signatories/0/firstNames", New: json.RawMessage(`"John"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/lastName", + Key: "/trustCorporations/0/signatories/0/lastName", New: json.RawMessage(`"Smith"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/professionalTitle", + Key: "/trustCorporations/0/signatories/0/professionalTitle", New: json.RawMessage(`"Director"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/signatories/0/signedAt", + Key: "/trustCorporations/0/signatories/0/signedAt", New: json.RawMessage(`"` + time.Now().Format(time.RFC3339) + `"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/contactLanguagePreference", + Key: "/trustCorporations/0/contactLanguagePreference", New: json.RawMessage(`"xy"`), Old: jsonNull, }, { - Key: "/trustCorporations/1/channel", + Key: "/trustCorporations/0/channel", New: json.RawMessage(`"digital"`), - Old: json.RawMessage(`"paper"`), + Old: jsonNull, }, }, }, @@ -258,6 +276,11 @@ func TestValidateUpdateTrustCorporationSign(t *testing.T) { {Source: "/changes/5/new", Detail: "invalid value"}, {Source: "/changes/6/new", Detail: "invalid value"}, }, + lpa: &shared.Lpa{ + LpaInit: shared.LpaInit{ + TrustCorporations: []shared.TrustCorporation{{}}, + }, + }, }, "multiple trust corporations": { update: shared.Update{ @@ -299,12 +322,17 @@ func TestValidateUpdateTrustCorporationSign(t *testing.T) { {Source: "/changes/1/key", Detail: "index out of range"}, {Source: "/changes", Detail: "missing /trustCorporations/0/signatories/0/firstNames"}, }, + lpa: &shared.Lpa{ + LpaInit: shared.LpaInit{ + TrustCorporations: []shared.TrustCorporation{{}, {}}, + }, + }, }, } for name, tc := range testcases { t.Run(name, func(t *testing.T) { - _, errors := validateUpdate(tc.update, &shared.Lpa{}) + _, errors := validateUpdate(tc.update, tc.lpa) assert.ElementsMatch(t, tc.errors, errors) }) } diff --git a/mock-apigw/main.go b/mock-apigw/main.go index e9c567c4..9e9551f2 100644 --- a/mock-apigw/main.go +++ b/mock-apigw/main.go @@ -165,7 +165,6 @@ func handlePactState(r *http.Request) error { "town": "Town", "country": "GB" }, - "email": "a@example.com", "status": "active", "channel": "paper" }