Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLPAB-2318: Send attorney opt out to lpa-store #1419

Merged
merged 13 commits into from
Aug 13, 2024
4 changes: 2 additions & 2 deletions docker/event-logger/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.5-alpine as base
FROM golang:1.22.5-alpine AS base

ARG ARCH=amd64

Expand All @@ -11,7 +11,7 @@ COPY cmd/event-logger ./cmd/event-logger

RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /go/bin/event-logger ./cmd/event-logger

FROM scratch as production
FROM scratch AS production

COPY --from=base /go/bin/event-logger event-logger

Expand Down
2 changes: 1 addition & 1 deletion docker/event-received/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.5-alpine as build
FROM golang:1.22.5-alpine AS build

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions docker/localstack/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.5-alpine as build
FROM golang:1.22.5-alpine AS build

RUN apk add zip

Expand All @@ -13,7 +13,7 @@ COPY --link internal ./internal
RUN GOOS=linux GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -tags lambda.norpc -o event-received ./cmd/event-received
RUN zip event-received.zip event-received

FROM localstack/localstack:3.6.0 as localstack
FROM localstack/localstack:3.6.0 AS localstack

COPY --from=build /app/event-received.zip /etc/event-received.zip

Expand Down
20 changes: 15 additions & 5 deletions docker/mock-lpa-store/lpa-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ console.log(`Request - ${context.request.method} ${context.request.path}`);

const lpaStore = stores.open('lpa');
const pathParts = context.request.path.split('/');
const lpaUID = pathParts[2]

switch (context.request.method) {
case 'GET': {
if (pathParts.length == 3 && pathParts[1] == 'lpas') {
const lpa = lpaStore.load(pathParts[2]);
const lpa = lpaStore.load(lpaUID);
if (lpa) {
respond().withContent(lpa);
} else {
Expand All @@ -19,9 +20,9 @@ switch (context.request.method) {
}
case 'PUT': {
let lpa = JSON.parse(context.request.body);
lpa.uid = pathParts[2];
lpa.uid = lpaUID;
lpa.updatedAt = new Date(Date.now()).toISOString();
lpaStore.save(pathParts[2], JSON.stringify(lpa));
lpaStore.save(lpaUID, JSON.stringify(lpa));
respond();
break;
}
Expand All @@ -33,7 +34,7 @@ switch (context.request.method) {
respond().withContent(JSON.stringify({ lpas: lpas }));
} else {
let update = JSON.parse(context.request.body);
let lpa = JSON.parse(lpaStore.load(pathParts[2]));
let lpa = JSON.parse(lpaStore.load(lpaUID));
if (!lpa) {
respond().withStatusCode(404);
break;
Expand Down Expand Up @@ -81,9 +82,18 @@ switch (context.request.method) {
case 'DONOR_WITHDRAW_LPA':
lpa.status = 'withdrawn';
break;

case 'ATTORNEY_OPT_OUT':
const idx = lpa.attorneys.findIndex(item => item.uid === update.subject)

if (idx >= 0 && lpa.attorneys[idx].signedAt != '') {
lpa.attorneys[idx].status = 'removed'
}
break;

}

lpaStore.save(pathParts[2], JSON.stringify(lpa));
lpaStore.save(lpaUID, JSON.stringify(lpa));
respond();
}
break;
Expand Down
2 changes: 1 addition & 1 deletion docker/mock-notify/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.5-alpine as build-env
FROM golang:1.22.5-alpine AS build-env

RUN apk --no-cache add openssl

Expand Down
2 changes: 1 addition & 1 deletion docker/mock-os-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.5-alpine as build-env
FROM golang:1.22.5-alpine AS build-env

RUN apk --no-cache add openssl

Expand Down
98 changes: 0 additions & 98 deletions internal/app/mock_LpaStoreResolvingService_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type confirmDontWantToBeAttorneyData struct {
Lpa *lpadata.Lpa
}

func ConfirmDontWantToBeAttorney(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, attorneyStore AttorneyStore, notifyClient NotifyClient, appPublicURL string) Handler {
func ConfirmDontWantToBeAttorney(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, attorneyStore AttorneyStore, notifyClient NotifyClient, appPublicURL string, lpaStoreClient LpaStoreClient) Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, attorneyProvidedDetails *attorneydata.Provided) error {
lpa, err := lpaStoreResolvingService.Get(r.Context())
if err != nil {
Expand All @@ -46,11 +46,15 @@ func ConfirmDontWantToBeAttorney(tmpl template.Template, lpaStoreResolvingServic
DonorStartPageURL: appPublicURL + page.PathStart.Format(),
}

if err := attorneyStore.Delete(r.Context()); err != nil {
if err := notifyClient.SendActorEmail(r.Context(), lpa.CorrespondentEmail(), lpa.LpaUID, email); err != nil {
return err
}

if err := notifyClient.SendActorEmail(r.Context(), lpa.CorrespondentEmail(), lpa.LpaUID, email); err != nil {
if err := lpaStoreClient.SendAttorneyOptOut(r.Context(), lpa.LpaUID, attorneyProvidedDetails.UID); err != nil {
return err
}

if err := attorneyStore.Delete(r.Context()); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type confirmDontWantToBeAttorneyDataLoggedOut struct {
Lpa *lpadata.Lpa
}

func ConfirmDontWantToBeAttorneyLoggedOut(tmpl template.Template, shareCodeStore ShareCodeStore, lpaStoreResolvingService LpaStoreResolvingService, sessionStore SessionStore, notifyClient NotifyClient, appPublicURL string) page.Handler {
func ConfirmDontWantToBeAttorneyLoggedOut(tmpl template.Template, shareCodeStore ShareCodeStore, lpaStoreResolvingService LpaStoreResolvingService, sessionStore SessionStore, notifyClient NotifyClient, appPublicURL string, lpaStoreClient LpaStoreClient) page.Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request) error {
session, err := sessionStore.LpaData(r)
if err != nil {
Expand Down Expand Up @@ -64,6 +64,10 @@ func ConfirmDontWantToBeAttorneyLoggedOut(tmpl template.Template, shareCodeStore
return err
}

if err := lpaStoreClient.SendAttorneyOptOut(r.Context(), lpa.LpaUID, shareCode.ActorUID); err != nil {
return err
}

if err := shareCodeStore.Delete(r.Context(), shareCode); err != nil {
return err
}
Expand Down
Loading