diff --git a/cmd/event-received/factory.go b/cmd/event-received/factory.go index 82ea414b62..37c8dc4611 100644 --- a/cmd/event-received/factory.go +++ b/cmd/event-received/factory.go @@ -18,7 +18,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/secrets" @@ -40,7 +39,7 @@ type SecretsClient interface { } type ShareCodeSender interface { - SendCertificateProviderInvite(context.Context, appcontext.Data, page.CertificateProviderInvite) error + SendCertificateProviderInvite(context.Context, appcontext.Data, sharecode.CertificateProviderInvite) error SendCertificateProviderPrompt(context.Context, appcontext.Data, *donordata.Provided) error SendAttorneys(context.Context, appcontext.Data, *lpadata.Lpa) error } @@ -163,7 +162,7 @@ func (f *Factory) ShareCodeSender(ctx context.Context) (ShareCodeSender, error) return nil, err } - f.shareCodeSender = page.NewShareCodeSender(sharecode.NewStore(f.dynamoClient), notifyClient, f.appPublicURL, random.String, event.NewClient(f.cfg, f.eventBusName)) + f.shareCodeSender = sharecode.NewShareCodeSender(sharecode.NewStore(f.dynamoClient), notifyClient, f.appPublicURL, random.String, event.NewClient(f.cfg, f.eventBusName)) } return f.shareCodeSender, nil diff --git a/cmd/event-received/mock_shareCodeSender_test.go b/cmd/event-received/mock_shareCodeSender_test.go index c8aad0b74c..fe98b5cacb 100644 --- a/cmd/event-received/mock_shareCodeSender_test.go +++ b/cmd/event-received/mock_shareCodeSender_test.go @@ -13,7 +13,7 @@ import ( mock "github.com/stretchr/testify/mock" - page "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" ) // mockShareCodeSender is an autogenerated mock type for the ShareCodeSender type @@ -78,7 +78,7 @@ func (_c *mockShareCodeSender_SendAttorneys_Call) RunAndReturn(run func(context. } // SendCertificateProviderInvite provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockShareCodeSender) SendCertificateProviderInvite(_a0 context.Context, _a1 appcontext.Data, _a2 page.CertificateProviderInvite) error { +func (_m *mockShareCodeSender) SendCertificateProviderInvite(_a0 context.Context, _a1 appcontext.Data, _a2 sharecode.CertificateProviderInvite) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -86,7 +86,7 @@ func (_m *mockShareCodeSender) SendCertificateProviderInvite(_a0 context.Context } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, page.CertificateProviderInvite) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, sharecode.CertificateProviderInvite) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -103,14 +103,14 @@ type mockShareCodeSender_SendCertificateProviderInvite_Call struct { // SendCertificateProviderInvite is a helper method to define mock.On call // - _a0 context.Context // - _a1 appcontext.Data -// - _a2 page.CertificateProviderInvite +// - _a2 sharecode.CertificateProviderInvite func (_e *mockShareCodeSender_Expecter) SendCertificateProviderInvite(_a0 interface{}, _a1 interface{}, _a2 interface{}) *mockShareCodeSender_SendCertificateProviderInvite_Call { return &mockShareCodeSender_SendCertificateProviderInvite_Call{Call: _e.mock.On("SendCertificateProviderInvite", _a0, _a1, _a2)} } -func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 page.CertificateProviderInvite)) *mockShareCodeSender_SendCertificateProviderInvite_Call { +func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 sharecode.CertificateProviderInvite)) *mockShareCodeSender_SendCertificateProviderInvite_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(page.CertificateProviderInvite)) + run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(sharecode.CertificateProviderInvite)) }) return _c } @@ -120,7 +120,7 @@ func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) Return(_a0 err return _c } -func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) RunAndReturn(run func(context.Context, appcontext.Data, page.CertificateProviderInvite) error) *mockShareCodeSender_SendCertificateProviderInvite_Call { +func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) RunAndReturn(run func(context.Context, appcontext.Data, sharecode.CertificateProviderInvite) error) *mockShareCodeSender_SendCertificateProviderInvite_Call { _c.Call.Return(run) return _c } diff --git a/cmd/event-received/sirius_event_handler.go b/cmd/event-received/sirius_event_handler.go index 63c92f158b..45b332121f 100644 --- a/cmd/event-received/sirius_event_handler.go +++ b/cmd/event-received/sirius_event_handler.go @@ -12,8 +12,8 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) @@ -228,7 +228,7 @@ func handleDonorSubmissionCompleted(ctx context.Context, client dynamodbClient, } if lpa.CertificateProvider.Channel.IsOnline() { - if err := shareCodeSender.SendCertificateProviderInvite(ctx, appData, page.CertificateProviderInvite{ + if err := shareCodeSender.SendCertificateProviderInvite(ctx, appData, sharecode.CertificateProviderInvite{ LpaKey: lpa.LpaKey, LpaOwnerKey: lpa.LpaOwnerKey, LpaUID: lpa.LpaUID, diff --git a/cmd/event-received/sirius_event_handler_test.go b/cmd/event-received/sirius_event_handler_test.go index 9614473bd8..756f45d5fa 100644 --- a/cmd/event-received/sirius_event_handler_test.go +++ b/cmd/event-received/sirius_event_handler_test.go @@ -11,12 +11,12 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" - donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -754,7 +754,7 @@ func TestHandleDonorSubmissionCompleted(t *testing.T) { shareCodeSender := newMockShareCodeSender(t) shareCodeSender.EXPECT(). - SendCertificateProviderInvite(ctx, appData, page.CertificateProviderInvite{ + SendCertificateProviderInvite(ctx, appData, sharecode.CertificateProviderInvite{ DonorFirstNames: "Dave", DonorFullName: "Dave Smith", CertificateProviderUID: uid, diff --git a/internal/app/app.go b/internal/app/app.go index 152f0e478f..64b1a8188d 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -106,7 +106,7 @@ func App( memberStore := supporter.NewMemberStore(lpaDynamoClient) progressTracker := task.ProgressTracker{Localizer: localizer} - shareCodeSender := page.NewShareCodeSender(shareCodeStore, notifyClient, appPublicURL, random.String, eventClient) + shareCodeSender := sharecode.NewShareCodeSender(shareCodeStore, notifyClient, appPublicURL, random.String, eventClient) witnessCodeSender := page.NewWitnessCodeSender(donorStore, notifyClient) lpaStoreResolvingService := lpastore.NewResolvingService(donorStore, lpaStoreClient) diff --git a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go index 8724d3e3ba..5c5221f302 100644 --- a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go +++ b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go @@ -14,7 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -173,7 +173,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) { LpaData(r). Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), ActorUID: tc.uid, @@ -235,7 +235,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutWhenAttorneyNotFound(t *testing LpaData(r). Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), ActorUID: actoruid.New(), @@ -266,7 +266,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?referenceNumber=123", nil) ctx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{LpaID: "lpa-id"}) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), } diff --git a/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go b/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go index afe172c144..a43ed49e61 100644 --- a/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go +++ b/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go @@ -12,7 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -75,7 +75,7 @@ func TestPostEnterReferenceNumberOptOut(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -108,7 +108,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(sharecode.Data{}, expectedError) + Return(sharecodedata.Data{}, expectedError) return shareCodeStore }, @@ -119,7 +119,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id")}, nil) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id")}, nil) return shareCodeStore }, @@ -169,7 +169,7 @@ func TestPostEnterReferenceNumberOptOutOnShareCodeStoreNotFoundError(t *testing. shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) err := EnterReferenceNumberOptOut(template.Execute, shareCodeStore, nil)(testAppData, w, r) diff --git a/internal/attorney/attorneypage/enter_reference_number_test.go b/internal/attorney/attorneypage/enter_reference_number_test.go index 20a1c7fbb9..6843c17a41 100644 --- a/internal/attorney/attorneypage/enter_reference_number_test.go +++ b/internal/attorney/attorneypage/enter_reference_number_test.go @@ -15,7 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -73,27 +73,27 @@ func TestGetEnterReferenceNumberOnTemplateError(t *testing.T) { func TestPostEnterReferenceNumber(t *testing.T) { testcases := map[string]struct { - shareCode sharecode.Data + shareCode sharecodedata.Data session *sesh.LoginSession isReplacement bool isTrustCorporation bool }{ "attorney": { - shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID}, + shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, }, "replacement": { - shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true}, + shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, isReplacement: true, }, "trust corporation": { - shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsTrustCorporation: true}, + shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsTrustCorporation: true}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, isTrustCorporation: true, }, "replacement trust corporation": { - shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true, IsTrustCorporation: true}, + shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true, IsTrustCorporation: true}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, isReplacement: true, isTrustCorporation: true, @@ -141,7 +141,7 @@ func TestPostEnterReferenceNumber(t *testing.T) { } func TestPostEnterReferenceNumberWhenConditionalCheckFailed(t *testing.T) { - shareCode := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} + shareCode := sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} form := url.Values{ "reference-number": {"abcdef123456"}, @@ -187,7 +187,7 @@ func TestPostEnterReferenceNumberOnDonorStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) err := EnterReferenceNumber(nil, shareCodeStore, nil, nil)(testAppData, w, r) @@ -220,7 +220,7 @@ func TestPostEnterReferenceNumberOnShareCodeStoreNotFoundError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) err := EnterReferenceNumber(template.Execute, shareCodeStore, nil, nil)(testAppData, w, r) @@ -242,7 +242,7 @@ func TestPostEnterReferenceNumberOnSessionGetError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -266,7 +266,7 @@ func TestPostEnterReferenceNumberOnAttorneyStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) attorneyStore := newMockAttorneyStore(t) attorneyStore.EXPECT(). diff --git a/internal/attorney/attorneypage/mock_AttorneyStore_test.go b/internal/attorney/attorneypage/mock_AttorneyStore_test.go index 4e7a4ce383..06ff6b1b4e 100644 --- a/internal/attorney/attorneypage/mock_AttorneyStore_test.go +++ b/internal/attorney/attorneypage/mock_AttorneyStore_test.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockAttorneyStore is an autogenerated mock type for the AttorneyStore type @@ -26,7 +26,7 @@ func (_m *mockAttorneyStore) EXPECT() *mockAttorneyStore_Expecter { } // Create provides a mock function with given fields: ctx, shareCode, email -func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecode.Data, email string) (*attorneydata.Provided, error) { +func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*attorneydata.Provided, error) { ret := _m.Called(ctx, shareCode, email) if len(ret) == 0 { @@ -35,10 +35,10 @@ func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecode.Dat var r0 *attorneydata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) (*attorneydata.Provided, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data, string) (*attorneydata.Provided, error)); ok { return rf(ctx, shareCode, email) } - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) *attorneydata.Provided); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data, string) *attorneydata.Provided); ok { r0 = rf(ctx, shareCode, email) } else { if ret.Get(0) != nil { @@ -46,7 +46,7 @@ func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecode.Dat } } - if rf, ok := ret.Get(1).(func(context.Context, sharecode.Data, string) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sharecodedata.Data, string) error); ok { r1 = rf(ctx, shareCode, email) } else { r1 = ret.Error(1) @@ -62,15 +62,15 @@ type mockAttorneyStore_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.Data +// - shareCode sharecodedata.Data // - email string func (_e *mockAttorneyStore_Expecter) Create(ctx interface{}, shareCode interface{}, email interface{}) *mockAttorneyStore_Create_Call { return &mockAttorneyStore_Create_Call{Call: _e.mock.On("Create", ctx, shareCode, email)} } -func (_c *mockAttorneyStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecode.Data, email string)) *mockAttorneyStore_Create_Call { +func (_c *mockAttorneyStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecodedata.Data, email string)) *mockAttorneyStore_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.Data), args[2].(string)) + run(args[0].(context.Context), args[1].(sharecodedata.Data), args[2].(string)) }) return _c } @@ -80,7 +80,7 @@ func (_c *mockAttorneyStore_Create_Call) Return(_a0 *attorneydata.Provided, _a1 return _c } -func (_c *mockAttorneyStore_Create_Call) RunAndReturn(run func(context.Context, sharecode.Data, string) (*attorneydata.Provided, error)) *mockAttorneyStore_Create_Call { +func (_c *mockAttorneyStore_Create_Call) RunAndReturn(run func(context.Context, sharecodedata.Data, string) (*attorneydata.Provided, error)) *mockAttorneyStore_Create_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/mock_ShareCodeStore_test.go b/internal/attorney/attorneypage/mock_ShareCodeStore_test.go index 6da566168a..3102012f77 100644 --- a/internal/attorney/attorneypage/mock_ShareCodeStore_test.go +++ b/internal/attorney/attorneypage/mock_ShareCodeStore_test.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockShareCodeStore is an autogenerated mock type for the ShareCodeStore type @@ -26,7 +26,7 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Delete provides a mock function with given fields: ctx, shareCode -func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Data) error { +func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecodedata.Data) error { ret := _m.Called(ctx, shareCode) if len(ret) == 0 { @@ -34,7 +34,7 @@ func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Da } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data) error); ok { r0 = rf(ctx, shareCode) } else { r0 = ret.Error(0) @@ -50,14 +50,14 @@ type mockShareCodeStore_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.Data +// - shareCode sharecodedata.Data func (_e *mockShareCodeStore_Expecter) Delete(ctx interface{}, shareCode interface{}) *mockShareCodeStore_Delete_Call { return &mockShareCodeStore_Delete_Call{Call: _e.mock.On("Delete", ctx, shareCode)} } -func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecode.Data)) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecodedata.Data)) *mockShareCodeStore_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.Data)) + run(args[0].(context.Context), args[1].(sharecodedata.Data)) }) return _c } @@ -67,28 +67,28 @@ func (_c *mockShareCodeStore_Delete_Call) Return(_a0 error) *mockShareCodeStore_ return _c } -func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecodedata.Data) error) *mockShareCodeStore_Delete_Call { _c.Call.Return(run) return _c } // Get provides a mock function with given fields: ctx, actorType, shareCode -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) { ret := _m.Called(ctx, actorType, shareCode) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.Data + var r0 sharecodedata.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecode.Data, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecodedata.Data, error)); ok { return rf(ctx, actorType, shareCode) } - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecode.Data); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecodedata.Data); ok { r0 = rf(ctx, actorType, shareCode) } else { - r0 = ret.Get(0).(sharecode.Data) + r0 = ret.Get(0).(sharecodedata.Data) } if rf, ok := ret.Get(1).(func(context.Context, actor.Type, string) error); ok { @@ -120,18 +120,18 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecodedata.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecodedata.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, actorType, shareCode, data -func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error { +func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error { ret := _m.Called(ctx, actorType, shareCode, data) if len(ret) == 0 { @@ -139,7 +139,7 @@ func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, sha } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string, sharecodedata.Data) error); ok { r0 = rf(ctx, actorType, shareCode, data) } else { r0 = ret.Error(0) @@ -157,14 +157,14 @@ type mockShareCodeStore_Put_Call struct { // - ctx context.Context // - actorType actor.Type // - shareCode string -// - data sharecode.Data +// - data sharecodedata.Data func (_e *mockShareCodeStore_Expecter) Put(ctx interface{}, actorType interface{}, shareCode interface{}, data interface{}) *mockShareCodeStore_Put_Call { return &mockShareCodeStore_Put_Call{Call: _e.mock.On("Put", ctx, actorType, shareCode, data)} } -func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data)) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data)) *mockShareCodeStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(actor.Type), args[2].(string), args[3].(sharecode.Data)) + run(args[0].(context.Context), args[1].(actor.Type), args[2].(string), args[3].(sharecodedata.Data)) }) return _c } @@ -174,7 +174,7 @@ func (_c *mockShareCodeStore_Put_Call) Return(_a0 error) *mockShareCodeStore_Put return _c } -func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, actor.Type, string, sharecode.Data) error) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, actor.Type, string, sharecodedata.Data) error) *mockShareCodeStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/register.go b/internal/attorney/attorneypage/register.go index 2509479be0..95db21cd26 100644 --- a/internal/attorney/attorneypage/register.go +++ b/internal/attorney/attorneypage/register.go @@ -20,7 +20,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) type Localizer interface { @@ -57,13 +57,13 @@ type OneLoginClient interface { } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) - Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error - Delete(ctx context.Context, shareCode sharecode.Data) error + Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) + Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error + Delete(ctx context.Context, shareCode sharecodedata.Data) error } type AttorneyStore interface { - Create(ctx context.Context, shareCode sharecode.Data, email string) (*attorneydata.Provided, error) + Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*attorneydata.Provided, error) Get(ctx context.Context) (*attorneydata.Provided, error) Put(ctx context.Context, attorney *attorneydata.Provided) error Delete(ctx context.Context) error diff --git a/internal/attorney/store.go b/internal/attorney/store.go index 27b882913e..67461724f7 100644 --- a/internal/attorney/store.go +++ b/internal/attorney/store.go @@ -12,7 +12,7 @@ import ( "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/dynamo" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) type DynamoClient interface { @@ -44,7 +44,7 @@ func NewStore(dynamoClient DynamoClient) *Store { return &Store{dynamoClient: dynamoClient, now: time.Now} } -func (s *Store) Create(ctx context.Context, shareCode sharecode.Data, email string) (*attorneydata.Provided, error) { +func (s *Store) Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*attorneydata.Provided, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err diff --git a/internal/attorney/store_test.go b/internal/attorney/store_test.go index 1bffc13b18..37411b7d3f 100644 --- a/internal/attorney/store_test.go +++ b/internal/attorney/store_test.go @@ -13,7 +13,7 @@ import ( "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/dynamo" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -45,7 +45,7 @@ func TestAttorneyStoreCreate(t *testing.T) { Email: "a@example.com", } - shareCode := sharecode.Data{ + shareCode := sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.AttorneyShareKey("123")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), ActorUID: uid, @@ -93,7 +93,7 @@ func TestAttorneyStoreCreateWhenSessionMissing(t *testing.T) { attorneyStore := &Store{dynamoClient: nil, now: nil} - _, err := attorneyStore.Create(ctx, sharecode.Data{}, "") + _, err := attorneyStore.Create(ctx, sharecodedata.Data{}, "") assert.Equal(t, appcontext.SessionMissingError{}, err) } @@ -109,7 +109,7 @@ func TestAttorneyStoreCreateWhenSessionMissingRequiredData(t *testing.T) { attorneyStore := &Store{} - _, err := attorneyStore.Create(ctx, sharecode.Data{}, "") + _, err := attorneyStore.Create(ctx, sharecodedata.Data{}, "") assert.NotNil(t, err) }) } @@ -126,7 +126,7 @@ func TestAttorneyStoreCreateWhenWriteTransactionError(t *testing.T) { attorneyStore := &Store{dynamoClient: dynamoClient, now: func() time.Time { return now }} - _, err := attorneyStore.Create(ctx, sharecode.Data{ + _, err := attorneyStore.Create(ctx, sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.AttorneyShareKey("123")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), }, "") diff --git a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go index e3b41ba386..ec89a73f30 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go @@ -15,7 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -258,7 +258,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { LpaData(r). Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), } @@ -306,7 +306,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) r, _ := http.NewRequest(http.MethodPost, "/?referenceNumber=123", nil) ctx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{LpaID: "lpa-id"}) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), } diff --git a/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go b/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go index fd07e64a9a..891b8e8f2e 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go +++ b/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go @@ -12,7 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -75,7 +75,7 @@ func TestPostEnterReferenceNumberOptOut(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -108,7 +108,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(sharecode.Data{}, expectedError) + Return(sharecodedata.Data{}, expectedError) return shareCodeStore }, @@ -119,7 +119,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id")}, nil) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id")}, nil) return shareCodeStore }, @@ -169,7 +169,7 @@ func TestPostEnterReferenceNumberOptOutOnShareCodeStoreNotFoundError(t *testing. shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) err := EnterReferenceNumberOptOut(template.Execute, shareCodeStore, nil)(testAppData, w, r) diff --git a/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go b/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go index 74be87b2cc..e839b8d53e 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go +++ b/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go @@ -16,7 +16,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -76,7 +76,7 @@ func TestPostEnterReferenceNumber(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} + shareCodeData := sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). @@ -115,7 +115,7 @@ func TestPostEnterReferenceNumberWhenConditionalCheckFailed(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} + shareCodeData := sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), mock.Anything, mock.Anything). @@ -152,7 +152,7 @@ func TestPostEnterReferenceNumberOnShareCodeStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, expectedError) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, expectedError) err := EnterReferenceNumber(nil, shareCodeStore, nil, nil)(testAppData, w, r) @@ -185,7 +185,7 @@ func TestPostEnterReferenceNumberOnShareCodeStoreNotFoundError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) err := EnterReferenceNumber(template.Execute, shareCodeStore, nil, nil)(testAppData, w, r) @@ -208,7 +208,7 @@ func TestPostEnterReferenceNumberWhenCreateError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) + Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). diff --git a/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go b/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go index e980158d02..7457dbb544 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockCertificateProviderStore is an autogenerated mock type for the CertificateProviderStore type @@ -26,7 +26,7 @@ func (_m *mockCertificateProviderStore) EXPECT() *mockCertificateProviderStore_E } // Create provides a mock function with given fields: ctx, shareCode, email -func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sharecode.Data, email string) (*certificateproviderdata.Provided, error) { +func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*certificateproviderdata.Provided, error) { ret := _m.Called(ctx, shareCode, email) if len(ret) == 0 { @@ -35,10 +35,10 @@ func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sh var r0 *certificateproviderdata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) (*certificateproviderdata.Provided, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data, string) (*certificateproviderdata.Provided, error)); ok { return rf(ctx, shareCode, email) } - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) *certificateproviderdata.Provided); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data, string) *certificateproviderdata.Provided); ok { r0 = rf(ctx, shareCode, email) } else { if ret.Get(0) != nil { @@ -46,7 +46,7 @@ func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sh } } - if rf, ok := ret.Get(1).(func(context.Context, sharecode.Data, string) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sharecodedata.Data, string) error); ok { r1 = rf(ctx, shareCode, email) } else { r1 = ret.Error(1) @@ -62,15 +62,15 @@ type mockCertificateProviderStore_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.Data +// - shareCode sharecodedata.Data // - email string func (_e *mockCertificateProviderStore_Expecter) Create(ctx interface{}, shareCode interface{}, email interface{}) *mockCertificateProviderStore_Create_Call { return &mockCertificateProviderStore_Create_Call{Call: _e.mock.On("Create", ctx, shareCode, email)} } -func (_c *mockCertificateProviderStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecode.Data, email string)) *mockCertificateProviderStore_Create_Call { +func (_c *mockCertificateProviderStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecodedata.Data, email string)) *mockCertificateProviderStore_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.Data), args[2].(string)) + run(args[0].(context.Context), args[1].(sharecodedata.Data), args[2].(string)) }) return _c } @@ -80,7 +80,7 @@ func (_c *mockCertificateProviderStore_Create_Call) Return(_a0 *certificateprovi return _c } -func (_c *mockCertificateProviderStore_Create_Call) RunAndReturn(run func(context.Context, sharecode.Data, string) (*certificateproviderdata.Provided, error)) *mockCertificateProviderStore_Create_Call { +func (_c *mockCertificateProviderStore_Create_Call) RunAndReturn(run func(context.Context, sharecodedata.Data, string) (*certificateproviderdata.Provided, error)) *mockCertificateProviderStore_Create_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go b/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go index 3aab1f0eb8..c4c6f2a619 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockShareCodeStore is an autogenerated mock type for the ShareCodeStore type @@ -26,7 +26,7 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Delete provides a mock function with given fields: ctx, shareCode -func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Data) error { +func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecodedata.Data) error { ret := _m.Called(ctx, shareCode) if len(ret) == 0 { @@ -34,7 +34,7 @@ func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Da } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data) error); ok { r0 = rf(ctx, shareCode) } else { r0 = ret.Error(0) @@ -50,14 +50,14 @@ type mockShareCodeStore_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.Data +// - shareCode sharecodedata.Data func (_e *mockShareCodeStore_Expecter) Delete(ctx interface{}, shareCode interface{}) *mockShareCodeStore_Delete_Call { return &mockShareCodeStore_Delete_Call{Call: _e.mock.On("Delete", ctx, shareCode)} } -func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecode.Data)) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecodedata.Data)) *mockShareCodeStore_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.Data)) + run(args[0].(context.Context), args[1].(sharecodedata.Data)) }) return _c } @@ -67,28 +67,28 @@ func (_c *mockShareCodeStore_Delete_Call) Return(_a0 error) *mockShareCodeStore_ return _c } -func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecodedata.Data) error) *mockShareCodeStore_Delete_Call { _c.Call.Return(run) return _c } // Get provides a mock function with given fields: ctx, actorType, shareCode -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) { ret := _m.Called(ctx, actorType, shareCode) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.Data + var r0 sharecodedata.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecode.Data, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecodedata.Data, error)); ok { return rf(ctx, actorType, shareCode) } - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecode.Data); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecodedata.Data); ok { r0 = rf(ctx, actorType, shareCode) } else { - r0 = ret.Get(0).(sharecode.Data) + r0 = ret.Get(0).(sharecodedata.Data) } if rf, ok := ret.Get(1).(func(context.Context, actor.Type, string) error); ok { @@ -120,18 +120,18 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecodedata.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecodedata.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, actorType, shareCode, shareCodeData -func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData sharecode.Data) error { +func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData sharecodedata.Data) error { ret := _m.Called(ctx, actorType, shareCode, shareCodeData) if len(ret) == 0 { @@ -139,7 +139,7 @@ func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, sha } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string, sharecodedata.Data) error); ok { r0 = rf(ctx, actorType, shareCode, shareCodeData) } else { r0 = ret.Error(0) @@ -157,14 +157,14 @@ type mockShareCodeStore_Put_Call struct { // - ctx context.Context // - actorType actor.Type // - shareCode string -// - shareCodeData sharecode.Data +// - shareCodeData sharecodedata.Data func (_e *mockShareCodeStore_Expecter) Put(ctx interface{}, actorType interface{}, shareCode interface{}, shareCodeData interface{}) *mockShareCodeStore_Put_Call { return &mockShareCodeStore_Put_Call{Call: _e.mock.On("Put", ctx, actorType, shareCode, shareCodeData)} } -func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData sharecode.Data)) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData sharecodedata.Data)) *mockShareCodeStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(actor.Type), args[2].(string), args[3].(sharecode.Data)) + run(args[0].(context.Context), args[1].(actor.Type), args[2].(string), args[3].(sharecodedata.Data)) }) return _c } @@ -174,7 +174,7 @@ func (_c *mockShareCodeStore_Put_Call) Return(_a0 error) *mockShareCodeStore_Put return _c } -func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, actor.Type, string, sharecode.Data) error) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, actor.Type, string, sharecodedata.Data) error) *mockShareCodeStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/register.go b/internal/certificateprovider/certificateproviderpage/register.go index 06c2d0d232..d6c38f114e 100644 --- a/internal/certificateprovider/certificateproviderpage/register.go +++ b/internal/certificateprovider/certificateproviderpage/register.go @@ -23,7 +23,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request, details *certificateproviderdata.Provided) error @@ -39,7 +39,7 @@ type Logger interface { } type CertificateProviderStore interface { - Create(ctx context.Context, shareCode sharecode.Data, email string) (*certificateproviderdata.Provided, error) + Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*certificateproviderdata.Provided, error) Delete(ctx context.Context) error Get(ctx context.Context) (*certificateproviderdata.Provided, error) Put(ctx context.Context, certificateProvider *certificateproviderdata.Provided) error @@ -53,9 +53,9 @@ type OneLoginClient interface { } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) - Put(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData sharecode.Data) error - Delete(ctx context.Context, shareCode sharecode.Data) error + Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) + Put(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData sharecodedata.Data) error + Delete(ctx context.Context, shareCode sharecodedata.Data) error } type Template func(io.Writer, interface{}) error diff --git a/internal/certificateprovider/store.go b/internal/certificateprovider/store.go index 765e288a21..2cf0005ad4 100644 --- a/internal/certificateprovider/store.go +++ b/internal/certificateprovider/store.go @@ -12,7 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dashboard/dashboarddata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) type DynamoClient interface { @@ -44,7 +44,7 @@ type Store struct { now func() time.Time } -func (s *Store) Create(ctx context.Context, shareCode sharecode.Data, email string) (*certificateproviderdata.Provided, error) { +func (s *Store) Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*certificateproviderdata.Provided, error) { data, err := appcontext.SessionFromContext(ctx) if err != nil { return nil, err diff --git a/internal/certificateprovider/store_test.go b/internal/certificateprovider/store_test.go index 629cd7ed7b..ad7a3a573f 100644 --- a/internal/certificateprovider/store_test.go +++ b/internal/certificateprovider/store_test.go @@ -12,7 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dashboard/dashboarddata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -22,7 +22,7 @@ func TestCertificateProviderStoreCreate(t *testing.T) { uid := actoruid.New() details := &certificateproviderdata.Provided{PK: dynamo.LpaKey("lpa-id"), SK: dynamo.CertificateProviderKey("session-id"), LpaID: "lpa-id", UpdatedAt: testNow, UID: uid, Email: "a@b.com"} - shareCode := sharecode.Data{ + shareCode := sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.CertificateProviderShareKey("share-key")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("share-key")), ActorUID: uid, @@ -59,7 +59,7 @@ func TestCertificateProviderStoreCreate(t *testing.T) { func TestCertificateProviderStoreCreateWhenSessionMissing(t *testing.T) { certificateProviderStore := &Store{dynamoClient: nil, now: nil} - _, err := certificateProviderStore.Create(ctx, sharecode.Data{}, "") + _, err := certificateProviderStore.Create(ctx, sharecodedata.Data{}, "") assert.Equal(t, appcontext.SessionMissingError{}, err) } @@ -75,7 +75,7 @@ func TestCertificateProviderStoreCreateWhenSessionMissingRequiredData(t *testing certificateProviderStore := &Store{} - _, err := certificateProviderStore.Create(ctx, sharecode.Data{}, "") + _, err := certificateProviderStore.Create(ctx, sharecodedata.Data{}, "") assert.NotNil(t, err) }) } @@ -91,7 +91,7 @@ func TestCertificateProviderStoreCreateWhenWriteTransactionError(t *testing.T) { certificateProviderStore := &Store{dynamoClient: dynamoClient, now: testNowFn} - _, err := certificateProviderStore.Create(ctx, sharecode.Data{ + _, err := certificateProviderStore.Create(ctx, sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.CertificateProviderShareKey("123")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), }, "") diff --git a/internal/donor/donorpage/check_your_lpa.go b/internal/donor/donorpage/check_your_lpa.go index 73525322e7..c39f832fac 100644 --- a/internal/donor/donorpage/check_your_lpa.go +++ b/internal/donor/donorpage/check_your_lpa.go @@ -15,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -65,7 +66,7 @@ func (n *checkYourLpaNotifier) sendPaperNotification(ctx context.Context, appDat func (n *checkYourLpaNotifier) sendOnlineNotification(ctx context.Context, appData appcontext.Data, donor *donordata.Provided, wasCompleted bool) error { if !wasCompleted { - return n.shareCodeSender.SendCertificateProviderInvite(ctx, appData, page.CertificateProviderInvite{ + return n.shareCodeSender.SendCertificateProviderInvite(ctx, appData, sharecode.CertificateProviderInvite{ LpaKey: donor.PK, LpaOwnerKey: donor.SK, LpaUID: donor.LpaUID, diff --git a/internal/donor/donorpage/check_your_lpa_test.go b/internal/donor/donorpage/check_your_lpa_test.go index e86b37b2b9..9939298c9c 100644 --- a/internal/donor/donorpage/check_your_lpa_test.go +++ b/internal/donor/donorpage/check_your_lpa_test.go @@ -14,6 +14,7 @@ import ( "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" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -140,7 +141,7 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnFirstCheck(t *testing.T) { shareCodeSender := newMockShareCodeSender(t) shareCodeSender.EXPECT(). - SendCertificateProviderInvite(r.Context(), testAppData, page.CertificateProviderInvite{ + SendCertificateProviderInvite(r.Context(), testAppData, sharecode.CertificateProviderInvite{ CertificateProviderUID: provided.CertificateProvider.UID, CertificateProviderFullName: provided.CertificateProvider.FullName(), CertificateProviderEmail: provided.CertificateProvider.Email, diff --git a/internal/donor/donorpage/enter_access_code_test.go b/internal/donor/donorpage/enter_access_code_test.go index 1f01eac992..67eec789e1 100644 --- a/internal/donor/donorpage/enter_access_code_test.go +++ b/internal/donor/donorpage/enter_access_code_test.go @@ -11,7 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -68,7 +68,7 @@ func TestPostEnterAccessCode(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCode := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} + shareCode := sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -104,7 +104,7 @@ func TestPostEnterAccessCodeOnShareCodeStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeDonor, "abcdef123456"). - Return(sharecode.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) + Return(sharecodedata.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) err := EnterAccessCode(nil, nil, shareCodeStore, nil)(testAppData, w, r) resp := w.Result() @@ -136,7 +136,7 @@ func TestPostEnterAccessCodeOnShareCodeStoreNotFoundError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeDonor, "abcdef123456"). - Return(sharecode.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) err := EnterAccessCode(nil, template.Execute, shareCodeStore, nil)(testAppData, w, r) resp := w.Result() @@ -157,7 +157,7 @@ func TestPostEnterAccessCodeOnDonorStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeDonor, "abcdef123456"). - Return(sharecode.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) + Return(sharecodedata.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) donorStore := newMockDonorStore(t) donorStore.EXPECT(). diff --git a/internal/donor/donorpage/mock_DonorStore_test.go b/internal/donor/donorpage/mock_DonorStore_test.go index 34a1b59ed4..e4ef36a430 100644 --- a/internal/donor/donorpage/mock_DonorStore_test.go +++ b/internal/donor/donorpage/mock_DonorStore_test.go @@ -8,7 +8,7 @@ import ( donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockDonorStore is an autogenerated mock type for the DonorStore type @@ -187,7 +187,7 @@ func (_c *mockDonorStore_Latest_Call) RunAndReturn(run func(context.Context) (*d } // Link provides a mock function with given fields: ctx, data, donorEmail -func (_m *mockDonorStore) Link(ctx context.Context, data sharecode.Data, donorEmail string) error { +func (_m *mockDonorStore) Link(ctx context.Context, data sharecodedata.Data, donorEmail string) error { ret := _m.Called(ctx, data, donorEmail) if len(ret) == 0 { @@ -195,7 +195,7 @@ func (_m *mockDonorStore) Link(ctx context.Context, data sharecode.Data, donorEm } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data, string) error); ok { r0 = rf(ctx, data, donorEmail) } else { r0 = ret.Error(0) @@ -211,15 +211,15 @@ type mockDonorStore_Link_Call struct { // Link is a helper method to define mock.On call // - ctx context.Context -// - data sharecode.Data +// - data sharecodedata.Data // - donorEmail string func (_e *mockDonorStore_Expecter) Link(ctx interface{}, data interface{}, donorEmail interface{}) *mockDonorStore_Link_Call { return &mockDonorStore_Link_Call{Call: _e.mock.On("Link", ctx, data, donorEmail)} } -func (_c *mockDonorStore_Link_Call) Run(run func(ctx context.Context, data sharecode.Data, donorEmail string)) *mockDonorStore_Link_Call { +func (_c *mockDonorStore_Link_Call) Run(run func(ctx context.Context, data sharecodedata.Data, donorEmail string)) *mockDonorStore_Link_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.Data), args[2].(string)) + run(args[0].(context.Context), args[1].(sharecodedata.Data), args[2].(string)) }) return _c } @@ -229,7 +229,7 @@ func (_c *mockDonorStore_Link_Call) Return(_a0 error) *mockDonorStore_Link_Call return _c } -func (_c *mockDonorStore_Link_Call) RunAndReturn(run func(context.Context, sharecode.Data, string) error) *mockDonorStore_Link_Call { +func (_c *mockDonorStore_Link_Call) RunAndReturn(run func(context.Context, sharecodedata.Data, string) error) *mockDonorStore_Link_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_ShareCodeSender_test.go b/internal/donor/donorpage/mock_ShareCodeSender_test.go index 10a7431b4d..d76b143740 100644 --- a/internal/donor/donorpage/mock_ShareCodeSender_test.go +++ b/internal/donor/donorpage/mock_ShareCodeSender_test.go @@ -11,7 +11,7 @@ import ( mock "github.com/stretchr/testify/mock" - page "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" ) // mockShareCodeSender is an autogenerated mock type for the ShareCodeSender type @@ -28,7 +28,7 @@ func (_m *mockShareCodeSender) EXPECT() *mockShareCodeSender_Expecter { } // SendCertificateProviderInvite provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockShareCodeSender) SendCertificateProviderInvite(_a0 context.Context, _a1 appcontext.Data, _a2 page.CertificateProviderInvite) error { +func (_m *mockShareCodeSender) SendCertificateProviderInvite(_a0 context.Context, _a1 appcontext.Data, _a2 sharecode.CertificateProviderInvite) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -36,7 +36,7 @@ func (_m *mockShareCodeSender) SendCertificateProviderInvite(_a0 context.Context } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, page.CertificateProviderInvite) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, sharecode.CertificateProviderInvite) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -53,14 +53,14 @@ type mockShareCodeSender_SendCertificateProviderInvite_Call struct { // SendCertificateProviderInvite is a helper method to define mock.On call // - _a0 context.Context // - _a1 appcontext.Data -// - _a2 page.CertificateProviderInvite +// - _a2 sharecode.CertificateProviderInvite func (_e *mockShareCodeSender_Expecter) SendCertificateProviderInvite(_a0 interface{}, _a1 interface{}, _a2 interface{}) *mockShareCodeSender_SendCertificateProviderInvite_Call { return &mockShareCodeSender_SendCertificateProviderInvite_Call{Call: _e.mock.On("SendCertificateProviderInvite", _a0, _a1, _a2)} } -func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 page.CertificateProviderInvite)) *mockShareCodeSender_SendCertificateProviderInvite_Call { +func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 sharecode.CertificateProviderInvite)) *mockShareCodeSender_SendCertificateProviderInvite_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(page.CertificateProviderInvite)) + run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(sharecode.CertificateProviderInvite)) }) return _c } @@ -70,7 +70,7 @@ func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) Return(_a0 err return _c } -func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) RunAndReturn(run func(context.Context, appcontext.Data, page.CertificateProviderInvite) error) *mockShareCodeSender_SendCertificateProviderInvite_Call { +func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) RunAndReturn(run func(context.Context, appcontext.Data, sharecode.CertificateProviderInvite) error) *mockShareCodeSender_SendCertificateProviderInvite_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_ShareCodeStore_test.go b/internal/donor/donorpage/mock_ShareCodeStore_test.go index 331a5f1907..fe7169030b 100644 --- a/internal/donor/donorpage/mock_ShareCodeStore_test.go +++ b/internal/donor/donorpage/mock_ShareCodeStore_test.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockShareCodeStore is an autogenerated mock type for the ShareCodeStore type @@ -26,22 +26,22 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Get provides a mock function with given fields: ctx, actorType, code -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, code string) (sharecode.Data, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, code string) (sharecodedata.Data, error) { ret := _m.Called(ctx, actorType, code) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.Data + var r0 sharecodedata.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecode.Data, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecodedata.Data, error)); ok { return rf(ctx, actorType, code) } - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecode.Data); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecodedata.Data); ok { r0 = rf(ctx, actorType, code) } else { - r0 = ret.Get(0).(sharecode.Data) + r0 = ret.Get(0).(sharecodedata.Data) } if rf, ok := ret.Get(1).(func(context.Context, actor.Type, string) error); ok { @@ -73,12 +73,12 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecodedata.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecodedata.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/register.go b/internal/donor/donorpage/register.go index 58a155111f..45cc21c23a 100644 --- a/internal/donor/donorpage/register.go +++ b/internal/donor/donorpage/register.go @@ -26,6 +26,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" ) @@ -49,7 +50,7 @@ type DonorStore interface { Latest(ctx context.Context) (*donordata.Provided, error) Put(ctx context.Context, donor *donordata.Provided) error Delete(ctx context.Context) error - Link(ctx context.Context, data sharecode.Data, donorEmail string) error + Link(ctx context.Context, data sharecodedata.Data, donorEmail string) error } type GetDonorStore interface { @@ -80,7 +81,7 @@ type AddressClient interface { } type ShareCodeSender interface { - SendCertificateProviderInvite(context.Context, appcontext.Data, page.CertificateProviderInvite) error + SendCertificateProviderInvite(context.Context, appcontext.Data, sharecode.CertificateProviderInvite) error SendCertificateProviderPrompt(context.Context, appcontext.Data, *donordata.Provided) error } @@ -153,7 +154,7 @@ type LpaStoreClient interface { } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, code string) (sharecode.Data, error) + Get(ctx context.Context, actorType actor.Type, code string) (sharecodedata.Data, error) } type ErrorHandler func(http.ResponseWriter, *http.Request, error) diff --git a/internal/donor/store.go b/internal/donor/store.go index 3be9d180cd..e3c03cd870 100644 --- a/internal/donor/store.go +++ b/internal/donor/store.go @@ -18,7 +18,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" ) @@ -162,7 +162,7 @@ type lpaReference struct { // for the organisation ID that holds the Lpa data; // 2. an lpaLink which allows // the Lpa to be shown on the donor's dashboard. -func (s *donorStore) Link(ctx context.Context, shareCode sharecode.Data, donorEmail string) error { +func (s *donorStore) Link(ctx context.Context, shareCode sharecodedata.Data, donorEmail string) error { organisationKey, ok := shareCode.LpaOwnerKey.Organisation() if !ok { return errors.New("donorStore.Link can only be used with organisations") @@ -400,7 +400,7 @@ func (s *donorStore) Delete(ctx context.Context) error { return s.dynamoClient.DeleteKeys(ctx, keys) } -func (s *donorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.Data) error { +func (s *donorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecodedata.Data) error { organisationKey, ok := shareCodeData.LpaOwnerKey.Organisation() if !ok { return errors.New("donorStore.DeleteDonorAccess can only be used with organisations") diff --git a/internal/donor/store_test.go b/internal/donor/store_test.go index 24567d8227..cef48c5741 100644 --- a/internal/donor/store_test.go +++ b/internal/donor/store_test.go @@ -20,7 +20,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/mitchellh/hashstructure/v2" "github.com/stretchr/testify/assert" @@ -515,7 +515,7 @@ func TestDonorStoreLink(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "session-id"}) - shareCode := sharecode.Data{ + shareCode := sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), } @@ -536,7 +536,7 @@ func TestDonorStoreLink(t *testing.T) { }, }, Puts: []any{ - sharecode.Data{ + sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaLinkedTo: "a@example.com", @@ -563,14 +563,14 @@ func TestDonorStoreLink(t *testing.T) { func TestDonorStoreLinkWithDonor(t *testing.T) { donorStore := &donorStore{} - err := donorStore.Link(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}, "a@example.com") + err := donorStore.Link(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}, "a@example.com") assert.Error(t, err) } func TestDonorStoreLinkWithSessionMissing(t *testing.T) { donorStore := &donorStore{} - err := donorStore.Link(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") + err := donorStore.Link(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") assert.Equal(t, appcontext.SessionMissingError{}, err) } @@ -578,7 +578,7 @@ func TestDonorStoreLinkWithSessionIDMissing(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{}) donorStore := &donorStore{} - err := donorStore.Link(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") + err := donorStore.Link(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") assert.Error(t, err) } @@ -593,7 +593,7 @@ func TestDonorStoreLinkWhenDonorLinkAlreadyExists(t *testing.T) { err := donorStore.Link( ctx, - sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, + sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com", ) @@ -618,7 +618,7 @@ func TestDonorStoreLinkWhenError(t *testing.T) { for name, setupDynamoClient := range testcases { t.Run(name, func(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "an-id"}) - shareCode := sharecode.Data{ + shareCode := sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), } @@ -798,7 +798,7 @@ func TestDonorStoreDeleteDonorAccess(t *testing.T) { ctx := appcontext.ContextWithSession(context.Background(), &appcontext.Session{SessionID: "an-id", OrganisationID: "org-id"}) link := dashboarddata.LpaLink{PK: dynamo.LpaKey("lpa-id"), SK: dynamo.SubKey("donor-sub")} - shareCodeData := sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")} + shareCodeData := sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")} dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("lpa-id"), dynamo.SubKey(""), link, nil) @@ -821,7 +821,7 @@ func TestDonorStoreDeleteDonorAccess(t *testing.T) { func TestDonorStoreDeleteDonorAccessWhenDonor(t *testing.T) { donorStore := &donorStore{} - err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}) + err := donorStore.DeleteDonorAccess(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}) assert.Error(t, err) } @@ -835,7 +835,7 @@ func TestDonorStoreDeleteDonorAccessWhenSessionMissing(t *testing.T) { t.Run(name, func(t *testing.T) { donorStore := &donorStore{} - err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}) + err := donorStore.DeleteDonorAccess(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}) assert.Error(t, err) }) } @@ -846,7 +846,7 @@ func TestDonorStoreDeleteDonorAccessWhenDeleterInDifferentOrganisation(t *testin donorStore := &donorStore{} - err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := donorStore.DeleteDonorAccess(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } @@ -858,7 +858,7 @@ func TestDonorStoreDeleteDonorAccessWhenOneByPartialSKError(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient} - err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := donorStore.DeleteDonorAccess(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } @@ -873,6 +873,6 @@ func TestDonorStoreDeleteDonorAccessWhenWriteTransactionError(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient} - err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := donorStore.DeleteDonorAccess(ctx, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } diff --git a/internal/page/common.go b/internal/page/common.go index 210fb9dd7f..70317d727e 100644 --- a/internal/page/common.go +++ b/internal/page/common.go @@ -16,7 +16,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) const FormUrlEncoded = "application/x-www-form-urlencoded" @@ -29,8 +29,8 @@ type Logger interface { } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) - Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error + Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) + Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error } type NotifyClient interface { diff --git a/internal/page/fixtures/attorney.go b/internal/page/fixtures/attorney.go index 96d429e2b7..18e921fb4a 100644 --- a/internal/page/fixtures/attorney.go +++ b/internal/page/fixtures/attorney.go @@ -22,7 +22,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -30,17 +30,17 @@ import ( type DonorStore interface { Create(ctx context.Context) (*donordata.Provided, error) - Link(ctx context.Context, shareCode sharecode.Data, donorEmail string) error + Link(ctx context.Context, shareCode sharecodedata.Data, donorEmail string) error Put(ctx context.Context, donorProvidedDetails *donordata.Provided) error } type CertificateProviderStore interface { - Create(ctx context.Context, shareCode sharecode.Data, email string) (*certificateproviderdata.Provided, error) + Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*certificateproviderdata.Provided, error) Put(ctx context.Context, certificateProvider *certificateproviderdata.Provided) error } type AttorneyStore interface { - Create(ctx context.Context, shareCode sharecode.Data, email string) (*attorneydata.Provided, error) + Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*attorneydata.Provided, error) Put(ctx context.Context, attorney *attorneydata.Provided) error } @@ -133,7 +133,7 @@ func Attorney( } if isSupported { - if err := donorStore.Link(appcontext.ContextWithSession(r.Context(), createSession), sharecode.Data{ + if err := donorStore.Link(appcontext.ContextWithSession(r.Context(), createSession), sharecodedata.Data{ LpaKey: donorDetails.PK, LpaOwnerKey: donorDetails.SK, }, donorDetails.Donor.Email); err != nil { diff --git a/internal/page/fixtures/certificate_provider.go b/internal/page/fixtures/certificate_provider.go index ee1d58c4e6..c562d4261b 100644 --- a/internal/page/fixtures/certificate_provider.go +++ b/internal/page/fixtures/certificate_provider.go @@ -21,6 +21,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" ) @@ -122,7 +123,7 @@ func CertificateProvider( return err } - if err := donorStore.Link(appcontext.ContextWithSession(r.Context(), orgSession), sharecode.Data{ + if err := donorStore.Link(appcontext.ContextWithSession(r.Context(), orgSession), sharecodedata.Data{ LpaKey: donorDetails.PK, LpaOwnerKey: donorDetails.SK, }, donorDetails.Donor.Email); err != nil { @@ -253,7 +254,7 @@ func CertificateProvider( SessionID: donorSessionID, LpaID: donorDetails.LpaID, Localizer: appData.Localizer, - }, page.CertificateProviderInvite{ + }, sharecode.CertificateProviderInvite{ LpaKey: donorDetails.PK, LpaOwnerKey: donorDetails.SK, LpaUID: donorDetails.LpaUID, diff --git a/internal/page/fixtures/fixtures.go b/internal/page/fixtures/fixtures.go index f5366694e6..04154bca12 100644 --- a/internal/page/fixtures/fixtures.go +++ b/internal/page/fixtures/fixtures.go @@ -17,15 +17,15 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type ShareCodeSender interface { - SendCertificateProviderInvite(context context.Context, appData appcontext.Data, donorProvided page.CertificateProviderInvite) error + SendCertificateProviderInvite(context context.Context, appData appcontext.Data, invite sharecode.CertificateProviderInvite) error SendAttorneys(context context.Context, appData appcontext.Data, donorProvided *lpadata.Lpa) error UseTestCode(shareCode string) } @@ -221,7 +221,7 @@ func acceptCookiesConsent(w http.ResponseWriter) { func createAttorney(ctx context.Context, shareCodeStore ShareCodeStore, attorneyStore AttorneyStore, actorUID actoruid.UID, isReplacement, isTrustCorporation bool, lpaOwnerKey dynamo.LpaOwnerKeyType, email string) (*attorneydata.Provided, error) { shareCode := random.String(16) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.AttorneyShareKey(shareCode)), SK: dynamo.ShareSortKey(dynamo.MetadataKey(shareCode)), ActorUID: actorUID, @@ -245,7 +245,7 @@ func createAttorney(ctx context.Context, shareCodeStore ShareCodeStore, attorney func createCertificateProvider(ctx context.Context, shareCodeStore ShareCodeStore, certificateProviderStore CertificateProviderStore, actorUID actoruid.UID, lpaOwnerKey dynamo.LpaOwnerKeyType, email string) (*certificateproviderdata.Provided, error) { shareCode := random.String(16) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.CertificateProviderShareKey(shareCode)), SK: dynamo.ShareSortKey(dynamo.MetadataKey(shareCode)), ActorUID: actorUID, diff --git a/internal/page/fixtures/supporter.go b/internal/page/fixtures/supporter.go index 9e747024e2..4f52a8c0e9 100644 --- a/internal/page/fixtures/supporter.go +++ b/internal/page/fixtures/supporter.go @@ -22,7 +22,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -41,8 +41,8 @@ type MemberStore interface { } type ShareCodeStore interface { - Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error - PutDonor(ctx context.Context, code string, data sharecode.Data) error + Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error + PutDonor(ctx context.Context, code string, data sharecodedata.Data) error } func Supporter( @@ -148,7 +148,7 @@ func Supporter( return err } - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(org.PK), LpaKey: donor.PK, ActorUID: donor.Donor.UID, diff --git a/internal/page/mock_ShareCodeStore_test.go b/internal/page/mock_ShareCodeStore_test.go index bcf8b9356b..b3af48beaa 100644 --- a/internal/page/mock_ShareCodeStore_test.go +++ b/internal/page/mock_ShareCodeStore_test.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockShareCodeStore is an autogenerated mock type for the ShareCodeStore type @@ -26,22 +26,22 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Get provides a mock function with given fields: ctx, actorType, shareCode -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) { ret := _m.Called(ctx, actorType, shareCode) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.Data + var r0 sharecodedata.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecode.Data, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecodedata.Data, error)); ok { return rf(ctx, actorType, shareCode) } - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecode.Data); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecodedata.Data); ok { r0 = rf(ctx, actorType, shareCode) } else { - r0 = ret.Get(0).(sharecode.Data) + r0 = ret.Get(0).(sharecodedata.Data) } if rf, ok := ret.Get(1).(func(context.Context, actor.Type, string) error); ok { @@ -73,18 +73,18 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecodedata.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecodedata.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, actorType, shareCode, data -func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error { +func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error { ret := _m.Called(ctx, actorType, shareCode, data) if len(ret) == 0 { @@ -92,7 +92,7 @@ func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, sha } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string, sharecodedata.Data) error); ok { r0 = rf(ctx, actorType, shareCode, data) } else { r0 = ret.Error(0) @@ -110,14 +110,14 @@ type mockShareCodeStore_Put_Call struct { // - ctx context.Context // - actorType actor.Type // - shareCode string -// - data sharecode.Data +// - data sharecodedata.Data func (_e *mockShareCodeStore_Expecter) Put(ctx interface{}, actorType interface{}, shareCode interface{}, data interface{}) *mockShareCodeStore_Put_Call { return &mockShareCodeStore_Put_Call{Call: _e.mock.On("Put", ctx, actorType, shareCode, data)} } -func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data)) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data)) *mockShareCodeStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(actor.Type), args[2].(string), args[3].(sharecode.Data)) + run(args[0].(context.Context), args[1].(actor.Type), args[2].(string), args[3].(sharecodedata.Data)) }) return _c } @@ -127,7 +127,7 @@ func (_c *mockShareCodeStore_Put_Call) Return(_a0 error) *mockShareCodeStore_Put return _c } -func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, actor.Type, string, sharecode.Data) error) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, actor.Type, string, sharecodedata.Data) error) *mockShareCodeStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/sharecode/mock_EventClient_test.go b/internal/sharecode/mock_EventClient_test.go new file mode 100644 index 0000000000..6b896db85f --- /dev/null +++ b/internal/sharecode/mock_EventClient_test.go @@ -0,0 +1,131 @@ +// Code generated by mockery v2.42.2. DO NOT EDIT. + +package sharecode + +import ( + context "context" + + event "github.com/ministryofjustice/opg-modernising-lpa/internal/event" + mock "github.com/stretchr/testify/mock" +) + +// mockEventClient is an autogenerated mock type for the EventClient type +type mockEventClient struct { + mock.Mock +} + +type mockEventClient_Expecter struct { + mock *mock.Mock +} + +func (_m *mockEventClient) EXPECT() *mockEventClient_Expecter { + return &mockEventClient_Expecter{mock: &_m.Mock} +} + +// SendNotificationSent provides a mock function with given fields: ctx, notificationSentEvent +func (_m *mockEventClient) SendNotificationSent(ctx context.Context, notificationSentEvent event.NotificationSent) error { + ret := _m.Called(ctx, notificationSentEvent) + + if len(ret) == 0 { + panic("no return value specified for SendNotificationSent") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, event.NotificationSent) error); ok { + r0 = rf(ctx, notificationSentEvent) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockEventClient_SendNotificationSent_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendNotificationSent' +type mockEventClient_SendNotificationSent_Call struct { + *mock.Call +} + +// SendNotificationSent is a helper method to define mock.On call +// - ctx context.Context +// - notificationSentEvent event.NotificationSent +func (_e *mockEventClient_Expecter) SendNotificationSent(ctx interface{}, notificationSentEvent interface{}) *mockEventClient_SendNotificationSent_Call { + return &mockEventClient_SendNotificationSent_Call{Call: _e.mock.On("SendNotificationSent", ctx, notificationSentEvent)} +} + +func (_c *mockEventClient_SendNotificationSent_Call) Run(run func(ctx context.Context, notificationSentEvent event.NotificationSent)) *mockEventClient_SendNotificationSent_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(event.NotificationSent)) + }) + return _c +} + +func (_c *mockEventClient_SendNotificationSent_Call) Return(_a0 error) *mockEventClient_SendNotificationSent_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockEventClient_SendNotificationSent_Call) RunAndReturn(run func(context.Context, event.NotificationSent) error) *mockEventClient_SendNotificationSent_Call { + _c.Call.Return(run) + return _c +} + +// SendPaperFormRequested provides a mock function with given fields: ctx, paperFormRequestedEvent +func (_m *mockEventClient) SendPaperFormRequested(ctx context.Context, paperFormRequestedEvent event.PaperFormRequested) error { + ret := _m.Called(ctx, paperFormRequestedEvent) + + if len(ret) == 0 { + panic("no return value specified for SendPaperFormRequested") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, event.PaperFormRequested) error); ok { + r0 = rf(ctx, paperFormRequestedEvent) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockEventClient_SendPaperFormRequested_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendPaperFormRequested' +type mockEventClient_SendPaperFormRequested_Call struct { + *mock.Call +} + +// SendPaperFormRequested is a helper method to define mock.On call +// - ctx context.Context +// - paperFormRequestedEvent event.PaperFormRequested +func (_e *mockEventClient_Expecter) SendPaperFormRequested(ctx interface{}, paperFormRequestedEvent interface{}) *mockEventClient_SendPaperFormRequested_Call { + return &mockEventClient_SendPaperFormRequested_Call{Call: _e.mock.On("SendPaperFormRequested", ctx, paperFormRequestedEvent)} +} + +func (_c *mockEventClient_SendPaperFormRequested_Call) Run(run func(ctx context.Context, paperFormRequestedEvent event.PaperFormRequested)) *mockEventClient_SendPaperFormRequested_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(event.PaperFormRequested)) + }) + return _c +} + +func (_c *mockEventClient_SendPaperFormRequested_Call) Return(_a0 error) *mockEventClient_SendPaperFormRequested_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockEventClient_SendPaperFormRequested_Call) RunAndReturn(run func(context.Context, event.PaperFormRequested) error) *mockEventClient_SendPaperFormRequested_Call { + _c.Call.Return(run) + return _c +} + +// newMockEventClient creates a new instance of mockEventClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newMockEventClient(t interface { + mock.TestingT + Cleanup(func()) +}) *mockEventClient { + mock := &mockEventClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/sharecode/mock_Localizer_test.go b/internal/sharecode/mock_Localizer_test.go new file mode 100644 index 0000000000..75ed8b196a --- /dev/null +++ b/internal/sharecode/mock_Localizer_test.go @@ -0,0 +1,534 @@ +// Code generated by mockery v2.42.2. DO NOT EDIT. + +package sharecode + +import ( + date "github.com/ministryofjustice/opg-modernising-lpa/internal/date" + mock "github.com/stretchr/testify/mock" + + time "time" +) + +// mockLocalizer is an autogenerated mock type for the Localizer type +type mockLocalizer struct { + mock.Mock +} + +type mockLocalizer_Expecter struct { + mock *mock.Mock +} + +func (_m *mockLocalizer) EXPECT() *mockLocalizer_Expecter { + return &mockLocalizer_Expecter{mock: &_m.Mock} +} + +// Concat provides a mock function with given fields: list, joiner +func (_m *mockLocalizer) Concat(list []string, joiner string) string { + ret := _m.Called(list, joiner) + + if len(ret) == 0 { + panic("no return value specified for Concat") + } + + var r0 string + if rf, ok := ret.Get(0).(func([]string, string) string); ok { + r0 = rf(list, joiner) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Concat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Concat' +type mockLocalizer_Concat_Call struct { + *mock.Call +} + +// Concat is a helper method to define mock.On call +// - list []string +// - joiner string +func (_e *mockLocalizer_Expecter) Concat(list interface{}, joiner interface{}) *mockLocalizer_Concat_Call { + return &mockLocalizer_Concat_Call{Call: _e.mock.On("Concat", list, joiner)} +} + +func (_c *mockLocalizer_Concat_Call) Run(run func(list []string, joiner string)) *mockLocalizer_Concat_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]string), args[1].(string)) + }) + return _c +} + +func (_c *mockLocalizer_Concat_Call) Return(_a0 string) *mockLocalizer_Concat_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Concat_Call) RunAndReturn(run func([]string, string) string) *mockLocalizer_Concat_Call { + _c.Call.Return(run) + return _c +} + +// Count provides a mock function with given fields: messageID, count +func (_m *mockLocalizer) Count(messageID string, count int) string { + ret := _m.Called(messageID, count) + + if len(ret) == 0 { + panic("no return value specified for Count") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string, int) string); ok { + r0 = rf(messageID, count) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' +type mockLocalizer_Count_Call struct { + *mock.Call +} + +// Count is a helper method to define mock.On call +// - messageID string +// - count int +func (_e *mockLocalizer_Expecter) Count(messageID interface{}, count interface{}) *mockLocalizer_Count_Call { + return &mockLocalizer_Count_Call{Call: _e.mock.On("Count", messageID, count)} +} + +func (_c *mockLocalizer_Count_Call) Run(run func(messageID string, count int)) *mockLocalizer_Count_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(int)) + }) + return _c +} + +func (_c *mockLocalizer_Count_Call) Return(_a0 string) *mockLocalizer_Count_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Count_Call) RunAndReturn(run func(string, int) string) *mockLocalizer_Count_Call { + _c.Call.Return(run) + return _c +} + +// Format provides a mock function with given fields: messageID, data +func (_m *mockLocalizer) Format(messageID string, data map[string]interface{}) string { + ret := _m.Called(messageID, data) + + if len(ret) == 0 { + panic("no return value specified for Format") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string, map[string]interface{}) string); ok { + r0 = rf(messageID, data) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Format_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Format' +type mockLocalizer_Format_Call struct { + *mock.Call +} + +// Format is a helper method to define mock.On call +// - messageID string +// - data map[string]interface{} +func (_e *mockLocalizer_Expecter) Format(messageID interface{}, data interface{}) *mockLocalizer_Format_Call { + return &mockLocalizer_Format_Call{Call: _e.mock.On("Format", messageID, data)} +} + +func (_c *mockLocalizer_Format_Call) Run(run func(messageID string, data map[string]interface{})) *mockLocalizer_Format_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(map[string]interface{})) + }) + return _c +} + +func (_c *mockLocalizer_Format_Call) Return(_a0 string) *mockLocalizer_Format_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Format_Call) RunAndReturn(run func(string, map[string]interface{}) string) *mockLocalizer_Format_Call { + _c.Call.Return(run) + return _c +} + +// FormatCount provides a mock function with given fields: messageID, count, data +func (_m *mockLocalizer) FormatCount(messageID string, count int, data map[string]interface{}) string { + ret := _m.Called(messageID, count, data) + + if len(ret) == 0 { + panic("no return value specified for FormatCount") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string, int, map[string]interface{}) string); ok { + r0 = rf(messageID, count, data) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatCount' +type mockLocalizer_FormatCount_Call struct { + *mock.Call +} + +// FormatCount is a helper method to define mock.On call +// - messageID string +// - count int +// - data map[string]interface{} +func (_e *mockLocalizer_Expecter) FormatCount(messageID interface{}, count interface{}, data interface{}) *mockLocalizer_FormatCount_Call { + return &mockLocalizer_FormatCount_Call{Call: _e.mock.On("FormatCount", messageID, count, data)} +} + +func (_c *mockLocalizer_FormatCount_Call) Run(run func(messageID string, count int, data map[string]interface{})) *mockLocalizer_FormatCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(int), args[2].(map[string]interface{})) + }) + return _c +} + +func (_c *mockLocalizer_FormatCount_Call) Return(_a0 string) *mockLocalizer_FormatCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatCount_Call) RunAndReturn(run func(string, int, map[string]interface{}) string) *mockLocalizer_FormatCount_Call { + _c.Call.Return(run) + return _c +} + +// FormatDate provides a mock function with given fields: t +func (_m *mockLocalizer) FormatDate(t date.TimeOrDate) string { + ret := _m.Called(t) + + if len(ret) == 0 { + panic("no return value specified for FormatDate") + } + + var r0 string + if rf, ok := ret.Get(0).(func(date.TimeOrDate) string); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatDate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatDate' +type mockLocalizer_FormatDate_Call struct { + *mock.Call +} + +// FormatDate is a helper method to define mock.On call +// - t date.TimeOrDate +func (_e *mockLocalizer_Expecter) FormatDate(t interface{}) *mockLocalizer_FormatDate_Call { + return &mockLocalizer_FormatDate_Call{Call: _e.mock.On("FormatDate", t)} +} + +func (_c *mockLocalizer_FormatDate_Call) Run(run func(t date.TimeOrDate)) *mockLocalizer_FormatDate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(date.TimeOrDate)) + }) + return _c +} + +func (_c *mockLocalizer_FormatDate_Call) Return(_a0 string) *mockLocalizer_FormatDate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatDate_Call) RunAndReturn(run func(date.TimeOrDate) string) *mockLocalizer_FormatDate_Call { + _c.Call.Return(run) + return _c +} + +// FormatDateTime provides a mock function with given fields: t +func (_m *mockLocalizer) FormatDateTime(t time.Time) string { + ret := _m.Called(t) + + if len(ret) == 0 { + panic("no return value specified for FormatDateTime") + } + + var r0 string + if rf, ok := ret.Get(0).(func(time.Time) string); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatDateTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatDateTime' +type mockLocalizer_FormatDateTime_Call struct { + *mock.Call +} + +// FormatDateTime is a helper method to define mock.On call +// - t time.Time +func (_e *mockLocalizer_Expecter) FormatDateTime(t interface{}) *mockLocalizer_FormatDateTime_Call { + return &mockLocalizer_FormatDateTime_Call{Call: _e.mock.On("FormatDateTime", t)} +} + +func (_c *mockLocalizer_FormatDateTime_Call) Run(run func(t time.Time)) *mockLocalizer_FormatDateTime_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Time)) + }) + return _c +} + +func (_c *mockLocalizer_FormatDateTime_Call) Return(_a0 string) *mockLocalizer_FormatDateTime_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatDateTime_Call) RunAndReturn(run func(time.Time) string) *mockLocalizer_FormatDateTime_Call { + _c.Call.Return(run) + return _c +} + +// FormatTime provides a mock function with given fields: t +func (_m *mockLocalizer) FormatTime(t time.Time) string { + ret := _m.Called(t) + + if len(ret) == 0 { + panic("no return value specified for FormatTime") + } + + var r0 string + if rf, ok := ret.Get(0).(func(time.Time) string); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatTime' +type mockLocalizer_FormatTime_Call struct { + *mock.Call +} + +// FormatTime is a helper method to define mock.On call +// - t time.Time +func (_e *mockLocalizer_Expecter) FormatTime(t interface{}) *mockLocalizer_FormatTime_Call { + return &mockLocalizer_FormatTime_Call{Call: _e.mock.On("FormatTime", t)} +} + +func (_c *mockLocalizer_FormatTime_Call) Run(run func(t time.Time)) *mockLocalizer_FormatTime_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Time)) + }) + return _c +} + +func (_c *mockLocalizer_FormatTime_Call) Return(_a0 string) *mockLocalizer_FormatTime_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatTime_Call) RunAndReturn(run func(time.Time) string) *mockLocalizer_FormatTime_Call { + _c.Call.Return(run) + return _c +} + +// Possessive provides a mock function with given fields: s +func (_m *mockLocalizer) Possessive(s string) string { + ret := _m.Called(s) + + if len(ret) == 0 { + panic("no return value specified for Possessive") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(s) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Possessive_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Possessive' +type mockLocalizer_Possessive_Call struct { + *mock.Call +} + +// Possessive is a helper method to define mock.On call +// - s string +func (_e *mockLocalizer_Expecter) Possessive(s interface{}) *mockLocalizer_Possessive_Call { + return &mockLocalizer_Possessive_Call{Call: _e.mock.On("Possessive", s)} +} + +func (_c *mockLocalizer_Possessive_Call) Run(run func(s string)) *mockLocalizer_Possessive_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *mockLocalizer_Possessive_Call) Return(_a0 string) *mockLocalizer_Possessive_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Possessive_Call) RunAndReturn(run func(string) string) *mockLocalizer_Possessive_Call { + _c.Call.Return(run) + return _c +} + +// SetShowTranslationKeys provides a mock function with given fields: s +func (_m *mockLocalizer) SetShowTranslationKeys(s bool) { + _m.Called(s) +} + +// mockLocalizer_SetShowTranslationKeys_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetShowTranslationKeys' +type mockLocalizer_SetShowTranslationKeys_Call struct { + *mock.Call +} + +// SetShowTranslationKeys is a helper method to define mock.On call +// - s bool +func (_e *mockLocalizer_Expecter) SetShowTranslationKeys(s interface{}) *mockLocalizer_SetShowTranslationKeys_Call { + return &mockLocalizer_SetShowTranslationKeys_Call{Call: _e.mock.On("SetShowTranslationKeys", s)} +} + +func (_c *mockLocalizer_SetShowTranslationKeys_Call) Run(run func(s bool)) *mockLocalizer_SetShowTranslationKeys_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *mockLocalizer_SetShowTranslationKeys_Call) Return() *mockLocalizer_SetShowTranslationKeys_Call { + _c.Call.Return() + return _c +} + +func (_c *mockLocalizer_SetShowTranslationKeys_Call) RunAndReturn(run func(bool)) *mockLocalizer_SetShowTranslationKeys_Call { + _c.Call.Return(run) + return _c +} + +// ShowTranslationKeys provides a mock function with given fields: +func (_m *mockLocalizer) ShowTranslationKeys() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ShowTranslationKeys") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// mockLocalizer_ShowTranslationKeys_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ShowTranslationKeys' +type mockLocalizer_ShowTranslationKeys_Call struct { + *mock.Call +} + +// ShowTranslationKeys is a helper method to define mock.On call +func (_e *mockLocalizer_Expecter) ShowTranslationKeys() *mockLocalizer_ShowTranslationKeys_Call { + return &mockLocalizer_ShowTranslationKeys_Call{Call: _e.mock.On("ShowTranslationKeys")} +} + +func (_c *mockLocalizer_ShowTranslationKeys_Call) Run(run func()) *mockLocalizer_ShowTranslationKeys_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *mockLocalizer_ShowTranslationKeys_Call) Return(_a0 bool) *mockLocalizer_ShowTranslationKeys_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_ShowTranslationKeys_Call) RunAndReturn(run func() bool) *mockLocalizer_ShowTranslationKeys_Call { + _c.Call.Return(run) + return _c +} + +// T provides a mock function with given fields: messageID +func (_m *mockLocalizer) T(messageID string) string { + ret := _m.Called(messageID) + + if len(ret) == 0 { + panic("no return value specified for T") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(messageID) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_T_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'T' +type mockLocalizer_T_Call struct { + *mock.Call +} + +// T is a helper method to define mock.On call +// - messageID string +func (_e *mockLocalizer_Expecter) T(messageID interface{}) *mockLocalizer_T_Call { + return &mockLocalizer_T_Call{Call: _e.mock.On("T", messageID)} +} + +func (_c *mockLocalizer_T_Call) Run(run func(messageID string)) *mockLocalizer_T_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *mockLocalizer_T_Call) Return(_a0 string) *mockLocalizer_T_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_T_Call) RunAndReturn(run func(string) string) *mockLocalizer_T_Call { + _c.Call.Return(run) + return _c +} + +// newMockLocalizer creates a new instance of mockLocalizer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newMockLocalizer(t interface { + mock.TestingT + Cleanup(func()) +}) *mockLocalizer { + mock := &mockLocalizer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/sharecode/mock_NotifyClient_test.go b/internal/sharecode/mock_NotifyClient_test.go new file mode 100644 index 0000000000..803151a2d7 --- /dev/null +++ b/internal/sharecode/mock_NotifyClient_test.go @@ -0,0 +1,135 @@ +// Code generated by mockery v2.42.2. DO NOT EDIT. + +package sharecode + +import ( + context "context" + + notify "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" + mock "github.com/stretchr/testify/mock" +) + +// mockNotifyClient is an autogenerated mock type for the NotifyClient type +type mockNotifyClient struct { + mock.Mock +} + +type mockNotifyClient_Expecter struct { + mock *mock.Mock +} + +func (_m *mockNotifyClient) EXPECT() *mockNotifyClient_Expecter { + return &mockNotifyClient_Expecter{mock: &_m.Mock} +} + +// SendActorEmail provides a mock function with given fields: _a0, to, lpaUID, email +func (_m *mockNotifyClient) SendActorEmail(_a0 context.Context, to string, lpaUID string, email notify.Email) error { + ret := _m.Called(_a0, to, lpaUID, email) + + if len(ret) == 0 { + panic("no return value specified for SendActorEmail") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, notify.Email) error); ok { + r0 = rf(_a0, to, lpaUID, email) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockNotifyClient_SendActorEmail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendActorEmail' +type mockNotifyClient_SendActorEmail_Call struct { + *mock.Call +} + +// SendActorEmail is a helper method to define mock.On call +// - _a0 context.Context +// - to string +// - lpaUID string +// - email notify.Email +func (_e *mockNotifyClient_Expecter) SendActorEmail(_a0 interface{}, to interface{}, lpaUID interface{}, email interface{}) *mockNotifyClient_SendActorEmail_Call { + return &mockNotifyClient_SendActorEmail_Call{Call: _e.mock.On("SendActorEmail", _a0, to, lpaUID, email)} +} + +func (_c *mockNotifyClient_SendActorEmail_Call) Run(run func(_a0 context.Context, to string, lpaUID string, email notify.Email)) *mockNotifyClient_SendActorEmail_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(notify.Email)) + }) + return _c +} + +func (_c *mockNotifyClient_SendActorEmail_Call) Return(_a0 error) *mockNotifyClient_SendActorEmail_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockNotifyClient_SendActorEmail_Call) RunAndReturn(run func(context.Context, string, string, notify.Email) error) *mockNotifyClient_SendActorEmail_Call { + _c.Call.Return(run) + return _c +} + +// SendActorSMS provides a mock function with given fields: _a0, to, lpaUID, sms +func (_m *mockNotifyClient) SendActorSMS(_a0 context.Context, to string, lpaUID string, sms notify.SMS) error { + ret := _m.Called(_a0, to, lpaUID, sms) + + if len(ret) == 0 { + panic("no return value specified for SendActorSMS") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, notify.SMS) error); ok { + r0 = rf(_a0, to, lpaUID, sms) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockNotifyClient_SendActorSMS_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendActorSMS' +type mockNotifyClient_SendActorSMS_Call struct { + *mock.Call +} + +// SendActorSMS is a helper method to define mock.On call +// - _a0 context.Context +// - to string +// - lpaUID string +// - sms notify.SMS +func (_e *mockNotifyClient_Expecter) SendActorSMS(_a0 interface{}, to interface{}, lpaUID interface{}, sms interface{}) *mockNotifyClient_SendActorSMS_Call { + return &mockNotifyClient_SendActorSMS_Call{Call: _e.mock.On("SendActorSMS", _a0, to, lpaUID, sms)} +} + +func (_c *mockNotifyClient_SendActorSMS_Call) Run(run func(_a0 context.Context, to string, lpaUID string, sms notify.SMS)) *mockNotifyClient_SendActorSMS_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(notify.SMS)) + }) + return _c +} + +func (_c *mockNotifyClient_SendActorSMS_Call) Return(_a0 error) *mockNotifyClient_SendActorSMS_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockNotifyClient_SendActorSMS_Call) RunAndReturn(run func(context.Context, string, string, notify.SMS) error) *mockNotifyClient_SendActorSMS_Call { + _c.Call.Return(run) + return _c +} + +// newMockNotifyClient creates a new instance of mockNotifyClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newMockNotifyClient(t interface { + mock.TestingT + Cleanup(func()) +}) *mockNotifyClient { + mock := &mockNotifyClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/sharecode/mock_ShareCodeStore_test.go b/internal/sharecode/mock_ShareCodeStore_test.go new file mode 100644 index 0000000000..c636abfd97 --- /dev/null +++ b/internal/sharecode/mock_ShareCodeStore_test.go @@ -0,0 +1,147 @@ +// Code generated by mockery v2.42.2. DO NOT EDIT. + +package sharecode + +import ( + context "context" + + actor "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" + + mock "github.com/stretchr/testify/mock" + + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" +) + +// mockShareCodeStore is an autogenerated mock type for the ShareCodeStore type +type mockShareCodeStore struct { + mock.Mock +} + +type mockShareCodeStore_Expecter struct { + mock *mock.Mock +} + +func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { + return &mockShareCodeStore_Expecter{mock: &_m.Mock} +} + +// Get provides a mock function with given fields: ctx, actorType, shareCode +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) { + ret := _m.Called(ctx, actorType, shareCode) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 sharecodedata.Data + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) (sharecodedata.Data, error)); ok { + return rf(ctx, actorType, shareCode) + } + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string) sharecodedata.Data); ok { + r0 = rf(ctx, actorType, shareCode) + } else { + r0 = ret.Get(0).(sharecodedata.Data) + } + + if rf, ok := ret.Get(1).(func(context.Context, actor.Type, string) error); ok { + r1 = rf(ctx, actorType, shareCode) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// mockShareCodeStore_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type mockShareCodeStore_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - actorType actor.Type +// - shareCode string +func (_e *mockShareCodeStore_Expecter) Get(ctx interface{}, actorType interface{}, shareCode interface{}) *mockShareCodeStore_Get_Call { + return &mockShareCodeStore_Get_Call{Call: _e.mock.On("Get", ctx, actorType, shareCode)} +} + +func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string)) *mockShareCodeStore_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(actor.Type), args[2].(string)) + }) + return _c +} + +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecodedata.Data, _a1 error) *mockShareCodeStore_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, actor.Type, string) (sharecodedata.Data, error)) *mockShareCodeStore_Get_Call { + _c.Call.Return(run) + return _c +} + +// Put provides a mock function with given fields: ctx, actorType, shareCode, data +func (_m *mockShareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error { + ret := _m.Called(ctx, actorType, shareCode, data) + + if len(ret) == 0 { + panic("no return value specified for Put") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, actor.Type, string, sharecodedata.Data) error); ok { + r0 = rf(ctx, actorType, shareCode, data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockShareCodeStore_Put_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Put' +type mockShareCodeStore_Put_Call struct { + *mock.Call +} + +// Put is a helper method to define mock.On call +// - ctx context.Context +// - actorType actor.Type +// - shareCode string +// - data sharecodedata.Data +func (_e *mockShareCodeStore_Expecter) Put(ctx interface{}, actorType interface{}, shareCode interface{}, data interface{}) *mockShareCodeStore_Put_Call { + return &mockShareCodeStore_Put_Call{Call: _e.mock.On("Put", ctx, actorType, shareCode, data)} +} + +func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data)) *mockShareCodeStore_Put_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(actor.Type), args[2].(string), args[3].(sharecodedata.Data)) + }) + return _c +} + +func (_c *mockShareCodeStore_Put_Call) Return(_a0 error) *mockShareCodeStore_Put_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, actor.Type, string, sharecodedata.Data) error) *mockShareCodeStore_Put_Call { + _c.Call.Return(run) + return _c +} + +// newMockShareCodeStore creates a new instance of mockShareCodeStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newMockShareCodeStore(t interface { + mock.TestingT + Cleanup(func()) +}) *mockShareCodeStore { + mock := &mockShareCodeStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/page/share_code.go b/internal/sharecode/sender.go similarity index 82% rename from internal/page/share_code.go rename to internal/sharecode/sender.go index ed1e19dd56..6990dcc4ad 100644 --- a/internal/page/share_code.go +++ b/internal/sharecode/sender.go @@ -1,21 +1,53 @@ -package page +package sharecode import ( "context" "fmt" + "time" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" + "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "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/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) +type Localizer interface { + Concat(list []string, joiner string) string + Count(messageID string, count int) string + Format(messageID string, data map[string]interface{}) string + FormatCount(messageID string, count int, data map[string]any) string + FormatDate(t date.TimeOrDate) string + FormatTime(t time.Time) string + FormatDateTime(t time.Time) string + Possessive(s string) string + SetShowTranslationKeys(s bool) + ShowTranslationKeys() bool + T(messageID string) string +} + +type ShareCodeStore interface { + Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) + Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error +} + +type NotifyClient interface { + SendActorEmail(context context.Context, to, lpaUID string, email notify.Email) error + SendActorSMS(context context.Context, to, lpaUID string, sms notify.SMS) error +} + +type EventClient interface { + SendNotificationSent(ctx context.Context, notificationSentEvent event.NotificationSent) error + SendPaperFormRequested(ctx context.Context, paperFormRequestedEvent event.PaperFormRequested) error +} + type ShareCodeSender struct { testCode string shareCodeStore ShareCodeStore @@ -61,12 +93,12 @@ func (s *ShareCodeSender) SendCertificateProviderInvite(ctx context.Context, app CertificateProviderFullName: invite.CertificateProviderFullName, DonorFullName: invite.DonorFullName, LpaType: localize.LowerFirst(appData.Localizer.T(invite.Type.String())), - CertificateProviderStartURL: fmt.Sprintf("%s%s", s.appPublicURL, PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("%s%s", s.appPublicURL, page.PathCertificateProviderStart), DonorFirstNames: invite.DonorFirstNames, DonorFirstNamesPossessive: appData.Localizer.Possessive(invite.DonorFirstNames), WhatLpaCovers: appData.Localizer.T(invite.Type.WhatLPACoversTransKey()), ShareCode: shareCode, - CertificateProviderOptOutURL: fmt.Sprintf("%s%s", s.appPublicURL, PathCertificateProviderEnterReferenceNumberOptOut), + CertificateProviderOptOutURL: fmt.Sprintf("%s%s", s.appPublicURL, page.PathCertificateProviderEnterReferenceNumberOptOut), }) } @@ -84,7 +116,7 @@ func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, app CertificateProviderFullName: donor.CertificateProvider.FullName(), DonorFullName: donor.Donor.FullName(), LpaType: localize.LowerFirst(appData.Localizer.T(donor.Type.String())), - CertificateProviderStartURL: fmt.Sprintf("%s%s", s.appPublicURL, PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("%s%s", s.appPublicURL, page.PathCertificateProviderStart), ShareCode: shareCode, }) } @@ -129,9 +161,9 @@ func (s *ShareCodeSender) sendOriginalAttorney(ctx context.Context, appData appc DonorFirstNamesPossessive: appData.Localizer.Possessive(lpa.Donor.FirstNames), DonorFullName: lpa.Donor.FullName(), LpaType: localize.LowerFirst(appData.Localizer.T(lpa.Type.String())), - AttorneyStartPageURL: s.appPublicURL + PathAttorneyStart.Format(), + AttorneyStartPageURL: s.appPublicURL + page.PathAttorneyStart.Format(), ShareCode: shareCode, - AttorneyOptOutURL: s.appPublicURL + PathAttorneyEnterReferenceNumberOptOut.Format(), + AttorneyOptOutURL: s.appPublicURL + page.PathAttorneyEnterReferenceNumberOptOut.Format(), }) } @@ -152,9 +184,9 @@ func (s *ShareCodeSender) sendReplacementAttorney(ctx context.Context, appData a DonorFirstNamesPossessive: appData.Localizer.Possessive(lpa.Donor.FirstNames), DonorFullName: lpa.Donor.FullName(), LpaType: localize.LowerFirst(appData.Localizer.T(lpa.Type.String())), - AttorneyStartPageURL: s.appPublicURL + PathAttorneyStart.Format(), + AttorneyStartPageURL: s.appPublicURL + page.PathAttorneyStart.Format(), ShareCode: shareCode, - AttorneyOptOutURL: s.appPublicURL + PathAttorneyEnterReferenceNumberOptOut.Format(), + AttorneyOptOutURL: s.appPublicURL + page.PathAttorneyEnterReferenceNumberOptOut.Format(), }) } @@ -179,9 +211,9 @@ func (s *ShareCodeSender) sendTrustCorporation(ctx context.Context, appData appc DonorFirstNamesPossessive: appData.Localizer.Possessive(lpa.Donor.FirstNames), DonorFullName: lpa.Donor.FullName(), LpaType: localize.LowerFirst(appData.Localizer.T(lpa.Type.String())), - AttorneyStartPageURL: fmt.Sprintf("%s%s", s.appPublicURL, PathAttorneyStart), + AttorneyStartPageURL: fmt.Sprintf("%s%s", s.appPublicURL, page.PathAttorneyStart), ShareCode: shareCode, - AttorneyOptOutURL: s.appPublicURL + PathAttorneyEnterReferenceNumberOptOut.Format(), + AttorneyOptOutURL: s.appPublicURL + page.PathAttorneyEnterReferenceNumberOptOut.Format(), }) } @@ -206,9 +238,9 @@ func (s *ShareCodeSender) sendReplacementTrustCorporation(ctx context.Context, a DonorFirstNamesPossessive: appData.Localizer.Possessive(lpa.Donor.FirstNames), DonorFullName: lpa.Donor.FullName(), LpaType: localize.LowerFirst(appData.Localizer.T(lpa.Type.String())), - AttorneyStartPageURL: fmt.Sprintf("%s%s", s.appPublicURL, PathAttorneyStart), + AttorneyStartPageURL: fmt.Sprintf("%s%s", s.appPublicURL, page.PathAttorneyStart), ShareCode: shareCode, - AttorneyOptOutURL: s.appPublicURL + PathAttorneyEnterReferenceNumberOptOut.Format(), + AttorneyOptOutURL: s.appPublicURL + page.PathAttorneyEnterReferenceNumberOptOut.Format(), }) } @@ -219,7 +251,7 @@ func (s *ShareCodeSender) createShareCode(ctx context.Context, lpaKey dynamo.Lpa s.testCode = "" } - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaKey: lpaKey, LpaOwnerKey: lpaOwnerKey, ActorUID: actorUID, diff --git a/internal/page/share_code_test.go b/internal/sharecode/sender_test.go similarity index 86% rename from internal/page/share_code_test.go rename to internal/sharecode/sender_test.go index 72f345c142..a9eb938fa2 100644 --- a/internal/page/share_code_test.go +++ b/internal/sharecode/sender_test.go @@ -1,4 +1,4 @@ -package page +package sharecode import ( "context" @@ -8,16 +8,30 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "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/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" + "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/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) +const testRandomString = "123" + +var ( + TestAppData = appcontext.Data{ + SessionID: "session-id", + LpaID: "lpa-id", + Lang: localize.En, + } + testRandomStringFn = func(int) string { return testRandomString } +) + func TestShareCodeSenderSendCertificateProviderInvite(t *testing.T) { donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ @@ -51,7 +65,7 @@ func TestShareCodeSenderSendCertificateProviderInvite(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -65,10 +79,10 @@ func TestShareCodeSenderSendCertificateProviderInvite(t *testing.T) { DonorFirstNames: "Jan", DonorFullName: "Jan Smith", LpaType: "property and affairs", - CertificateProviderStartURL: fmt.Sprintf("http://app%s", PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderStart), DonorFirstNamesPossessive: "Jan’s", WhatLpaCovers: "houses and stuff", - CertificateProviderOptOutURL: fmt.Sprintf("http://app%s", PathCertificateProviderEnterReferenceNumberOptOut), + CertificateProviderOptOutURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderEnterReferenceNumberOptOut), }). Return(nil) @@ -136,14 +150,14 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, sharecode.Data{ + Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). Once(). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -157,11 +171,11 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) DonorFirstNames: "Jan", DonorFullName: "Jan Smith", LpaType: "property and affairs", - CertificateProviderStartURL: fmt.Sprintf("http://app%s", PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderStart), ShareCode: tc.expectedTestCode, DonorFirstNamesPossessive: "Jan’s", WhatLpaCovers: "houses and stuff", - CertificateProviderOptOutURL: fmt.Sprintf("http://app%s", PathCertificateProviderEnterReferenceNumberOptOut), + CertificateProviderOptOutURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderEnterReferenceNumberOptOut), }). Once(). Return(nil) @@ -171,11 +185,11 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) DonorFirstNames: "Jan", DonorFullName: "Jan Smith", LpaType: "property and affairs", - CertificateProviderStartURL: fmt.Sprintf("http://app%s", PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderStart), ShareCode: testRandomString, DonorFirstNamesPossessive: "Jan’s", WhatLpaCovers: "houses and stuff", - CertificateProviderOptOutURL: fmt.Sprintf("http://app%s", PathCertificateProviderEnterReferenceNumberOptOut), + CertificateProviderOptOutURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderEnterReferenceNumberOptOut), }). Once(). Return(nil) @@ -312,13 +326,13 @@ func TestShareCodeSenderSendCertificateProviderPromptOnline(t *testing.T) { CertificateProviderFullName: "Joanna Jones", DonorFullName: "Jan Smith", LpaType: "property and affairs", - CertificateProviderStartURL: fmt.Sprintf("http://app%s", PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderStart), }). Return(nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -355,7 +369,7 @@ func TestShareCodeSenderSendCertificateProviderPromptPaper(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecodedata.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: actorUID, @@ -423,7 +437,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, sharecode.Data{ + Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -431,7 +445,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecodedata.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -444,7 +458,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) CertificateProviderFullName: "Joanna Jones", DonorFullName: "Jan Smith", LpaType: "property and affairs", - CertificateProviderStartURL: fmt.Sprintf("http://app%s", PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderStart), ShareCode: tc.expectedTestCode, }). Once(). @@ -454,7 +468,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) CertificateProviderFullName: "Joanna Jones", DonorFullName: "Jan Smith", LpaType: "property and affairs", - CertificateProviderStartURL: fmt.Sprintf("http://app%s", PathCertificateProviderStart), + CertificateProviderStartURL: fmt.Sprintf("http://app%s", page.PathCertificateProviderStart), ShareCode: testRandomString, }). Once(). @@ -653,25 +667,25 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeTrustCorporation, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: trustCorporationUID, IsTrustCorporation: true}). + Put(ctx, actor.TypeTrustCorporation, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: trustCorporationUID, IsTrustCorporation: true}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacementTrustCorporationUID, IsTrustCorporation: true, IsReplacementAttorney: true}). + Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacementTrustCorporationUID, IsTrustCorporation: true, IsReplacementAttorney: true}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney1UID}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney1UID}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney2UID}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney2UID}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney3UID}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney3UID}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement1UID, IsReplacementAttorney: true}). + Put(ctx, actor.TypeReplacementAttorney, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement1UID, IsReplacementAttorney: true}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement2UID, IsReplacementAttorney: true}). + Put(ctx, actor.TypeReplacementAttorney, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement2UID, IsReplacementAttorney: true}). Return(nil) notifyClient := newMockNotifyClient(t) @@ -683,8 +697,8 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { DonorFullName: "Jan Smith", DonorFirstNamesPossessive: "Jan's", LpaType: "property and affairs", - AttorneyStartPageURL: fmt.Sprintf("http://app%s", PathAttorneyStart), - AttorneyOptOutURL: fmt.Sprintf("http://app%s", PathAttorneyEnterReferenceNumberOptOut), + AttorneyStartPageURL: fmt.Sprintf("http://app%s", page.PathAttorneyStart), + AttorneyOptOutURL: fmt.Sprintf("http://app%s", page.PathAttorneyEnterReferenceNumberOptOut), }). Return(nil) notifyClient.EXPECT(). @@ -695,8 +709,8 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { DonorFullName: "Jan Smith", DonorFirstNamesPossessive: "Jan's", LpaType: "property and affairs", - AttorneyStartPageURL: fmt.Sprintf("http://app%s", PathAttorneyStart), - AttorneyOptOutURL: fmt.Sprintf("http://app%s", PathAttorneyEnterReferenceNumberOptOut), + AttorneyStartPageURL: fmt.Sprintf("http://app%s", page.PathAttorneyStart), + AttorneyOptOutURL: fmt.Sprintf("http://app%s", page.PathAttorneyEnterReferenceNumberOptOut), }). Return(nil) notifyClient.EXPECT(). @@ -707,8 +721,8 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { DonorFullName: "Jan Smith", DonorFirstNamesPossessive: "Jan's", LpaType: "property and affairs", - AttorneyStartPageURL: fmt.Sprintf("http://app%s", PathAttorneyStart), - AttorneyOptOutURL: fmt.Sprintf("http://app%s", PathAttorneyEnterReferenceNumberOptOut), + AttorneyStartPageURL: fmt.Sprintf("http://app%s", page.PathAttorneyStart), + AttorneyOptOutURL: fmt.Sprintf("http://app%s", page.PathAttorneyEnterReferenceNumberOptOut), }). Return(nil) notifyClient.EXPECT(). @@ -719,8 +733,8 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { DonorFullName: "Jan Smith", DonorFirstNamesPossessive: "Jan's", LpaType: "property and affairs", - AttorneyStartPageURL: fmt.Sprintf("http://app%s", PathAttorneyStart), - AttorneyOptOutURL: fmt.Sprintf("http://app%s", PathAttorneyEnterReferenceNumberOptOut), + AttorneyStartPageURL: fmt.Sprintf("http://app%s", page.PathAttorneyStart), + AttorneyOptOutURL: fmt.Sprintf("http://app%s", page.PathAttorneyEnterReferenceNumberOptOut), }). Return(nil) notifyClient.EXPECT(). @@ -731,8 +745,8 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { DonorFullName: "Jan Smith", DonorFirstNamesPossessive: "Jan's", LpaType: "property and affairs", - AttorneyStartPageURL: fmt.Sprintf("http://app%s", PathAttorneyStart), - AttorneyOptOutURL: fmt.Sprintf("http://app%s", PathAttorneyEnterReferenceNumberOptOut), + AttorneyStartPageURL: fmt.Sprintf("http://app%s", page.PathAttorneyStart), + AttorneyOptOutURL: fmt.Sprintf("http://app%s", page.PathAttorneyEnterReferenceNumberOptOut), }). Return(nil) @@ -790,7 +804,7 @@ func TestShareCodeSenderSendAttorneysTrustCorporationsNoEmail(t *testing.T) { ctx := context.Background() shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeTrustCorporation, testRandomString, sharecode.Data{ + Put(ctx, actor.TypeTrustCorporation, testRandomString, sharecodedata.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: uid1, @@ -798,7 +812,7 @@ func TestShareCodeSenderSendAttorneysTrustCorporationsNoEmail(t *testing.T) { }). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, sharecode.Data{ + Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, sharecodedata.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: uid2, @@ -880,10 +894,10 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, tc.expectedTestCode, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). + Put(ctx, actor.TypeAttorney, tc.expectedTestCode, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). Return(nil) notifyClient := newMockNotifyClient(t) @@ -895,8 +909,8 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) { DonorFullName: "Jan Smith", DonorFirstNamesPossessive: "Jan's", LpaType: "property and affairs", - AttorneyStartPageURL: fmt.Sprintf("http://app%s", PathAttorneyStart), - AttorneyOptOutURL: fmt.Sprintf("http://app%s", PathAttorneyEnterReferenceNumberOptOut), + AttorneyStartPageURL: fmt.Sprintf("http://app%s", page.PathAttorneyStart), + AttorneyOptOutURL: fmt.Sprintf("http://app%s", page.PathAttorneyEnterReferenceNumberOptOut), }). Return(nil) notifyClient.EXPECT(). @@ -907,8 +921,8 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) { DonorFullName: "Jan Smith", DonorFirstNamesPossessive: "Jan's", LpaType: "property and affairs", - AttorneyStartPageURL: fmt.Sprintf("http://app%s", PathAttorneyStart), - AttorneyOptOutURL: fmt.Sprintf("http://app%s", PathAttorneyEnterReferenceNumberOptOut), + AttorneyStartPageURL: fmt.Sprintf("http://app%s", page.PathAttorneyStart), + AttorneyOptOutURL: fmt.Sprintf("http://app%s", page.PathAttorneyEnterReferenceNumberOptOut), }). Return(nil) diff --git a/internal/sharecode/data.go b/internal/sharecode/sharecodedata/data.go similarity index 97% rename from internal/sharecode/data.go rename to internal/sharecode/sharecodedata/data.go index 7dc046cae1..16a8e71b40 100644 --- a/internal/sharecode/data.go +++ b/internal/sharecode/sharecodedata/data.go @@ -1,4 +1,4 @@ -package sharecode +package sharecodedata import ( "time" diff --git a/internal/sharecode/store.go b/internal/sharecode/store.go index 964788597a..aabb1a0450 100644 --- a/internal/sharecode/store.go +++ b/internal/sharecode/store.go @@ -9,6 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) type DynamoClient interface { @@ -28,8 +29,8 @@ func NewStore(dynamoClient DynamoClient) *Store { return &Store{dynamoClient: dynamoClient, now: time.Now} } -func (s *Store) Get(ctx context.Context, actorType actor.Type, shareCode string) (Data, error) { - var data Data +func (s *Store) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Data, error) { + var data sharecodedata.Data pk, err := shareCodeKey(actorType, shareCode) if err != nil { @@ -37,17 +38,17 @@ func (s *Store) Get(ctx context.Context, actorType actor.Type, shareCode string) } if err := s.dynamoClient.OneByPK(ctx, pk, &data); err != nil { - return Data{}, err + return sharecodedata.Data{}, err } if !data.LpaLinkedAt.IsZero() { - return Data{}, dynamo.NotFoundError{} + return sharecodedata.Data{}, dynamo.NotFoundError{} } return data, err } -func (s *Store) Put(ctx context.Context, actorType actor.Type, shareCode string, data Data) error { +func (s *Store) Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Data) error { pk, err := shareCodeKey(actorType, shareCode) if err != nil { return err @@ -59,7 +60,7 @@ func (s *Store) Put(ctx context.Context, actorType actor.Type, shareCode string, return s.dynamoClient.Put(ctx, data) } -func (s *Store) PutDonor(ctx context.Context, shareCode string, data Data) error { +func (s *Store) PutDonor(ctx context.Context, shareCode string, data sharecodedata.Data) error { organisationKey, ok := data.LpaOwnerKey.Organisation() if !ok { return errors.New("shareCodeStore.PutDonor can only be used by organisations") @@ -72,8 +73,8 @@ func (s *Store) PutDonor(ctx context.Context, shareCode string, data Data) error return s.dynamoClient.Put(ctx, data) } -func (s *Store) GetDonor(ctx context.Context) (Data, error) { - var data Data +func (s *Store) GetDonor(ctx context.Context) (sharecodedata.Data, error) { + var data sharecodedata.Data sessionData, err := appcontext.SessionFromContext(ctx) if err != nil { @@ -86,7 +87,7 @@ func (s *Store) GetDonor(ctx context.Context) (Data, error) { return data, err } -func (s *Store) Delete(ctx context.Context, shareCode Data) error { +func (s *Store) Delete(ctx context.Context, shareCode sharecodedata.Data) error { return s.dynamoClient.DeleteOne(ctx, shareCode.PK, shareCode.SK) } diff --git a/internal/sharecode/store_test.go b/internal/sharecode/store_test.go index e250c1ac12..fd65661fa6 100644 --- a/internal/sharecode/store_test.go +++ b/internal/sharecode/store_test.go @@ -10,6 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -63,7 +64,7 @@ func TestShareCodeStoreGet(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { ctx := context.Background() - data := Data{LpaKey: "lpa-id"} + data := sharecodedata.Data{LpaKey: "lpa-id"} dynamoClient := newMockDynamoClient(t) dynamoClient. @@ -85,13 +86,13 @@ func TestShareCodeStoreGetWhenLinked(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient. ExpectOneByPK(ctx, dynamo.ShareKey(dynamo.DonorShareKey("123")), - Data{LpaLinkedAt: time.Now()}, nil) + sharecodedata.Data{LpaLinkedAt: time.Now()}, nil) shareCodeStore := &Store{dynamoClient: dynamoClient} result, err := shareCodeStore.Get(ctx, actor.TypeDonor, "123") assert.Equal(t, dynamo.NotFoundError{}, err) - assert.Equal(t, Data{}, result) + assert.Equal(t, sharecodedata.Data{}, result) } func TestShareCodeStoreGetForBadActorType(t *testing.T) { @@ -104,7 +105,7 @@ func TestShareCodeStoreGetForBadActorType(t *testing.T) { func TestShareCodeStoreGetOnError(t *testing.T) { ctx := context.Background() - data := Data{LpaKey: "lpa-id"} + data := sharecodedata.Data{LpaKey: "lpa-id"} dynamoClient := newMockDynamoClient(t) dynamoClient. @@ -139,7 +140,7 @@ func TestShareCodeStorePut(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { ctx := context.Background() - data := Data{PK: tc.pk, SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), LpaKey: "lpa-id"} + data := sharecodedata.Data{PK: tc.pk, SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), LpaKey: "lpa-id"} dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). @@ -158,7 +159,7 @@ func TestShareCodeStorePutForBadActorType(t *testing.T) { ctx := context.Background() shareCodeStore := &Store{} - err := shareCodeStore.Put(ctx, actor.TypePersonToNotify, "123", Data{}) + err := shareCodeStore.Put(ctx, actor.TypePersonToNotify, "123", sharecodedata.Data{}) assert.NotNil(t, err) } @@ -172,7 +173,7 @@ func TestShareCodeStorePutOnError(t *testing.T) { shareCodeStore := &Store{dynamoClient: dynamoClient} - err := shareCodeStore.Put(ctx, actor.TypeAttorney, "123", Data{LpaKey: "123"}) + err := shareCodeStore.Put(ctx, actor.TypeAttorney, "123", sharecodedata.Data{LpaKey: "123"}) assert.Equal(t, expectedError, err) } @@ -189,7 +190,7 @@ func TestShareCodeStoreGetDonor(t *testing.T) { OrganisationID: "org-id", LpaID: "lpa-id", }) - data := Data{LpaKey: dynamo.LpaKey("lpa-id")} + data := sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id")} dynamoClient := newMockDynamoClient(t) dynamoClient. @@ -216,7 +217,7 @@ func TestShareCodeStorePutDonor(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Put(ctx, Data{ + Put(ctx, sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.DonorShareKey("123")), SK: dynamo.ShareSortKey(dynamo.DonorInviteKey(dynamo.OrganisationKey("org-id"), dynamo.LpaKey("lpa-id"))), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), @@ -227,7 +228,7 @@ func TestShareCodeStorePutDonor(t *testing.T) { shareCodeStore := &Store{dynamoClient: dynamoClient, now: testNowFn} - err := shareCodeStore.PutDonor(ctx, "123", Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := shareCodeStore.PutDonor(ctx, "123", sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Nil(t, err) } @@ -236,7 +237,7 @@ func TestShareCodeStorePutDonorWhenDonor(t *testing.T) { shareCodeStore := &Store{} - err := shareCodeStore.PutDonor(ctx, "123", Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := shareCodeStore.PutDonor(ctx, "123", sharecodedata.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } @@ -252,7 +253,7 @@ func TestShareCodeStoreDelete(t *testing.T) { shareCodeStore := &Store{dynamoClient: dynamoClient} - err := shareCodeStore.Delete(ctx, Data{LpaKey: "123", PK: pk, SK: sk}) + err := shareCodeStore.Delete(ctx, sharecodedata.Data{LpaKey: "123", PK: pk, SK: sk}) assert.Nil(t, err) } @@ -266,7 +267,7 @@ func TestShareCodeStoreDeleteOnError(t *testing.T) { shareCodeStore := &Store{dynamoClient: dynamoClient} - err := shareCodeStore.Delete(ctx, Data{}) + err := shareCodeStore.Delete(ctx, sharecodedata.Data{}) assert.Equal(t, expectedError, err) } diff --git a/internal/supporter/supporterpage/donor_access.go b/internal/supporter/supporterpage/donor_access.go index 42ce8cc4d4..0e7d040060 100644 --- a/internal/supporter/supporterpage/donor_access.go +++ b/internal/supporter/supporterpage/donor_access.go @@ -13,7 +13,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -24,7 +24,7 @@ type donorAccessData struct { Errors validation.List Form *donorAccessForm Donor *donordata.Provided - ShareCode *sharecode.Data + ShareCode *sharecodedata.Data } func DonorAccess(logger Logger, tmpl template.Template, donorStore DonorStore, shareCodeStore ShareCodeStore, notifyClient NotifyClient, appPublicURL string, randomString func(int) string) Handler { @@ -91,7 +91,7 @@ func DonorAccess(logger Logger, tmpl template.Template, donorStore DonorStore, s } shareCode := randomString(12) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(organisation.PK), LpaKey: dynamo.LpaKey(appData.LpaID), ActorUID: donor.Donor.UID, diff --git a/internal/supporter/supporterpage/donor_access_test.go b/internal/supporter/supporterpage/donor_access_test.go index 434f7fbbae..545007fc5d 100644 --- a/internal/supporter/supporterpage/donor_access_test.go +++ b/internal/supporter/supporterpage/donor_access_test.go @@ -14,7 +14,7 @@ import ( "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" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -25,7 +25,7 @@ import ( func TestGetDonorAccess(t *testing.T) { donor := &donordata.Provided{Donor: donordata.Donor{Email: "x"}} - shareCodeData := sharecode.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1"))} + shareCodeData := sharecodedata.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1"))} testcases := map[string]struct { data *donorAccessData @@ -103,7 +103,7 @@ func TestGetDonorAccessWhenShareCodeStoreErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(sharecode.Data{}, expectedError) + Return(sharecodedata.Data{}, expectedError) err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, nil, nil) assert.Equal(t, expectedError, err) @@ -135,9 +135,9 @@ func TestPostDonorAccess(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(sharecode.Data{}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{}, dynamo.NotFoundError{}) shareCodeStore.EXPECT(). - PutDonor(r.Context(), testRandomString, sharecode.Data{ + PutDonor(r.Context(), testRandomString, sharecodedata.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id"), ActorUID: donorUID, @@ -189,7 +189,7 @@ func TestPostDonorAccessWhenDonorUpdateErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(sharecode.Data{}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{}, dynamo.NotFoundError{}) err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, &supporterdata.Organisation{ID: "org-id"}, nil) assert.Equal(t, expectedError, err) @@ -210,7 +210,7 @@ func TestPostDonorAccessWhenShareCodeStoreErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(sharecode.Data{}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{}, dynamo.NotFoundError{}) shareCodeStore.EXPECT(). PutDonor(r.Context(), mock.Anything, mock.Anything). Return(expectedError) @@ -234,7 +234,7 @@ func TestPostDonorAccessWhenNotifyErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(sharecode.Data{}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{}, dynamo.NotFoundError{}) shareCodeStore.EXPECT(). PutDonor(r.Context(), mock.Anything, mock.Anything). Return(nil) @@ -269,7 +269,7 @@ func TestPostDonorAccessWhenValidationError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(sharecode.Data{}, dynamo.NotFoundError{}) + Return(sharecodedata.Data{}, dynamo.NotFoundError{}) template := newMockTemplate(t) template.EXPECT(). @@ -292,7 +292,7 @@ func TestPostDonorAccessRecall(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := sharecode.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} + shareCodeData := sharecodedata.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} donorStore := newMockDonorStore(t) donorStore.EXPECT(). @@ -322,7 +322,7 @@ func TestPostDonorAccessRecallWhenDeleteErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := sharecode.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} + shareCodeData := sharecodedata.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} donorStore := newMockDonorStore(t) donorStore.EXPECT(). @@ -390,7 +390,7 @@ func TestPostDonorAccessRemove(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), SK: dynamo.ShareSortKey(dynamo.DonorInviteKey("donor-session-id", "lpa-id")), InviteSentTo: "email@example.com", @@ -431,7 +431,7 @@ func TestPostDonorAccessRemoveWhenDonorHasPaid(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := sharecode.Data{ + shareCodeData := sharecodedata.Data{ PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), SK: dynamo.ShareSortKey(dynamo.DonorInviteKey("donor-session-id", "lpa-id")), InviteSentTo: "email@example.com", @@ -467,7 +467,7 @@ func TestPostDonorAccessRemoveWhenDeleteLinkError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(mock.Anything). - Return(sharecode.Data{}, nil) + Return(sharecodedata.Data{}, nil) donor := &donordata.Provided{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} diff --git a/internal/supporter/supporterpage/mock_DonorStore_test.go b/internal/supporter/supporterpage/mock_DonorStore_test.go index e0d5bb5fc3..9d935f9a1d 100644 --- a/internal/supporter/supporterpage/mock_DonorStore_test.go +++ b/internal/supporter/supporterpage/mock_DonorStore_test.go @@ -10,7 +10,7 @@ import ( mock "github.com/stretchr/testify/mock" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" ) // mockDonorStore is an autogenerated mock type for the DonorStore type @@ -27,7 +27,7 @@ func (_m *mockDonorStore) EXPECT() *mockDonorStore_Expecter { } // DeleteDonorAccess provides a mock function with given fields: ctx, shareCodeData -func (_m *mockDonorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.Data) error { +func (_m *mockDonorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecodedata.Data) error { ret := _m.Called(ctx, shareCodeData) if len(ret) == 0 { @@ -35,7 +35,7 @@ func (_m *mockDonorStore) DeleteDonorAccess(ctx context.Context, shareCodeData s } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data) error); ok { r0 = rf(ctx, shareCodeData) } else { r0 = ret.Error(0) @@ -51,14 +51,14 @@ type mockDonorStore_DeleteDonorAccess_Call struct { // DeleteDonorAccess is a helper method to define mock.On call // - ctx context.Context -// - shareCodeData sharecode.Data +// - shareCodeData sharecodedata.Data func (_e *mockDonorStore_Expecter) DeleteDonorAccess(ctx interface{}, shareCodeData interface{}) *mockDonorStore_DeleteDonorAccess_Call { return &mockDonorStore_DeleteDonorAccess_Call{Call: _e.mock.On("DeleteDonorAccess", ctx, shareCodeData)} } -func (_c *mockDonorStore_DeleteDonorAccess_Call) Run(run func(ctx context.Context, shareCodeData sharecode.Data)) *mockDonorStore_DeleteDonorAccess_Call { +func (_c *mockDonorStore_DeleteDonorAccess_Call) Run(run func(ctx context.Context, shareCodeData sharecodedata.Data)) *mockDonorStore_DeleteDonorAccess_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.Data)) + run(args[0].(context.Context), args[1].(sharecodedata.Data)) }) return _c } @@ -68,7 +68,7 @@ func (_c *mockDonorStore_DeleteDonorAccess_Call) Return(_a0 error) *mockDonorSto return _c } -func (_c *mockDonorStore_DeleteDonorAccess_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockDonorStore_DeleteDonorAccess_Call { +func (_c *mockDonorStore_DeleteDonorAccess_Call) RunAndReturn(run func(context.Context, sharecodedata.Data) error) *mockDonorStore_DeleteDonorAccess_Call { _c.Call.Return(run) return _c } diff --git a/internal/supporter/supporterpage/mock_ShareCodeStore_test.go b/internal/supporter/supporterpage/mock_ShareCodeStore_test.go index fdc6ac3fcc..54caa85c6c 100644 --- a/internal/supporter/supporterpage/mock_ShareCodeStore_test.go +++ b/internal/supporter/supporterpage/mock_ShareCodeStore_test.go @@ -5,7 +5,7 @@ package supporterpage import ( context "context" - sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + sharecodedata "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" mock "github.com/stretchr/testify/mock" ) @@ -23,7 +23,7 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Delete provides a mock function with given fields: ctx, data -func (_m *mockShareCodeStore) Delete(ctx context.Context, data sharecode.Data) error { +func (_m *mockShareCodeStore) Delete(ctx context.Context, data sharecodedata.Data) error { ret := _m.Called(ctx, data) if len(ret) == 0 { @@ -31,7 +31,7 @@ func (_m *mockShareCodeStore) Delete(ctx context.Context, data sharecode.Data) e } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecodedata.Data) error); ok { r0 = rf(ctx, data) } else { r0 = ret.Error(0) @@ -47,14 +47,14 @@ type mockShareCodeStore_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - data sharecode.Data +// - data sharecodedata.Data func (_e *mockShareCodeStore_Expecter) Delete(ctx interface{}, data interface{}) *mockShareCodeStore_Delete_Call { return &mockShareCodeStore_Delete_Call{Call: _e.mock.On("Delete", ctx, data)} } -func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, data sharecode.Data)) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, data sharecodedata.Data)) *mockShareCodeStore_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.Data)) + run(args[0].(context.Context), args[1].(sharecodedata.Data)) }) return _c } @@ -64,28 +64,28 @@ func (_c *mockShareCodeStore_Delete_Call) Return(_a0 error) *mockShareCodeStore_ return _c } -func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecodedata.Data) error) *mockShareCodeStore_Delete_Call { _c.Call.Return(run) return _c } // GetDonor provides a mock function with given fields: ctx -func (_m *mockShareCodeStore) GetDonor(ctx context.Context) (sharecode.Data, error) { +func (_m *mockShareCodeStore) GetDonor(ctx context.Context) (sharecodedata.Data, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetDonor") } - var r0 sharecode.Data + var r0 sharecodedata.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (sharecode.Data, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (sharecodedata.Data, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) sharecode.Data); ok { + if rf, ok := ret.Get(0).(func(context.Context) sharecodedata.Data); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(sharecode.Data) + r0 = ret.Get(0).(sharecodedata.Data) } if rf, ok := ret.Get(1).(func(context.Context) error); ok { @@ -115,18 +115,18 @@ func (_c *mockShareCodeStore_GetDonor_Call) Run(run func(ctx context.Context)) * return _c } -func (_c *mockShareCodeStore_GetDonor_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_GetDonor_Call { +func (_c *mockShareCodeStore_GetDonor_Call) Return(_a0 sharecodedata.Data, _a1 error) *mockShareCodeStore_GetDonor_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_GetDonor_Call) RunAndReturn(run func(context.Context) (sharecode.Data, error)) *mockShareCodeStore_GetDonor_Call { +func (_c *mockShareCodeStore_GetDonor_Call) RunAndReturn(run func(context.Context) (sharecodedata.Data, error)) *mockShareCodeStore_GetDonor_Call { _c.Call.Return(run) return _c } // PutDonor provides a mock function with given fields: ctx, shareCode, data -func (_m *mockShareCodeStore) PutDonor(ctx context.Context, shareCode string, data sharecode.Data) error { +func (_m *mockShareCodeStore) PutDonor(ctx context.Context, shareCode string, data sharecodedata.Data) error { ret := _m.Called(ctx, shareCode, data) if len(ret) == 0 { @@ -134,7 +134,7 @@ func (_m *mockShareCodeStore) PutDonor(ctx context.Context, shareCode string, da } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, sharecode.Data) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, sharecodedata.Data) error); ok { r0 = rf(ctx, shareCode, data) } else { r0 = ret.Error(0) @@ -151,14 +151,14 @@ type mockShareCodeStore_PutDonor_Call struct { // PutDonor is a helper method to define mock.On call // - ctx context.Context // - shareCode string -// - data sharecode.Data +// - data sharecodedata.Data func (_e *mockShareCodeStore_Expecter) PutDonor(ctx interface{}, shareCode interface{}, data interface{}) *mockShareCodeStore_PutDonor_Call { return &mockShareCodeStore_PutDonor_Call{Call: _e.mock.On("PutDonor", ctx, shareCode, data)} } -func (_c *mockShareCodeStore_PutDonor_Call) Run(run func(ctx context.Context, shareCode string, data sharecode.Data)) *mockShareCodeStore_PutDonor_Call { +func (_c *mockShareCodeStore_PutDonor_Call) Run(run func(ctx context.Context, shareCode string, data sharecodedata.Data)) *mockShareCodeStore_PutDonor_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(sharecode.Data)) + run(args[0].(context.Context), args[1].(string), args[2].(sharecodedata.Data)) }) return _c } @@ -168,7 +168,7 @@ func (_c *mockShareCodeStore_PutDonor_Call) Return(_a0 error) *mockShareCodeStor return _c } -func (_c *mockShareCodeStore_PutDonor_Call) RunAndReturn(run func(context.Context, string, sharecode.Data) error) *mockShareCodeStore_PutDonor_Call { +func (_c *mockShareCodeStore_PutDonor_Call) RunAndReturn(run func(context.Context, string, sharecodedata.Data) error) *mockShareCodeStore_PutDonor_Call { _c.Call.Return(run) return _c } diff --git a/internal/supporter/supporterpage/register.go b/internal/supporter/supporterpage/register.go index 72a37d846c..401dc5c142 100644 --- a/internal/supporter/supporterpage/register.go +++ b/internal/supporter/supporterpage/register.go @@ -19,7 +19,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode/sharecodedata" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -58,7 +58,7 @@ type MemberStore interface { } type DonorStore interface { - DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.Data) error + DeleteDonorAccess(ctx context.Context, shareCodeData sharecodedata.Data) error Get(ctx context.Context) (*donordata.Provided, error) GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]donordata.Provided, error) Put(ctx context.Context, donor *donordata.Provided) error @@ -91,9 +91,9 @@ type NotifyClient interface { } type ShareCodeStore interface { - PutDonor(ctx context.Context, shareCode string, data sharecode.Data) error - GetDonor(ctx context.Context) (sharecode.Data, error) - Delete(ctx context.Context, data sharecode.Data) error + PutDonor(ctx context.Context, shareCode string, data sharecodedata.Data) error + GetDonor(ctx context.Context) (sharecodedata.Data, error) + Delete(ctx context.Context, data sharecodedata.Data) error } type Template func(w io.Writer, data interface{}) error