From ea856e3febe15f50ce55878e48046a4da56e2b43 Mon Sep 17 00:00:00 2001 From: Greg Tyler Date: Fri, 17 Nov 2023 09:53:53 +0000 Subject: [PATCH 1/6] Build more LPA Schema - Add basic donor and attorney details to the LPA schema - Add an example LPA - Update tests to use new LPAs - Update handlers to handle and validate new LPA structure For VEGA-2134 #major --- .redocly.lint-ignore.yaml | 2 +- Makefile | 4 +- docs/example-lpa.json | 42 +++++++++++++++ docs/openapi/initial-lpa.yaml | 99 +++++++++++++++++++++++++++++++++++ docs/openapi/lpa.yaml | 26 +++++++++ docs/openapi/openapi.yaml | 19 ++++--- docs/schemas/lpa.json | 14 ----- lambda/create/main.go | 35 +++++++------ lambda/create/time.go | 19 +++++++ lambda/create/validate.go | 88 +++++++++++++++++++++++++++++++ lambda/shared/lpa.go | 20 +++++-- lambda/shared/person.go | 40 ++++++++++++++ lambda/shared/time.go | 25 +++++++++ lambda/update/main.go | 30 +++++++---- 14 files changed, 408 insertions(+), 55 deletions(-) create mode 100644 docs/example-lpa.json create mode 100644 docs/openapi/initial-lpa.yaml create mode 100644 docs/openapi/lpa.yaml delete mode 100644 docs/schemas/lpa.json create mode 100644 lambda/create/time.go create mode 100644 lambda/create/validate.go create mode 100644 lambda/shared/person.go create mode 100644 lambda/shared/time.go diff --git a/.redocly.lint-ignore.yaml b/.redocly.lint-ignore.yaml index 97bf2dae..3bd2ea73 100644 --- a/.redocly.lint-ignore.yaml +++ b/.redocly.lint-ignore.yaml @@ -1,6 +1,6 @@ # This file instructs Redocly's linter to ignore the rules contained for specific parts of your API. # See https://redoc.ly/docs/cli/ for more information. -docs/schemas/lpa.json: +docs/schemas/lpa.yaml: spec: - '#/$id' - '#/$schema' diff --git a/Makefile b/Makefile index daffe91e..c4d9dd07 100644 --- a/Makefile +++ b/Makefile @@ -24,9 +24,9 @@ test-api: ./api-test/tester -expectedStatus=401 REQUEST PUT $(URL)/lpas/$(LPA_UID) '{"version":"1"}' && \ ./api-test/tester -expectedStatus=401 REQUEST POST $(URL)/lpas/$(LPA_UID)/updates '{"type":"BUMP_VERSION","changes":[{"key":"/version","old":"1","new":"2"}]}' && \ ./api-test/tester -expectedStatus=401 REQUEST GET $(URL)/lpas/$(LPA_UID) '' && \ - ./api-test/tester -jwtSecret=$(JWT_SECRET_KEY) -expectedStatus=201 REQUEST PUT $(URL)/lpas/$(LPA_UID) '{"version":"1"}' && \ + cat ./docs/example-lpa.json | ./api-test/tester -jwtSecret=$(JWT_SECRET_KEY) -expectedStatus=201 REQUEST PUT $(URL)/lpas/$(LPA_UID) "`xargs -0`" && \ ./api-test/tester -jwtSecret=$(JWT_SECRET_KEY) -expectedStatus=400 REQUEST PUT $(URL)/lpas/$(LPA_UID) '{"version":"2"}' && \ - ./api-test/tester -jwtSecret=$(JWT_SECRET_KEY) -expectedStatus=201 REQUEST POST $(URL)/lpas/$(LPA_UID)/updates '{"type":"BUMP_VERSION","changes":[{"key":"/version","old":"1","new":"2"}]}' && \ + ./api-test/tester -jwtSecret=$(JWT_SECRET_KEY) -expectedStatus=201 REQUEST POST $(URL)/lpas/$(LPA_UID)/updates '{"type":"CHANGE_NAME","changes":[{"key":"/donor/surname","old":"Zoller","new":"Kjar"}]}' && \ ./api-test/tester -jwtSecret=$(JWT_SECRET_KEY) -expectedStatus=200 REQUEST GET $(URL)/lpas/$(LPA_UID) '' .PHONY: test-api diff --git a/docs/example-lpa.json b/docs/example-lpa.json new file mode 100644 index 00000000..3a8cbb76 --- /dev/null +++ b/docs/example-lpa.json @@ -0,0 +1,42 @@ +{ + "donor": { + "firstNames": "Homer", + "surname": "Zoller", + "dateOfBirth": "1960-04-06", + "email": "h.zoller@example.com", + "address": { + "line1": "79 Bury Rd", + "town": "Hampton Lovett", + "postcode": "WR9 2PF", + "country": "GB" + } + }, + "attorneys": [ + { + "firstNames": "Jake", + "surname": "Mulato", + "dateOfBirth": "2001-01-17", + "email": "jmul5@example.com", + "status": "active", + "address": { + "line1": "71 South Western Terrace", + "town": "Milton", + "postcode": "FK17 4FE", + "country": "GB" + } + }, + { + "firstNames": "Tory", + "surname": "Lapolla", + "dateOfBirth": "1989-12-29", + "status": "replacement", + "address": { + "line1": "184 Bayside Apartments", + "line2": "East Street", + "line3": "Saratosa", + "town": "Polebrook", + "country": "US" + } + } + ] +} diff --git a/docs/openapi/initial-lpa.yaml b/docs/openapi/initial-lpa.yaml new file mode 100644 index 00000000..12c9f8f8 --- /dev/null +++ b/docs/openapi/initial-lpa.yaml @@ -0,0 +1,99 @@ +$id: https://opg.service.justice.gov.uk/schema/lpa/2023-10 +$schema: http://json-schema.org/draft/2020-02/schema +title: Initial LPA +description: Digital representation of a Lasting Power of Attorney +type: object +required: + - donor + - attorneys +properties: + donor: + $ref: "#/$defs/Donor" + attorneys: + type: array + items: + $ref: "#/$defs/Attorney" + minLength: 1 +additionalProperties: false +$defs: + InitialLpa: + + Person: + type: object + required: + - firstNames + - surname + - dateOfBirth + - address + properties: + firstNames: + type: string + x-faker: name.firstName + surname: + type: string + x-faker: name.lastName + dateOfBirth: + type: string + format: date + email: + type: string + x-faker: internet.email + address: + $ref: "#/$defs/Address" + Address: + type: object + required: + - line1 + - town + - country + properties: + line1: + type: string + x-faker: address.streetAddress + line2: + type: string + x-faker: address.streetName + line3: + type: string + x-faker: address.cityName + town: + type: string + x-faker: address.cityName + postcode: + type: string + x-faker: + helpers.replaceSymbols: "??# #??" + country: + type: string + format: ISO-3166-1 + minLength: 2 + maxLength: 2 + x-faker: address.countryCode + additionalProperties: false + example: + line1: Flat 3 + line2: 42 Primrose Lane + line3: Greenfields + town: Manchester + postcode: M17 2XY + country: GB + Donor: + allOf: + - $ref: "#/$defs/Person" + type: object + properties: + otherNames: + type: string + nullable: true + x-faker: name.findName + Attorney: + allOf: + - $ref: "#/$defs/Person" + type: object + properties: + status: + type: string + enum: + - active + - replacement + - removed diff --git a/docs/openapi/lpa.yaml b/docs/openapi/lpa.yaml new file mode 100644 index 00000000..8fc4515b --- /dev/null +++ b/docs/openapi/lpa.yaml @@ -0,0 +1,26 @@ +$id: https://opg.service.justice.gov.uk/schema/lpa/2023-10 +$schema: http://json-schema.org/draft/2020-02/schema +title: LPA +description: Digital representation of a Lasting Power of Attorney +allOf: + - $ref: "./initial-lpa.yaml" +type: object +required: + - uid + - status + - registrationDate +properties: + uid: + type: string + pattern: M-([A-Z0-9]{4})-([A-Z0-9]{4})-([A-Z0-9]{4}) + example: M-789Q-P4DF-4UX3 + status: + type: string + enum: + - processing + - registered + registrationDate: + type: string + format: date + nullable: true +additionalProperties: false diff --git a/docs/openapi/openapi.yaml b/docs/openapi/openapi.yaml index 665173ad..80ff0966 100644 --- a/docs/openapi/openapi.yaml +++ b/docs/openapi/openapi.yaml @@ -14,13 +14,16 @@ servers: description: Development security: - {} +x-json-schema-faker: + alwaysFakeOptionals: false + optionalsProbability: 0.5 paths: /lpas/{uid}: parameters: - name: uid in: path required: true - description: The UID of the complaint + description: The UID of the case schema: type: string pattern: "M-([A-Z0-9]{4})-([A-Z0-9]{4})-([A-Z0-9]{4})" @@ -32,7 +35,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Lpa" + $ref: "#/components/schemas/InitialLpa" responses: "201": description: Case created @@ -52,12 +55,6 @@ paths: get: operationId: getLpa summary: Retrieve an LPA - requestBody: - content: - application/json: - schema: - type: object - additionalProperties: false responses: "200": description: Case found @@ -83,7 +80,7 @@ paths: - name: uid in: path required: true - description: The UID of the complaint + description: The UID of the case schema: type: string pattern: "M-([A-Z0-9]{4})-([A-Z0-9]{4})-([A-Z0-9]{4})" @@ -193,7 +190,9 @@ components: - source: "/uid" detail: "invalid uid format" Lpa: - $ref: "../schemas/lpa.json" + $ref: "./lpa.yaml" + InitialLpa: + $ref: "./initial-lpa.yaml" Update: type: object required: diff --git a/docs/schemas/lpa.json b/docs/schemas/lpa.json deleted file mode 100644 index c1d946b4..00000000 --- a/docs/schemas/lpa.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$id": "https://opg.service.justice.gov.uk/schema/lpa/2023-10", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "LPA", - "description": "Digital representation of a Lasting Power of Attorney", - "type": "object", - "properties": { - "uid": { - "type": "string", - "pattern": "M-([A-Z0-9]{4})-([A-Z0-9]{4})-([A-Z0-9]{4})", - "example": "M-789Q-P4DF-4UX3" - } - } -} diff --git a/lambda/create/main.go b/lambda/create/main.go index ae0c8057..25a2e360 100644 --- a/lambda/create/main.go +++ b/lambda/create/main.go @@ -33,41 +33,44 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe l.logger.Print("Successfully parsed JWT from event header") + var input shared.LpaInit + uid := event.PathParameters["uid"] + response := events.APIGatewayProxyResponse{ StatusCode: 500, Body: "{\"code\":\"INTERNAL_SERVER_ERROR\",\"detail\":\"Internal server error\"}", } - var data shared.Lpa - err := json.Unmarshal([]byte(event.Body), &data) + // check for existing Lpa + var existingLpa shared.Lpa + existingLpa, err := l.store.Get(ctx, uid) if err != nil { - l.logger.Print(err) return shared.ProblemInternalServerError.Respond() } - - data.Uid = event.PathParameters["uid"] - - if data.Version == "" { + if existingLpa.Uid == uid { problem := shared.ProblemInvalidRequest - problem.Errors = []shared.FieldError{ - {Source: "/version", Detail: "must supply a valid version"}, - } - + problem.Detail = "LPA with UID already exists" return problem.Respond() } - // check for existing Lpa - var existingLpa shared.Lpa - existingLpa, err = l.store.Get(ctx, data.Uid) + err = json.Unmarshal([]byte(event.Body), &input) if err != nil { + l.logger.Print(err) return shared.ProblemInternalServerError.Respond() } - if existingLpa.Uid == data.Uid { + + // validation + errors := Validate(input) + if len(errors) > 0 { problem := shared.ProblemInvalidRequest - problem.Detail = "LPA with UID already exists" + problem.Errors = errors + return problem.Respond() } + data := shared.Lpa{LpaInit: input} + data.Uid = uid + data.Status = shared.LpaStatusProcessing data.UpdatedAt = time.Now() // save diff --git a/lambda/create/time.go b/lambda/create/time.go new file mode 100644 index 00000000..978b9432 --- /dev/null +++ b/lambda/create/time.go @@ -0,0 +1,19 @@ +package main + +import "time" + +type Time struct { + time.Time + Err error +} + +func (m *Time) UnmarshalJSON(data []byte) error { + err := m.Time.UnmarshalJSON(data) + + *m = Time{ + Time: m.Time, + Err: err, + } + + return nil +} diff --git a/lambda/create/validate.go b/lambda/create/validate.go new file mode 100644 index 00000000..84972ab7 --- /dev/null +++ b/lambda/create/validate.go @@ -0,0 +1,88 @@ +package main + +import ( + "fmt" + "regexp" + + "github.com/ministryofjustice/opg-data-lpa-store/lambda/shared" +) + +func validateAddress(address shared.Address, prefix string, errors []shared.FieldError) []shared.FieldError { + requiredFields := map[string]string{ + fmt.Sprintf("%s/line1", prefix): address.Line1, + fmt.Sprintf("%s/town", prefix): address.Town, + fmt.Sprintf("%s/country", prefix): address.Country, + } + + for source, value := range requiredFields { + if value == "" { + errors = append(errors, shared.FieldError{Source: source, Detail: "field is required"}) + } + } + + if ok, _ := regexp.MatchString("^[A-Z]{2}$", address.Country); !ok { + errors = append(errors, shared.FieldError{Source: fmt.Sprintf("%s/country", prefix), Detail: "must be a valid ISO-3166-1 country code"}) + } + + return errors +} + +func validateAttorney(attorney shared.Attorney, prefix string, errors []shared.FieldError) []shared.FieldError { + requiredFields := map[string]string{ + fmt.Sprintf("%s/firstNames", prefix): attorney.FirstNames, + fmt.Sprintf("%s/surname", prefix): attorney.Surname, + fmt.Sprintf("%s/status", prefix): string(attorney.Status), + } + + for source, value := range requiredFields { + if value == "" { + errors = append(errors, shared.FieldError{Source: source, Detail: "field is required"}) + } + } + + if attorney.DateOfBirth.IsZero() { + errors = append(errors, shared.FieldError{Source: fmt.Sprintf("%s/dateOfBirth", prefix), Detail: "field is required"}) + } + + if !attorney.Status.IsValid() { + errors = append(errors, shared.FieldError{Source: fmt.Sprintf("%s/status", prefix), Detail: "invalid value"}) + } + + errors = validateAddress(attorney.Address, fmt.Sprintf("%s/address", prefix), errors) + + return errors +} + +func Validate(lpa shared.LpaInit) []shared.FieldError { + errors := []shared.FieldError{} + + requiredFields := map[string]string{ + "/donor/firstNames": lpa.Donor.FirstNames, + "/donor/surname": lpa.Donor.Surname, + } + + for source, value := range requiredFields { + if value == "" { + errors = append(errors, shared.FieldError{Source: source, Detail: "field is required"}) + } + } + + if lpa.Donor.DateOfBirth.IsMalformed { + errors = append(errors, shared.FieldError{Source: "/donor/dateOfBirth", Detail: "invalid format"}) + } else if lpa.Donor.DateOfBirth.IsZero() { + errors = append(errors, shared.FieldError{Source: "/donor/dateOfBirth", Detail: "field is required"}) + } + + errors = validateAddress(lpa.Donor.Address, "/donor/address", errors) + + if len(lpa.Attorneys) == 0 { + errors = append(errors, shared.FieldError{Source: "/attorneys", Detail: "at least one attorney is required"}) + } + + for index, attorney := range lpa.Attorneys { + prefix := fmt.Sprintf("/attorneys/%d", index) + errors = validateAttorney(attorney, prefix, errors) + } + + return errors +} diff --git a/lambda/shared/lpa.go b/lambda/shared/lpa.go index 1bfc3852..4ba0b87e 100644 --- a/lambda/shared/lpa.go +++ b/lambda/shared/lpa.go @@ -2,8 +2,22 @@ package shared import "time" +type LpaInit struct { + Donor Donor `json:"donor" dynamodbav:""` + Attorneys []Attorney `json:"attorneys" dynamodbav:""` +} + type Lpa struct { - Uid string `json:"uid" dynamodbav:"uid"` - Version string `json:"version" dynamodbav:"version"` - UpdatedAt time.Time `json:"-" dynamodbav:"updatedAt"` + LpaInit + Uid string `json:"uid" dynamodbav:""` + Status LpaStatus `json:"status" dynamodbav:""` + RegistrationDate time.Time `json:"registrationDate" dynamodbav:""` + UpdatedAt time.Time `json:"updatedAt" dynamodbav:""` } + +type LpaStatus string + +const ( + LpaStatusProcessing = LpaStatus("processing") + LpaStatusRegistered = LpaStatus("registered") +) diff --git a/lambda/shared/person.go b/lambda/shared/person.go new file mode 100644 index 00000000..638c2bd7 --- /dev/null +++ b/lambda/shared/person.go @@ -0,0 +1,40 @@ +package shared + +type Address struct { + Line1 string `json:"line1" dynamodbav:""` + Line2 string `json:"line2" dynamodbav:""` + Line3 string `json:"line3" dynamodbav:""` + Town string `json:"town" dynamodbav:""` + Postcode string `json:"postcode" dynamodbav:""` + Country string `json:"country" dynamodbav:""` +} + +type Person struct { + FirstNames string `json:"firstNames" dynamodbav:""` + Surname string `json:"surname" dynamodbav:""` + DateOfBirth Time `json:"dateOfBirth" dynamodbav:""` + Email string `json:"email" dynamodbav:""` + Address Address `json:"address" dynamodbav:""` +} + +type Donor struct { + Person + OtherNames string `json:"otherNames" dynamodbav:""` +} + +type AttorneyStatus string + +const ( + AttorneyStatusActive = AttorneyStatus("active") + AttorneyStatusReplacement = AttorneyStatus("replacement") + AttorneyStatusRemoved = AttorneyStatus("removed") +) + +func (a AttorneyStatus) IsValid() bool { + return a == AttorneyStatusActive || a == AttorneyStatusReplacement || a == AttorneyStatusRemoved +} + +type Attorney struct { + Person + Status AttorneyStatus `json:"status" dynamodbav:""` +} diff --git a/lambda/shared/time.go b/lambda/shared/time.go new file mode 100644 index 00000000..7e4bab1d --- /dev/null +++ b/lambda/shared/time.go @@ -0,0 +1,25 @@ +package shared + +import ( + "regexp" + "time" +) + +type Time struct { + time.Time + IsMalformed bool +} + +func (m *Time) UnmarshalJSON(data []byte) error { + time, err := time.Parse(`"2006-01-02"`, string(data)) + + m.Time = time + + if err != nil { + if ok, _ := regexp.MatchString("cannot parse \".+\" as \"\\\"2006-01-02\\\"\"$", err.Error()); ok { + m.IsMalformed = true + } + } + + return nil +} diff --git a/lambda/update/main.go b/lambda/update/main.go index a2e935be..9b57d9f4 100644 --- a/lambda/update/main.go +++ b/lambda/update/main.go @@ -49,12 +49,20 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe return shared.ProblemInternalServerError.Respond() } - err = applyUpdate(&lpa, update) + validationErrs, err := applyUpdate(&lpa, update) + if err != nil { l.logger.Print(err) return shared.ProblemInternalServerError.Respond() } + if len(validationErrs) > 0 { + problem := shared.ProblemInvalidRequest + problem.Errors = validationErrs + + return problem.Respond() + } + err = l.store.Put(ctx, lpa) if err != nil { l.logger.Print(err) @@ -74,30 +82,34 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe return response, nil } -func applyUpdate(lpa *shared.Lpa, update shared.Update) error { - for _, change := range update.Changes { +func applyUpdate(lpa *shared.Lpa, update shared.Update) ([]shared.FieldError, error) { + validationErrs := []shared.FieldError{} + + for index, change := range update.Changes { pointer, err := jsonpointer.New(change.Key) if err != nil { - return err + return validationErrs, err } current, _, err := pointer.Get(*lpa) if err != nil { - return err + return validationErrs, err } if current != change.Old { - err = fmt.Errorf("existing value for %s does not match request", change.Key) - return err + validationErrs = append(validationErrs, shared.FieldError{ + Source: fmt.Sprintf("/changes/%d/old", index), + Detail: "does not match existing value", + }) } _, err = pointer.Set(lpa, change.New) if err != nil { - return err + return validationErrs, err } } - return nil + return validationErrs, nil } func main() { From cd8b9a11f08f8b05a0503384765d2e80030a033d Mon Sep 17 00:00:00 2001 From: Greg Tyler Date: Fri, 17 Nov 2023 17:14:02 +0000 Subject: [PATCH 2/6] Add tests for validation and date Also update dependency files #patch --- .gitignore | 1 + Makefile | 5 +- api-test/go.mod | 1 + api-test/go.sum | 55 +------------ go.work | 2 +- go.work.sum | 5 +- lambda/create/go.mod | 8 +- lambda/create/go.sum | 42 +++------- lambda/create/time.go | 19 ----- lambda/create/validate.go | 4 +- lambda/create/validate_test.go | 142 +++++++++++++++++++++++++++++++++ lambda/get/go.mod | 3 +- lambda/get/go.sum | 33 +------- lambda/shared/date.go | 23 ++++++ lambda/shared/date_test.go | 51 ++++++++++++ lambda/shared/go.mod | 8 +- lambda/shared/go.sum | 67 ++++------------ lambda/shared/person.go | 2 +- lambda/shared/time.go | 25 ------ lambda/update/go.mod | 4 +- lambda/update/go.sum | 34 +------- 21 files changed, 276 insertions(+), 258 deletions(-) delete mode 100644 lambda/create/time.go create mode 100644 lambda/create/validate_test.go create mode 100644 lambda/shared/date.go create mode 100644 lambda/shared/date_test.go delete mode 100644 lambda/shared/time.go diff --git a/.gitignore b/.gitignore index 829dab8f..f5bac49c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ venv/ env/ # built items api-test/tester +**/coverage.out # structurizr .structurizr docs/architecture/dsl/**/workspace.json diff --git a/Makefile b/Makefile index c4d9dd07..7ec7e9ba 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,9 @@ up: ## Start application down: ## Stop application docker compose down +test: ## Unit tests + go test ./lambda/get/... ./lambda/create/... ./lambda/update/... ./lambda/shared/... -race -covermode=atomic -coverprofile=coverage.out + test-api: URL ?= http://localhost:9000 test-api: $(shell go build -o ./api-test/tester ./api-test && chmod +x ./api-test/tester) @@ -60,4 +63,4 @@ go-lint: ## Lint Go code gosec: ## Scan Go code for security flaws docker compose run --rm gosec -check-code: go-lint gosec +check-code: go-lint gosec test diff --git a/api-test/go.mod b/api-test/go.mod index 782e4fb0..1000d4d8 100644 --- a/api-test/go.mod +++ b/api-test/go.mod @@ -4,6 +4,7 @@ go 1.20 require ( github.com/aws/aws-sdk-go v1.47.9 + github.com/golang-jwt/jwt/v5 v5.1.0 github.com/google/uuid v1.4.0 ) diff --git a/api-test/go.sum b/api-test/go.sum index b4c6f044..cefdeacf 100644 --- a/api-test/go.sum +++ b/api-test/go.sum @@ -1,71 +1,18 @@ -github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= -github.com/aws/aws-sdk-go v1.46.1/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.5 h1:NYYUrhOftwiXPkqZwEpB3043bMukegJAt15ozrqJbEY= -github.com/aws/aws-sdk-go v1.46.5/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.6 h1:6wFnNC9hETIZLMf6SOTN7IcclrOGwp/n9SLp8Pjt6E8= -github.com/aws/aws-sdk-go v1.46.6/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.7 h1:IjvAWeiJZlbETOemOwvheN5L17CvKvKW0T1xOC6d3Sc= -github.com/aws/aws-sdk-go v1.46.7/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.47.0 h1:/JUg9V1+xh+qBn8A6ec/l15ETPaMaBqxkjz+gg63dNk= -github.com/aws/aws-sdk-go v1.47.0/go.mod h1:DlEaEbWKZmsITVbqlSVvekPARM1HzeV9PMYg15ymSDA= -github.com/aws/aws-sdk-go v1.47.1 h1:j9ih0Ashcw8tQcnfqNimBM8ARQ/CMpoBwjKue1D6Fuk= -github.com/aws/aws-sdk-go v1.47.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.2 h1:KEdO2PbjfEBmHvnEwbYEpr65ZIkmwK5aB85Gj19ASuA= -github.com/aws/aws-sdk-go v1.47.2/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.3 h1:e0H6NFXiniCpR8Lu3lTphVdRaeRCDLAeRyTHd1tJSd8= -github.com/aws/aws-sdk-go v1.47.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.4 h1:IyhNbmPt+5ldi5HNzv7ZnXiqSglDMaJiZlzj4Yq3qnk= -github.com/aws/aws-sdk-go v1.47.4/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.5 h1:U2JlfPmrUoz5p+2X/XwKxmaJFo2oV+LbJqx8jyEvyAY= -github.com/aws/aws-sdk-go v1.47.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.6 h1:WMnLApoJAKC+KBt8f53QccGBZghLRoVfAcOo52jUtY0= -github.com/aws/aws-sdk-go v1.47.6/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.7 h1:Y1J7g48WAzO4dYGQELbWJ57rASV8G7rd4u9hDB+AevU= -github.com/aws/aws-sdk-go v1.47.7/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.8 h1:VCFyO5UTREnhR0HRf9roqFfJeeRVin58zUy+pBMhwjY= -github.com/aws/aws-sdk-go v1.47.8/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go v1.47.9 h1:rarTsos0mA16q+huicGx0e560aYRtOucV5z2Mw23JRY= github.com/aws/aws-sdk-go v1.47.9/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang-jwt/jwt/v5 v5.1.0 h1:UGKbA/IPjtS6zLcdB7i5TyACMgSbOTiR8qzXgw8HWQU= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/go.work b/go.work index 24253d1b..d5d7396a 100644 --- a/go.work +++ b/go.work @@ -1,10 +1,10 @@ go 1.20 use ( + ./api-test ./lambda/create ./lambda/get ./lambda/shared ./lambda/update ./mock-apigw - ./api-test ) diff --git a/go.work.sum b/go.work.sum index a52e5ec6..028e5532 100644 --- a/go.work.sum +++ b/go.work.sum @@ -3,8 +3,8 @@ github.com/aws/aws-sdk-go-v2 v1.6.0/go.mod h1:tI4KhsR5VkzlUa2DZAdwx7wCAYGwkZZ1H3 github.com/aws/aws-sdk-go-v2/service/route53 v1.6.2/go.mod h1:ZnAMilx42P7DgIrdjlWCkNIGSBLzeyk6T31uB8oGTwY= github.com/aws/smithy-go v1.4.0 h1:3rsQpgRe+OoQgJhEwGNpIkosl0fJLdmQqF4gSFRjg+4= github.com/aws/smithy-go v1.4.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= @@ -24,3 +24,4 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/lambda/create/go.mod b/lambda/create/go.mod index 61dbb657..7758c480 100644 --- a/lambda/create/go.mod +++ b/lambda/create/go.mod @@ -8,16 +8,21 @@ require ( github.com/aws/aws-lambda-go v1.41.0 github.com/ministryofjustice/opg-data-lpa-store/lambda/shared v0.0.0-00010101000000-000000000000 github.com/ministryofjustice/opg-go-common v0.0.0-20231106092059-b3dcf8bd1eeb + github.com/stretchr/testify v1.8.4 ) require ( github.com/andybalholm/brotli v1.0.4 // indirect - github.com/aws/aws-sdk-go v1.47.3 // indirect + github.com/aws/aws-sdk-go v1.47.9 // indirect github.com/aws/aws-xray-sdk-go v1.8.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.1.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.15.9 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.34.0 // indirect golang.org/x/net v0.17.0 // indirect @@ -26,4 +31,5 @@ require ( google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/lambda/create/go.sum b/lambda/create/go.sum index d4d5f18e..8da1db61 100644 --- a/lambda/create/go.sum +++ b/lambda/create/go.sum @@ -3,16 +3,14 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y= github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= -github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= -github.com/aws/aws-sdk-go v1.46.1/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.5 h1:NYYUrhOftwiXPkqZwEpB3043bMukegJAt15ozrqJbEY= -github.com/aws/aws-sdk-go v1.46.5/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.47.3 h1:e0H6NFXiniCpR8Lu3lTphVdRaeRCDLAeRyTHd1tJSd8= -github.com/aws/aws-sdk-go v1.47.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.47.9 h1:rarTsos0mA16q+huicGx0e560aYRtOucV5z2Mw23JRY= github.com/aws/aws-xray-sdk-go v1.8.2 h1:PVxNWnQG+rAYjxsmhEN97DTO57Dipg6VS0wsu6bXUB0= github.com/aws/aws-xray-sdk-go v1.8.2/go.mod h1:wMmVYzej3sykAttNBkXQHK/+clAPWTOrPiajEk7Cp3A= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang-jwt/jwt/v5 v5.1.0 h1:UGKbA/IPjtS6zLcdB7i5TyACMgSbOTiR8qzXgw8HWQU= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -26,63 +24,43 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90 h1:mxTHIeCYV7LDZPN7C44wwLlBTUsgQ0G8FQprsrsKXaA= -github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90/go.mod h1:1RmCNi6dkAv8umAgNHp8RkuBoSKLlxp1UtfsGYH7ufc= -github.com/ministryofjustice/opg-go-common v0.0.0-20231009133357-1f236d604316 h1:iuo6s75firLntoOAU+SCaRnXUHlLfTIxru8hBlYsECw= -github.com/ministryofjustice/opg-go-common v0.0.0-20231009133357-1f236d604316/go.mod h1:1RmCNi6dkAv8umAgNHp8RkuBoSKLlxp1UtfsGYH7ufc= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ministryofjustice/opg-go-common v0.0.0-20231106092059-b3dcf8bd1eeb h1:nZ2pEcU9r5sAewHyQ0ZrXnPNLSHgfvxa7xf7rpZpbno= github.com/ministryofjustice/opg-go-common v0.0.0-20231106092059-b3dcf8bd1eeb/go.mod h1:qktwZb46YkojkLVHU2QNnVK6yVktXkNpBuJ+TyobvuY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= @@ -93,6 +71,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/lambda/create/time.go b/lambda/create/time.go deleted file mode 100644 index 978b9432..00000000 --- a/lambda/create/time.go +++ /dev/null @@ -1,19 +0,0 @@ -package main - -import "time" - -type Time struct { - time.Time - Err error -} - -func (m *Time) UnmarshalJSON(data []byte) error { - err := m.Time.UnmarshalJSON(data) - - *m = Time{ - Time: m.Time, - Err: err, - } - - return nil -} diff --git a/lambda/create/validate.go b/lambda/create/validate.go index 84972ab7..596214c2 100644 --- a/lambda/create/validate.go +++ b/lambda/create/validate.go @@ -40,7 +40,9 @@ func validateAttorney(attorney shared.Attorney, prefix string, errors []shared.F } } - if attorney.DateOfBirth.IsZero() { + if attorney.DateOfBirth.IsMalformed { + errors = append(errors, shared.FieldError{Source: fmt.Sprintf("%s/dateOfBirth", prefix), Detail: "invalid format"}) + } else if attorney.DateOfBirth.IsZero() { errors = append(errors, shared.FieldError{Source: fmt.Sprintf("%s/dateOfBirth", prefix), Detail: "field is required"}) } diff --git a/lambda/create/validate_test.go b/lambda/create/validate_test.go new file mode 100644 index 00000000..704ca661 --- /dev/null +++ b/lambda/create/validate_test.go @@ -0,0 +1,142 @@ +package main + +import ( + "testing" + "time" + + "github.com/ministryofjustice/opg-data-lpa-store/lambda/shared" + "github.com/stretchr/testify/assert" +) + +var validAddress = shared.Address{ + Line1: "123 Main St", + Town: "Homeland", + Country: "GB", +} + +func newDate(date string, isMalformed bool) shared.Date { + t, _ := time.Parse("2006-01-02", date) + + return shared.Date{ + Time: t, + IsMalformed: isMalformed, + } +} + +func TestValidateAddressEmpty(t *testing.T) { + address := shared.Address{} + errors := validateAddress(address, "/test", []shared.FieldError{}) + + assert.Contains(t, errors, shared.FieldError{Source: "/test/line1", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/town", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/country", Detail: "field is required"}) +} + +func TestValidateAddressValid(t *testing.T) { + errors := validateAddress(validAddress, "/test", []shared.FieldError{}) + + assert.Empty(t, errors) +} + +func TestValidateAddressInvalidCountry(t *testing.T) { + invalidAddress := shared.Address{ + Line1: "123 Main St", + Town: "Homeland", + Country: "United Kingdom", + } + errors := validateAddress(invalidAddress, "/test", []shared.FieldError{}) + + assert.Contains(t, errors, shared.FieldError{Source: "/test/country", Detail: "must be a valid ISO-3166-1 country code"}) +} + +func TestValidateAttorneyEmpty(t *testing.T) { + attorney := shared.Attorney{} + errors := validateAttorney(attorney, "/test", []shared.FieldError{}) + + assert.Contains(t, errors, shared.FieldError{Source: "/test/firstNames", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/surname", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/status", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/test/dateOfBirth", Detail: "field is required"}) +} + +func TestValidateAttorneyValid(t *testing.T) { + attorney := shared.Attorney{ + Person: shared.Person{ + FirstNames: "Lesia", + Surname: "Lathim", + Address: validAddress, + DateOfBirth: newDate("1928-01-18", false), + }, + Status: shared.AttorneyStatusActive, + } + errors := validateAttorney(attorney, "/test", []shared.FieldError{}) + + assert.Empty(t, errors) +} + +func TestValidateAttorneyMalformedDateOfBirth(t *testing.T) { + attorney := shared.Attorney{ + Person: shared.Person{ + FirstNames: "Lesia", + Surname: "Lathim", + Address: validAddress, + DateOfBirth: newDate("bad date", true), + }, + Status: shared.AttorneyStatusActive, + } + errors := validateAttorney(attorney, "/test", []shared.FieldError{}) + + assert.Contains(t, errors, shared.FieldError{Source: "/test/dateOfBirth", Detail: "invalid format"}) +} + +func TestValidateAttorneyInvalidStatus(t *testing.T) { + attorney := shared.Attorney{ + Person: shared.Person{ + FirstNames: "Lesia", + Surname: "Lathim", + Address: validAddress, + DateOfBirth: newDate("1928-01-18", false), + }, + Status: "bad status", + } + errors := validateAttorney(attorney, "/test", []shared.FieldError{}) + + assert.Contains(t, errors, shared.FieldError{Source: "/test/status", Detail: "invalid value"}) +} + +func TestValidateLpaEmpty(t *testing.T) { + lpa := shared.LpaInit{} + errors := Validate(lpa) + + assert.Contains(t, errors, shared.FieldError{Source: "/donor/firstNames", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/donor/surname", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/donor/dateOfBirth", Detail: "field is required"}) + assert.Contains(t, errors, shared.FieldError{Source: "/attorneys", Detail: "at least one attorney is required"}) +} + +func TestValidateLpaValid(t *testing.T) { + lpa := shared.LpaInit{ + Donor: shared.Donor{ + Person: shared.Person{ + FirstNames: "Otto", + Surname: "Boudreau", + DateOfBirth: newDate("1956-08-08", false), + Address: validAddress, + }, + }, + Attorneys: []shared.Attorney{ + { + Person: shared.Person{ + FirstNames: "Sharonda", + Surname: "Graciani", + DateOfBirth: newDate("1977-10-30", false), + Address: validAddress, + }, + Status: shared.AttorneyStatusActive, + }, + }, + } + errors := Validate(lpa) + + assert.Empty(t, errors) +} diff --git a/lambda/get/go.mod b/lambda/get/go.mod index 698a9bd2..42d54366 100644 --- a/lambda/get/go.mod +++ b/lambda/get/go.mod @@ -12,8 +12,9 @@ require ( require ( github.com/andybalholm/brotli v1.0.4 // indirect - github.com/aws/aws-sdk-go v1.47.3 // indirect + github.com/aws/aws-sdk-go v1.47.9 // indirect github.com/aws/aws-xray-sdk-go v1.8.2 // indirect + github.com/golang-jwt/jwt/v5 v5.1.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.15.9 // indirect diff --git a/lambda/get/go.sum b/lambda/get/go.sum index d4d5f18e..49875598 100644 --- a/lambda/get/go.sum +++ b/lambda/get/go.sum @@ -3,16 +3,12 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y= github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= -github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= -github.com/aws/aws-sdk-go v1.46.1/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.5 h1:NYYUrhOftwiXPkqZwEpB3043bMukegJAt15ozrqJbEY= -github.com/aws/aws-sdk-go v1.46.5/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.47.3 h1:e0H6NFXiniCpR8Lu3lTphVdRaeRCDLAeRyTHd1tJSd8= -github.com/aws/aws-sdk-go v1.47.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.47.9 h1:rarTsos0mA16q+huicGx0e560aYRtOucV5z2Mw23JRY= github.com/aws/aws-xray-sdk-go v1.8.2 h1:PVxNWnQG+rAYjxsmhEN97DTO57Dipg6VS0wsu6bXUB0= github.com/aws/aws-xray-sdk-go v1.8.2/go.mod h1:wMmVYzej3sykAttNBkXQHK/+clAPWTOrPiajEk7Cp3A= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/golang-jwt/jwt/v5 v5.1.0 h1:UGKbA/IPjtS6zLcdB7i5TyACMgSbOTiR8qzXgw8HWQU= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -26,10 +22,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90 h1:mxTHIeCYV7LDZPN7C44wwLlBTUsgQ0G8FQprsrsKXaA= -github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90/go.mod h1:1RmCNi6dkAv8umAgNHp8RkuBoSKLlxp1UtfsGYH7ufc= -github.com/ministryofjustice/opg-go-common v0.0.0-20231009133357-1f236d604316 h1:iuo6s75firLntoOAU+SCaRnXUHlLfTIxru8hBlYsECw= -github.com/ministryofjustice/opg-go-common v0.0.0-20231009133357-1f236d604316/go.mod h1:1RmCNi6dkAv8umAgNHp8RkuBoSKLlxp1UtfsGYH7ufc= github.com/ministryofjustice/opg-go-common v0.0.0-20231106092059-b3dcf8bd1eeb h1:nZ2pEcU9r5sAewHyQ0ZrXnPNLSHgfvxa7xf7rpZpbno= github.com/ministryofjustice/opg-go-common v0.0.0-20231106092059-b3dcf8bd1eeb/go.mod h1:qktwZb46YkojkLVHU2QNnVK6yVktXkNpBuJ+TyobvuY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -43,46 +35,25 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= diff --git a/lambda/shared/date.go b/lambda/shared/date.go new file mode 100644 index 00000000..5a85bf8c --- /dev/null +++ b/lambda/shared/date.go @@ -0,0 +1,23 @@ +package shared + +import ( + "time" +) + +type Date struct { + time.Time + IsMalformed bool +} + +func (m *Date) UnmarshalJSON(data []byte) error { + str := string(data) + time, err := time.Parse(`"2006-01-02"`, str) + + m.Time = time + + if err != nil { + m.IsMalformed = str != "" && str != `""` + } + + return nil +} diff --git a/lambda/shared/date_test.go b/lambda/shared/date_test.go new file mode 100644 index 00000000..7ec09600 --- /dev/null +++ b/lambda/shared/date_test.go @@ -0,0 +1,51 @@ +package shared + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestUnmarshalDate(t *testing.T) { + testCases := []struct { + name string + in string + expectFormatted string + expectIsMalformed bool + }{ + { + name: "ok", + in: `"1930-10-31"`, + expectFormatted: "31 October 1930", + expectIsMalformed: false, + }, + { + name: "out of bounds", + in: `"1930-11-31"`, + expectFormatted: "1 January 0001", + expectIsMalformed: true, + }, + { + name: "invalid string", + in: `"31 October 1930"`, + expectFormatted: "1 January 0001", + expectIsMalformed: true, + }, + { + name: "number", + in: `1700240133`, + expectFormatted: "1 January 0001", + expectIsMalformed: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + date := Date{} + date.UnmarshalJSON([]byte(tc.in)) + + assert.Equal(t, tc.expectFormatted, date.Time.Format("2 January 2006")) + assert.Equal(t, tc.expectIsMalformed, date.IsMalformed) + }) + } +} diff --git a/lambda/shared/go.mod b/lambda/shared/go.mod index 119d4b41..859b79b4 100644 --- a/lambda/shared/go.mod +++ b/lambda/shared/go.mod @@ -6,19 +6,20 @@ require ( github.com/aws/aws-lambda-go v1.41.0 github.com/aws/aws-sdk-go v1.47.9 github.com/aws/aws-xray-sdk-go v1.8.2 + github.com/golang-jwt/jwt/v5 v5.1.0 + github.com/stretchr/testify v1.8.4 ) require ( github.com/andybalholm/brotli v1.0.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.1.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/compress v1.15.9 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect - github.com/stretchr/testify v1.8.4 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.34.0 // indirect golang.org/x/net v0.17.0 // indirect @@ -27,5 +28,6 @@ require ( google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/lambda/shared/go.sum b/lambda/shared/go.sum index 7f47e3f1..49f897aa 100644 --- a/lambda/shared/go.sum +++ b/lambda/shared/go.sum @@ -3,36 +3,11 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y= github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= -github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= -github.com/aws/aws-sdk-go v1.46.1/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.5 h1:NYYUrhOftwiXPkqZwEpB3043bMukegJAt15ozrqJbEY= -github.com/aws/aws-sdk-go v1.46.5/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.6 h1:6wFnNC9hETIZLMf6SOTN7IcclrOGwp/n9SLp8Pjt6E8= -github.com/aws/aws-sdk-go v1.46.6/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.7 h1:IjvAWeiJZlbETOemOwvheN5L17CvKvKW0T1xOC6d3Sc= -github.com/aws/aws-sdk-go v1.46.7/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.47.0 h1:/JUg9V1+xh+qBn8A6ec/l15ETPaMaBqxkjz+gg63dNk= -github.com/aws/aws-sdk-go v1.47.0/go.mod h1:DlEaEbWKZmsITVbqlSVvekPARM1HzeV9PMYg15ymSDA= -github.com/aws/aws-sdk-go v1.47.1 h1:j9ih0Ashcw8tQcnfqNimBM8ARQ/CMpoBwjKue1D6Fuk= -github.com/aws/aws-sdk-go v1.47.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.2 h1:KEdO2PbjfEBmHvnEwbYEpr65ZIkmwK5aB85Gj19ASuA= -github.com/aws/aws-sdk-go v1.47.2/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.3 h1:e0H6NFXiniCpR8Lu3lTphVdRaeRCDLAeRyTHd1tJSd8= -github.com/aws/aws-sdk-go v1.47.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.4 h1:IyhNbmPt+5ldi5HNzv7ZnXiqSglDMaJiZlzj4Yq3qnk= -github.com/aws/aws-sdk-go v1.47.4/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.5 h1:U2JlfPmrUoz5p+2X/XwKxmaJFo2oV+LbJqx8jyEvyAY= -github.com/aws/aws-sdk-go v1.47.5/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.6 h1:WMnLApoJAKC+KBt8f53QccGBZghLRoVfAcOo52jUtY0= -github.com/aws/aws-sdk-go v1.47.6/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.7 h1:Y1J7g48WAzO4dYGQELbWJ57rASV8G7rd4u9hDB+AevU= -github.com/aws/aws-sdk-go v1.47.7/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= -github.com/aws/aws-sdk-go v1.47.8 h1:VCFyO5UTREnhR0HRf9roqFfJeeRVin58zUy+pBMhwjY= -github.com/aws/aws-sdk-go v1.47.8/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-sdk-go v1.47.9 h1:rarTsos0mA16q+huicGx0e560aYRtOucV5z2Mw23JRY= github.com/aws/aws-sdk-go v1.47.9/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/aws/aws-xray-sdk-go v1.8.2 h1:PVxNWnQG+rAYjxsmhEN97DTO57Dipg6VS0wsu6bXUB0= github.com/aws/aws-xray-sdk-go v1.8.2/go.mod h1:wMmVYzej3sykAttNBkXQHK/+clAPWTOrPiajEk7Cp3A= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -51,16 +26,22 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -68,46 +49,25 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= @@ -118,8 +78,9 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/lambda/shared/person.go b/lambda/shared/person.go index 638c2bd7..27273c24 100644 --- a/lambda/shared/person.go +++ b/lambda/shared/person.go @@ -12,7 +12,7 @@ type Address struct { type Person struct { FirstNames string `json:"firstNames" dynamodbav:""` Surname string `json:"surname" dynamodbav:""` - DateOfBirth Time `json:"dateOfBirth" dynamodbav:""` + DateOfBirth Date `json:"dateOfBirth" dynamodbav:""` Email string `json:"email" dynamodbav:""` Address Address `json:"address" dynamodbav:""` } diff --git a/lambda/shared/time.go b/lambda/shared/time.go deleted file mode 100644 index 7e4bab1d..00000000 --- a/lambda/shared/time.go +++ /dev/null @@ -1,25 +0,0 @@ -package shared - -import ( - "regexp" - "time" -) - -type Time struct { - time.Time - IsMalformed bool -} - -func (m *Time) UnmarshalJSON(data []byte) error { - time, err := time.Parse(`"2006-01-02"`, string(data)) - - m.Time = time - - if err != nil { - if ok, _ := regexp.MatchString("cannot parse \".+\" as \"\\\"2006-01-02\\\"\"$", err.Error()); ok { - m.IsMalformed = true - } - } - - return nil -} diff --git a/lambda/update/go.mod b/lambda/update/go.mod index cb1bbbdb..5e8fd894 100644 --- a/lambda/update/go.mod +++ b/lambda/update/go.mod @@ -13,16 +13,16 @@ require ( require ( github.com/andybalholm/brotli v1.0.4 // indirect - github.com/aws/aws-sdk-go v1.47.3 // indirect + github.com/aws/aws-sdk-go v1.47.9 // indirect github.com/aws/aws-xray-sdk-go v1.8.2 // indirect github.com/go-openapi/swag v0.22.4 // indirect + github.com/golang-jwt/jwt/v5 v5.1.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.15.9 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.34.0 // indirect golang.org/x/net v0.17.0 // indirect diff --git a/lambda/update/go.sum b/lambda/update/go.sum index fe6d172e..51d0ac40 100644 --- a/lambda/update/go.sum +++ b/lambda/update/go.sum @@ -3,12 +3,7 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/aws/aws-lambda-go v1.41.0 h1:l/5fyVb6Ud9uYd411xdHZzSf2n86TakxzpvIoz7l+3Y= github.com/aws/aws-lambda-go v1.41.0/go.mod h1:jwFe2KmMsHmffA1X2R09hH6lFzJQxzI8qK17ewzbQMM= -github.com/aws/aws-sdk-go v1.46.1 h1:U26quvBWFZMQuultLw5tloW4GnmWaChEwMZNq8uYatw= -github.com/aws/aws-sdk-go v1.46.1/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.46.5 h1:NYYUrhOftwiXPkqZwEpB3043bMukegJAt15ozrqJbEY= -github.com/aws/aws-sdk-go v1.46.5/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go v1.47.3 h1:e0H6NFXiniCpR8Lu3lTphVdRaeRCDLAeRyTHd1tJSd8= -github.com/aws/aws-sdk-go v1.47.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.47.9 h1:rarTsos0mA16q+huicGx0e560aYRtOucV5z2Mw23JRY= github.com/aws/aws-xray-sdk-go v1.8.2 h1:PVxNWnQG+rAYjxsmhEN97DTO57Dipg6VS0wsu6bXUB0= github.com/aws/aws-xray-sdk-go v1.8.2/go.mod h1:wMmVYzej3sykAttNBkXQHK/+clAPWTOrPiajEk7Cp3A= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -17,6 +12,7 @@ github.com/go-openapi/jsonpointer v0.20.0 h1:ESKJdU9ASRfaPNOPRx12IUyA1vn3R9GiE3K github.com/go-openapi/jsonpointer v0.20.0/go.mod h1:6PGzBjjIIumbLYysB73Klnms1mwnU4G3YHOECG3CedA= github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/golang-jwt/jwt/v5 v5.1.0 h1:UGKbA/IPjtS6zLcdB7i5TyACMgSbOTiR8qzXgw8HWQU= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -36,10 +32,6 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90 h1:mxTHIeCYV7LDZPN7C44wwLlBTUsgQ0G8FQprsrsKXaA= -github.com/ministryofjustice/opg-go-common v0.0.0-20220816144329-763497f29f90/go.mod h1:1RmCNi6dkAv8umAgNHp8RkuBoSKLlxp1UtfsGYH7ufc= -github.com/ministryofjustice/opg-go-common v0.0.0-20231009133357-1f236d604316 h1:iuo6s75firLntoOAU+SCaRnXUHlLfTIxru8hBlYsECw= -github.com/ministryofjustice/opg-go-common v0.0.0-20231009133357-1f236d604316/go.mod h1:1RmCNi6dkAv8umAgNHp8RkuBoSKLlxp1UtfsGYH7ufc= github.com/ministryofjustice/opg-go-common v0.0.0-20231106092059-b3dcf8bd1eeb h1:nZ2pEcU9r5sAewHyQ0ZrXnPNLSHgfvxa7xf7rpZpbno= github.com/ministryofjustice/opg-go-common v0.0.0-20231106092059-b3dcf8bd1eeb/go.mod h1:qktwZb46YkojkLVHU2QNnVK6yVktXkNpBuJ+TyobvuY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -47,7 +39,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -55,46 +46,25 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= From b4ba3ace20e085b9b0e26311ce630533227f5868 Mon Sep 17 00:00:00 2001 From: Greg Tyler Date: Fri, 17 Nov 2023 17:31:31 +0000 Subject: [PATCH 3/6] Refactor OpenAPI file AWS can only operate a single file, and this gives us an opportunity to co-locate the schemas rather than using `$defs`. #patch --- .redocly.lint-ignore.yaml | 4 -- docs/openapi/initial-lpa.yaml | 99 ----------------------------- docs/openapi/lpa.yaml | 26 -------- docs/openapi/openapi.yaml | 116 +++++++++++++++++++++++++++++++++- 4 files changed, 114 insertions(+), 131 deletions(-) delete mode 100644 docs/openapi/initial-lpa.yaml delete mode 100644 docs/openapi/lpa.yaml diff --git a/.redocly.lint-ignore.yaml b/.redocly.lint-ignore.yaml index 3bd2ea73..f5fc2232 100644 --- a/.redocly.lint-ignore.yaml +++ b/.redocly.lint-ignore.yaml @@ -1,9 +1,5 @@ # This file instructs Redocly's linter to ignore the rules contained for specific parts of your API. # See https://redoc.ly/docs/cli/ for more information. -docs/schemas/lpa.yaml: - spec: - - '#/$id' - - '#/$schema' docs/openapi/openapi.yaml: spec: - >- diff --git a/docs/openapi/initial-lpa.yaml b/docs/openapi/initial-lpa.yaml deleted file mode 100644 index 12c9f8f8..00000000 --- a/docs/openapi/initial-lpa.yaml +++ /dev/null @@ -1,99 +0,0 @@ -$id: https://opg.service.justice.gov.uk/schema/lpa/2023-10 -$schema: http://json-schema.org/draft/2020-02/schema -title: Initial LPA -description: Digital representation of a Lasting Power of Attorney -type: object -required: - - donor - - attorneys -properties: - donor: - $ref: "#/$defs/Donor" - attorneys: - type: array - items: - $ref: "#/$defs/Attorney" - minLength: 1 -additionalProperties: false -$defs: - InitialLpa: - - Person: - type: object - required: - - firstNames - - surname - - dateOfBirth - - address - properties: - firstNames: - type: string - x-faker: name.firstName - surname: - type: string - x-faker: name.lastName - dateOfBirth: - type: string - format: date - email: - type: string - x-faker: internet.email - address: - $ref: "#/$defs/Address" - Address: - type: object - required: - - line1 - - town - - country - properties: - line1: - type: string - x-faker: address.streetAddress - line2: - type: string - x-faker: address.streetName - line3: - type: string - x-faker: address.cityName - town: - type: string - x-faker: address.cityName - postcode: - type: string - x-faker: - helpers.replaceSymbols: "??# #??" - country: - type: string - format: ISO-3166-1 - minLength: 2 - maxLength: 2 - x-faker: address.countryCode - additionalProperties: false - example: - line1: Flat 3 - line2: 42 Primrose Lane - line3: Greenfields - town: Manchester - postcode: M17 2XY - country: GB - Donor: - allOf: - - $ref: "#/$defs/Person" - type: object - properties: - otherNames: - type: string - nullable: true - x-faker: name.findName - Attorney: - allOf: - - $ref: "#/$defs/Person" - type: object - properties: - status: - type: string - enum: - - active - - replacement - - removed diff --git a/docs/openapi/lpa.yaml b/docs/openapi/lpa.yaml deleted file mode 100644 index 8fc4515b..00000000 --- a/docs/openapi/lpa.yaml +++ /dev/null @@ -1,26 +0,0 @@ -$id: https://opg.service.justice.gov.uk/schema/lpa/2023-10 -$schema: http://json-schema.org/draft/2020-02/schema -title: LPA -description: Digital representation of a Lasting Power of Attorney -allOf: - - $ref: "./initial-lpa.yaml" -type: object -required: - - uid - - status - - registrationDate -properties: - uid: - type: string - pattern: M-([A-Z0-9]{4})-([A-Z0-9]{4})-([A-Z0-9]{4}) - example: M-789Q-P4DF-4UX3 - status: - type: string - enum: - - processing - - registered - registrationDate: - type: string - format: date - nullable: true -additionalProperties: false diff --git a/docs/openapi/openapi.yaml b/docs/openapi/openapi.yaml index 80ff0966..180d90f6 100644 --- a/docs/openapi/openapi.yaml +++ b/docs/openapi/openapi.yaml @@ -190,9 +190,121 @@ components: - source: "/uid" detail: "invalid uid format" Lpa: - $ref: "./lpa.yaml" + allOf: + - $ref: "#/components/schemas/InitialLpa" + type: object + required: + - uid + - status + - registrationDate + properties: + uid: + type: string + pattern: M-([A-Z0-9]{4})-([A-Z0-9]{4})-([A-Z0-9]{4}) + example: M-789Q-P4DF-4UX3 + status: + type: string + enum: + - processing + - registered + registrationDate: + type: string + format: date + nullable: true + additionalProperties: false InitialLpa: - $ref: "./initial-lpa.yaml" + type: object + required: + - donor + - attorneys + properties: + donor: + $ref: "#/components/schemas/Donor" + attorneys: + type: array + items: + $ref: "#/components/schemas/Attorney" + minLength: 1 + additionalProperties: false + Address: + type: object + required: + - line1 + - town + - country + properties: + line1: + type: string + x-faker: address.streetAddress + line2: + type: string + x-faker: address.streetName + line3: + type: string + x-faker: address.cityName + town: + type: string + x-faker: address.cityName + postcode: + type: string + x-faker: + helpers.replaceSymbols: "??# #??" + country: + type: string + format: ISO-3166-1 + minLength: 2 + maxLength: 2 + x-faker: address.countryCode + additionalProperties: false + example: + line1: Flat 3 + line2: 42 Primrose Lane + line3: Greenfields + town: Manchester + postcode: M17 2XY + country: GB + Person: + type: object + required: + - firstNames + - surname + - dateOfBirth + - address + properties: + firstNames: + type: string + x-faker: name.firstName + surname: + type: string + x-faker: name.lastName + dateOfBirth: + type: string + format: date + email: + type: string + x-faker: internet.email + address: + $ref: "#/components/schemas/Address" + Donor: + allOf: + - $ref: "#/components/schemas/Person" + type: object + properties: + otherNames: + type: string + nullable: true + x-faker: name.findName + Attorney: + allOf: + - $ref: "#/components/schemas/Person" + type: object + properties: + status: + type: string + enum: + - active + - replacement + - removed Update: type: object required: From b38d8a2bd89d957d1f3cfd10e733b34bc602d1ed Mon Sep 17 00:00:00 2001 From: Greg Tyler Date: Mon, 20 Nov 2023 09:34:28 +0000 Subject: [PATCH 4/6] Reinstate error log I somehow removed this in a previous commit #patch --- lambda/create/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lambda/create/main.go b/lambda/create/main.go index 25a2e360..dcd0ab0c 100644 --- a/lambda/create/main.go +++ b/lambda/create/main.go @@ -45,8 +45,10 @@ func (l *Lambda) HandleEvent(ctx context.Context, event events.APIGatewayProxyRe var existingLpa shared.Lpa existingLpa, err := l.store.Get(ctx, uid) if err != nil { + l.logger.Print(err) return shared.ProblemInternalServerError.Respond() } + if existingLpa.Uid == uid { problem := shared.ProblemInvalidRequest problem.Detail = "LPA with UID already exists" From a30e74f02e02699af9eb33a1ff0661835cdb55cc Mon Sep 17 00:00:00 2001 From: Greg Tyler Date: Mon, 20 Nov 2023 12:49:13 +0000 Subject: [PATCH 5/6] Update example data --- docs/example-lpa.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/example-lpa.json b/docs/example-lpa.json index 3a8cbb76..3d13da01 100644 --- a/docs/example-lpa.json +++ b/docs/example-lpa.json @@ -14,15 +14,15 @@ "attorneys": [ { "firstNames": "Jake", - "surname": "Mulato", + "surname": "Vallar", "dateOfBirth": "2001-01-17", - "email": "jmul5@example.com", + "email": "jval5@example.com", "status": "active", "address": { "line1": "71 South Western Terrace", "town": "Milton", - "postcode": "FK17 4FE", - "country": "GB" + "postcode": "6306", + "country": "AU" } }, { From 8240d4c433c16a878c02979547d880b7b99c6a20 Mon Sep 17 00:00:00 2001 From: Greg Tyler Date: Wed, 22 Nov 2023 13:03:07 +0000 Subject: [PATCH 6/6] "otherNames" => "otherNamesKnownBy" #patch --- docs/openapi/openapi.yaml | 2 +- lambda/shared/person.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/openapi/openapi.yaml b/docs/openapi/openapi.yaml index 180d90f6..4d52e86c 100644 --- a/docs/openapi/openapi.yaml +++ b/docs/openapi/openapi.yaml @@ -290,7 +290,7 @@ components: - $ref: "#/components/schemas/Person" type: object properties: - otherNames: + otherNamesKnownBy: type: string nullable: true x-faker: name.findName diff --git a/lambda/shared/person.go b/lambda/shared/person.go index 27273c24..2e78bcfa 100644 --- a/lambda/shared/person.go +++ b/lambda/shared/person.go @@ -19,7 +19,7 @@ type Person struct { type Donor struct { Person - OtherNames string `json:"otherNames" dynamodbav:""` + OtherNamesKnownBy string `json:"otherNamesKnownBy" dynamodbav:""` } type AttorneyStatus string