Skip to content

Commit

Permalink
Rename sharecodedata Data to Link
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed Aug 9, 2024
1 parent dd72f78 commit 9afea98
Show file tree
Hide file tree
Showing 39 changed files with 267 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) {
LpaData(r).
Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil)

shareCodeData := sharecodedata.Data{
shareCodeData := sharecodedata.Link{
LpaKey: dynamo.LpaKey("lpa-id"),
LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")),
ActorUID: tc.uid,
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutWhenAttorneyNotFound(t *testing
LpaData(r).
Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil)

shareCodeData := sharecodedata.Data{
shareCodeData := sharecodedata.Link{
LpaKey: dynamo.LpaKey("lpa-id"),
LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")),
ActorUID: actoruid.New(),
Expand Down Expand Up @@ -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 := sharecodedata.Data{
shareCodeData := sharecodedata.Link{
LpaKey: dynamo.LpaKey("lpa-id"),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestPostEnterReferenceNumberOptOut(t *testing.T) {
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(r.Context(), actor.TypeAttorney, "abcdef123456").
Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil)
Return(sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil)

sessionStore := newMockSessionStore(t)
sessionStore.EXPECT().
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) {
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(mock.Anything, mock.Anything, mock.Anything).
Return(sharecodedata.Data{}, expectedError)
Return(sharecodedata.Link{}, expectedError)

return shareCodeStore
},
Expand All @@ -119,7 +119,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) {
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(mock.Anything, mock.Anything, mock.Anything).
Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id")}, nil)
Return(sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id")}, nil)

return shareCodeStore
},
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestPostEnterReferenceNumberOptOutOnShareCodeStoreNotFoundError(t *testing.
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(r.Context(), actor.TypeAttorney, "abcdef123456").
Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{})
Return(sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{})

err := EnterReferenceNumberOptOut(template.Execute, shareCodeStore, nil)(testAppData, w, r)

Expand Down
20 changes: 10 additions & 10 deletions internal/attorney/attorneypage/enter_reference_number_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,27 @@ func TestGetEnterReferenceNumberOnTemplateError(t *testing.T) {

func TestPostEnterReferenceNumber(t *testing.T) {
testcases := map[string]struct {
shareCode sharecodedata.Data
shareCode sharecodedata.Link
session *sesh.LoginSession
isReplacement bool
isTrustCorporation bool
}{
"attorney": {
shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID},
shareCode: sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID},
session: &sesh.LoginSession{Sub: "hey", Email: "[email protected]"},
},
"replacement": {
shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true},
shareCode: sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true},
session: &sesh.LoginSession{Sub: "hey", Email: "[email protected]"},
isReplacement: true,
},
"trust corporation": {
shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsTrustCorporation: true},
shareCode: sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsTrustCorporation: true},
session: &sesh.LoginSession{Sub: "hey", Email: "[email protected]"},
isTrustCorporation: true,
},
"replacement trust corporation": {
shareCode: sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true, IsTrustCorporation: true},
shareCode: sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true, IsTrustCorporation: true},
session: &sesh.LoginSession{Sub: "hey", Email: "[email protected]"},
isReplacement: true,
isTrustCorporation: true,
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestPostEnterReferenceNumber(t *testing.T) {
}

func TestPostEnterReferenceNumberWhenConditionalCheckFailed(t *testing.T) {
shareCode := sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID}
shareCode := sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID}

form := url.Values{
"reference-number": {"abcdef123456"},
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestPostEnterReferenceNumberOnDonorStoreError(t *testing.T) {
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(r.Context(), actor.TypeAttorney, "abcdef123456").
Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError)
Return(sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError)

err := EnterReferenceNumber(nil, shareCodeStore, nil, nil)(testAppData, w, r)

Expand Down Expand Up @@ -220,7 +220,7 @@ func TestPostEnterReferenceNumberOnShareCodeStoreNotFoundError(t *testing.T) {
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(r.Context(), actor.TypeAttorney, "abcdef123456").
Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{})
Return(sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{})

err := EnterReferenceNumber(template.Execute, shareCodeStore, nil, nil)(testAppData, w, r)

Expand All @@ -242,7 +242,7 @@ func TestPostEnterReferenceNumberOnSessionGetError(t *testing.T) {
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(r.Context(), actor.TypeAttorney, "abcdef123456").
Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil)
Return(sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil)

sessionStore := newMockSessionStore(t)
sessionStore.EXPECT().
Expand All @@ -266,7 +266,7 @@ func TestPostEnterReferenceNumberOnAttorneyStoreError(t *testing.T) {
shareCodeStore := newMockShareCodeStore(t)
shareCodeStore.EXPECT().
Get(r.Context(), actor.TypeAttorney, "abcdef123456").
Return(sharecodedata.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil)
Return(sharecodedata.Link{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil)

attorneyStore := newMockAttorneyStore(t)
attorneyStore.EXPECT().
Expand Down
14 changes: 7 additions & 7 deletions internal/attorney/attorneypage/mock_AttorneyStore_test.go

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

34 changes: 17 additions & 17 deletions internal/attorney/attorneypage/mock_ShareCodeStore_test.go

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

8 changes: 4 additions & 4 deletions internal/attorney/attorneypage/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ type OneLoginClient interface {
}

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
Delete(ctx context.Context, shareCode sharecodedata.Data) error
Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecodedata.Link, error)
Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecodedata.Link) error
Delete(ctx context.Context, shareCode sharecodedata.Link) error
}

type AttorneyStore interface {
Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*attorneydata.Provided, error)
Create(ctx context.Context, shareCode sharecodedata.Link, 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
Expand Down
2 changes: 1 addition & 1 deletion internal/attorney/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewStore(dynamoClient DynamoClient) *Store {
return &Store{dynamoClient: dynamoClient, now: time.Now}
}

func (s *Store) Create(ctx context.Context, shareCode sharecodedata.Data, email string) (*attorneydata.Provided, error) {
func (s *Store) Create(ctx context.Context, shareCode sharecodedata.Link, email string) (*attorneydata.Provided, error) {
data, err := appcontext.SessionFromContext(ctx)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions internal/attorney/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestAttorneyStoreCreate(t *testing.T) {
Email: "[email protected]",
}

shareCode := sharecodedata.Data{
shareCode := sharecodedata.Link{
PK: dynamo.ShareKey(dynamo.AttorneyShareKey("123")),
SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")),
ActorUID: uid,
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestAttorneyStoreCreateWhenSessionMissing(t *testing.T) {

attorneyStore := &Store{dynamoClient: nil, now: nil}

_, err := attorneyStore.Create(ctx, sharecodedata.Data{}, "")
_, err := attorneyStore.Create(ctx, sharecodedata.Link{}, "")
assert.Equal(t, appcontext.SessionMissingError{}, err)
}

Expand All @@ -109,7 +109,7 @@ func TestAttorneyStoreCreateWhenSessionMissingRequiredData(t *testing.T) {

attorneyStore := &Store{}

_, err := attorneyStore.Create(ctx, sharecodedata.Data{}, "")
_, err := attorneyStore.Create(ctx, sharecodedata.Link{}, "")
assert.NotNil(t, err)
})
}
Expand All @@ -126,7 +126,7 @@ func TestAttorneyStoreCreateWhenWriteTransactionError(t *testing.T) {

attorneyStore := &Store{dynamoClient: dynamoClient, now: func() time.Time { return now }}

_, err := attorneyStore.Create(ctx, sharecodedata.Data{
_, err := attorneyStore.Create(ctx, sharecodedata.Link{
PK: dynamo.ShareKey(dynamo.AttorneyShareKey("123")),
SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")),
}, "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) {
LpaData(r).
Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil)

shareCodeData := sharecodedata.Data{
shareCodeData := sharecodedata.Link{
LpaKey: dynamo.LpaKey("lpa-id"),
LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")),
}
Expand Down Expand Up @@ -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 := sharecodedata.Data{
shareCodeData := sharecodedata.Link{
LpaKey: dynamo.LpaKey("lpa-id"),
}

Expand Down
Loading

0 comments on commit 9afea98

Please sign in to comment.