Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpearce-digital authored Oct 15, 2024
2 parents cecfc04 + fa99e4d commit 97f9ac6
Show file tree
Hide file tree
Showing 80 changed files with 788 additions and 615 deletions.
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func App(
progressTracker := task.ProgressTracker{Localizer: localizer}

shareCodeSender := sharecode.NewSender(shareCodeStore, notifyClient, appPublicURL, random.String, eventClient)
witnessCodeSender := donor.NewWitnessCodeSender(donorStore, notifyClient, localizer)
witnessCodeSender := donor.NewWitnessCodeSender(donorStore, certificateProviderStore, notifyClient, localizer)

lpaStoreResolvingService := lpastore.NewResolvingService(donorStore, lpaStoreClient)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func ConfirmDontWantToBeAttorney(tmpl template.Template, lpaStoreResolvingServic
DonorStartPageURL: appPublicURL + page.PathStart.Format(),
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func ConfirmDontWantToBeAttorneyLoggedOut(tmpl template.Template, shareCodeStore
DonorStartPageURL: appPublicURL + page.PathStart.Format(),
}

if err := notifyClient.SendActorEmail(ctx, lpa.CorrespondentEmail(), lpa.LpaUID, email); err != nil {
if err := notifyClient.SendActorEmail(ctx, lpa.Donor.ContactLanguagePreference, lpa.CorrespondentEmail(), lpa.LpaUID, email); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid"
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/notify"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
Expand Down Expand Up @@ -157,6 +158,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) {
SignedAt: time.Now(),
Donor: lpadata.Donor{
FirstNames: "a b", LastName: "c", Email: "[email protected]",
ContactLanguagePreference: localize.En,
},
Attorneys: lpadata.Attorneys{
TrustCorporation: lpadata.TrustCorporation{UID: trustCorporationUID, Name: "trusty"},
Expand Down Expand Up @@ -202,7 +204,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) {
EmailGreeting(lpa).
Return("Dear donor")
notifyClient.EXPECT().
SendActorEmail(ctx, "[email protected]", "lpa-uid", notify.AttorneyOptedOutEmail{
SendActorEmail(ctx, localize.En, "[email protected]", "lpa-uid", notify.AttorneyOptedOutEmail{
Greeting: "Dear donor",
AttorneyFullName: tc.attorneyFullName,
DonorFullName: "a b c",
Expand Down Expand Up @@ -357,7 +359,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutErrors(t *testing.T) {
EmailGreeting(mock.Anything).
Return("Dear donor")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

return client
Expand Down Expand Up @@ -395,7 +397,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutErrors(t *testing.T) {
EmailGreeting(mock.Anything).
Return("Dear donor")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(nil)

return client
Expand Down Expand Up @@ -443,7 +445,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutErrors(t *testing.T) {
EmailGreeting(mock.Anything).
Return("Dear donor")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(nil)

return client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid"
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
"github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/notify"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
Expand Down Expand Up @@ -94,6 +95,7 @@ func TestPostConfirmDontWantToBeAttorney(t *testing.T) {
SignedAt: time.Now(),
Donor: lpadata.Donor{
FirstNames: "a b", LastName: "c", Email: "[email protected]",
ContactLanguagePreference: localize.En,
},
Attorneys: lpadata.Attorneys{
Attorneys: []lpadata.Attorney{
Expand All @@ -120,7 +122,7 @@ func TestPostConfirmDontWantToBeAttorney(t *testing.T) {
EmailGreeting(mock.Anything).
Return("Dear donor")
notifyClient.EXPECT().
SendActorEmail(r.Context(), "[email protected]", "lpa-uid", notify.AttorneyOptedOutEmail{
SendActorEmail(r.Context(), localize.En, "[email protected]", "lpa-uid", notify.AttorneyOptedOutEmail{
Greeting: "Dear donor",
AttorneyFullName: "d e f",
DonorFullName: "a b c",
Expand Down Expand Up @@ -184,7 +186,7 @@ func TestPostConfirmDontWantToBeAttorneyErrors(t *testing.T) {
EmailGreeting(mock.Anything).
Return("")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

return client
Expand All @@ -204,7 +206,7 @@ func TestPostConfirmDontWantToBeAttorneyErrors(t *testing.T) {
EmailGreeting(mock.Anything).
Return("")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(nil)

return client
Expand Down Expand Up @@ -232,7 +234,7 @@ func TestPostConfirmDontWantToBeAttorneyErrors(t *testing.T) {
EmailGreeting(mock.Anything).
Return("")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(nil)

return client
Expand Down
23 changes: 13 additions & 10 deletions internal/attorney/attorneypage/mock_NotifyClient_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/attorney/attorneypage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/attorney"
"github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dashboard/dashboarddata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/notify"
"github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin"
Expand Down Expand Up @@ -87,7 +88,7 @@ type LpaStoreClient interface {

type NotifyClient interface {
EmailGreeting(lpa *lpadata.Lpa) string
SendActorEmail(ctx context.Context, to, lpaUID string, email notify.Email) error
SendActorEmail(ctx context.Context, lang localize.Lang, to, lpaUID string, email notify.Email) error
}

type ErrorHandler func(http.ResponseWriter, *http.Request, error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func ConfirmDontWantToBeCertificateProvider(tmpl template.Template, lpaStoreReso
return err
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func ConfirmDontWantToBeCertificateProviderLoggedOut(tmpl template.Template, sha
}
}

if err := notifyClient.SendActorEmail(ctx, lpa.CorrespondentEmail(), lpa.LpaUID, email); err != nil {
if err := notifyClient.SendActorEmail(ctx, lpa.Donor.ContactLanguagePreference, lpa.CorrespondentEmail(), lpa.LpaUID, email); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
"github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/notify"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
Expand Down Expand Up @@ -149,6 +150,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) {
WitnessedByCertificateProviderAt: time.Now(),
Donor: lpadata.Donor{
FirstNames: "a b", LastName: "c", Email: "[email protected]",
ContactLanguagePreference: localize.En,
},
CertificateProvider: lpadata.CertificateProvider{
FirstNames: "d e", LastName: "f",
Expand Down Expand Up @@ -179,7 +181,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) {
LpaUID: "lpa-uid",
SignedAt: time.Now(),
WitnessedByCertificateProviderAt: time.Now(),
Donor: lpadata.Donor{FirstNames: "a b", LastName: "c", Email: "[email protected]"},
Donor: lpadata.Donor{FirstNames: "a b", LastName: "c", Email: "[email protected]", ContactLanguagePreference: localize.En},
CertificateProvider: lpadata.CertificateProvider{
FirstNames: "d e", LastName: "f",
},
Expand All @@ -203,6 +205,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) {
LpaUID: "lpa-uid",
Donor: lpadata.Donor{
FirstNames: "a b", LastName: "c", Email: "[email protected]",
ContactLanguagePreference: localize.En,
},
},
lpaStoreClient: func() *mockLpaStoreClient { return nil },
Expand Down Expand Up @@ -283,7 +286,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) {
EmailGreeting(&tc.lpa).
Return("Dear donor")
notifyClient.EXPECT().
SendActorEmail(ctx, "[email protected]", "lpa-uid", tc.email).
SendActorEmail(ctx, localize.En, "[email protected]", "lpa-uid", tc.email).
Return(nil)

localizer := newMockLocalizer(t)
Expand Down Expand Up @@ -530,7 +533,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T)
EmailGreeting(mock.Anything).
Return("")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(nil)

return client
Expand Down Expand Up @@ -577,7 +580,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T)
EmailGreeting(mock.Anything).
Return("")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

return client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid"
"github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext"
"github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/notify"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
Expand Down Expand Up @@ -113,6 +114,7 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) {
WitnessedByCertificateProviderAt: time.Now(),
Donor: lpadata.Donor{
FirstNames: "a b", LastName: "c", Email: "[email protected]",
ContactLanguagePreference: localize.En,
},
CertificateProvider: lpadata.CertificateProvider{
FirstNames: "d e", LastName: "f", UID: uid,
Expand Down Expand Up @@ -145,6 +147,7 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) {
WitnessedByCertificateProviderAt: time.Now(),
Donor: lpadata.Donor{
FirstNames: "a b", LastName: "c", Email: "[email protected]",
ContactLanguagePreference: localize.En,
},
CertificateProvider: lpadata.CertificateProvider{
FirstNames: "d e", LastName: "f", UID: uid,
Expand All @@ -167,7 +170,7 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) {
"not witnessed and signed": {
lpa: lpadata.Lpa{
LpaUID: "lpa-uid",
Donor: lpadata.Donor{FirstNames: "a b", LastName: "c", Email: "[email protected]"},
Donor: lpadata.Donor{FirstNames: "a b", LastName: "c", Email: "[email protected]", ContactLanguagePreference: localize.En},
},
lpaStoreClient: func() *mockLpaStoreClient { return nil },
donorStore: func() *mockDonorStore {
Expand Down Expand Up @@ -241,7 +244,7 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) {
EmailGreeting(mock.Anything).
Return("Dear donor")
notifyClient.EXPECT().
SendActorEmail(r.Context(), "[email protected]", "lpa-uid", tc.email).
SendActorEmail(r.Context(), localize.En, "[email protected]", "lpa-uid", tc.email).
Return(nil)

err := ConfirmDontWantToBeCertificateProvider(nil, lpaStoreResolvingService, tc.lpaStoreClient(), tc.donorStore(), certificateProviderStore, notifyClient, "example.com")(testAppData, w, r, nil)
Expand Down Expand Up @@ -467,7 +470,7 @@ func TestPostConfirmDontWantToBeCertificateProviderErrors(t *testing.T) {
EmailGreeting(mock.Anything).
Return("Dear donor")
client.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

return client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore Se
}

if lpa.SignedForDonor() {
if err := notifyClient.SendActorEmail(r.Context(), lpa.CorrespondentEmail(), lpa.LpaUID, notify.CertificateProviderFailedIDCheckEmail{
if err := notifyClient.SendActorEmail(r.Context(), lpa.Donor.ContactLanguagePreference, lpa.CorrespondentEmail(), lpa.LpaUID, notify.CertificateProviderFailedIdentityCheckEmail{
Greeting: notifyClient.EmailGreeting(lpa),
DonorFullName: lpa.Donor.FullName(),
CertificateProviderFullName: lpa.CertificateProvider.FullName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/event"
"github.com/ministryofjustice/opg-modernising-lpa/internal/identity"
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/notify"
"github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin"
Expand Down Expand Up @@ -205,7 +206,7 @@ func TestGetIdentityWithOneLoginCallbackWhenIdentityCheckFailed(t *testing.T) {
Return(&lpadata.Lpa{
LpaUID: "lpa-uid",
CertificateProvider: lpadata.CertificateProvider{FirstNames: "a", LastName: "b"},
Donor: lpadata.Donor{Email: "[email protected]", FirstNames: "c", LastName: "d"},
Donor: lpadata.Donor{Email: "[email protected]", FirstNames: "c", LastName: "d", ContactLanguagePreference: localize.En},
Type: lpadata.LpaTypePersonalWelfare,
SignedAt: time.Now(),
WitnessedByCertificateProviderAt: time.Now(),
Expand Down Expand Up @@ -239,7 +240,7 @@ func TestGetIdentityWithOneLoginCallbackWhenIdentityCheckFailed(t *testing.T) {
EmailGreeting(mock.Anything).
Return("Dear donor")
notifyClient.EXPECT().
SendActorEmail(r.Context(), "[email protected]", "lpa-uid", notify.CertificateProviderFailedIDCheckEmail{
SendActorEmail(r.Context(), localize.En, "[email protected]", "lpa-uid", notify.CertificateProviderFailedIdentityCheckEmail{
Greeting: "Dear donor",
DonorFullName: "c d",
CertificateProviderFullName: "a b",
Expand Down Expand Up @@ -324,7 +325,7 @@ func TestGetIdentityWithOneLoginCallbackWhenSendingEmailError(t *testing.T) {
EmailGreeting(mock.Anything).
Return("")
notifyClient.EXPECT().
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything).
SendActorEmail(mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(expectedError)

eventClient := newMockEventClient(t)
Expand Down
Loading

0 comments on commit 97f9ac6

Please sign in to comment.