Skip to content

Commit

Permalink
Merge 1e84bc6 into fe5a029
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Jan 26, 2024
2 parents fe5a029 + 1e84bc6 commit 628cec6
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 43 deletions.
16 changes: 12 additions & 4 deletions cmd/event-received/cloud_watch_event_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func TestHandleFeeApproved(t *testing.T) {
}

now := time.Now()
updated := actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted}, UpdatedAt: now}
updated.Hash, _ = updated.GenerateHash()

client := newMockDynamodbClient(t)
client.
Expand All @@ -195,7 +197,7 @@ func TestHandleFeeApproved(t *testing.T) {
return nil
})
client.EXPECT().
Put(ctx, actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted}, UpdatedAt: now, Hash: 13171477638077665116}).
Put(ctx, updated).
Return(nil)

shareCodeSender := newMockShareCodeSender(t)
Expand Down Expand Up @@ -281,6 +283,8 @@ func TestHandleMoreEvidenceRequired(t *testing.T) {
}

now := time.Now()
updated := actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, UpdatedAt: now}
updated.Hash, _ = updated.GenerateHash()

client := newMockDynamodbClient(t)
client.
Expand All @@ -298,7 +302,7 @@ func TestHandleMoreEvidenceRequired(t *testing.T) {
return nil
})
client.EXPECT().
Put(ctx, actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, UpdatedAt: now, Hash: 2420797377841961994}).
Put(ctx, updated).
Return(nil)

err := handleMoreEvidenceRequired(ctx, client, event, func() time.Time { return now })
Expand All @@ -312,6 +316,8 @@ func TestHandleMoreEvidenceRequiredWhenPutError(t *testing.T) {
}

now := time.Now()
updated := actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, UpdatedAt: now}
updated.Hash, _ = updated.GenerateHash()

client := newMockDynamodbClient(t)
client.
Expand All @@ -329,7 +335,7 @@ func TestHandleMoreEvidenceRequiredWhenPutError(t *testing.T) {
return nil
})
client.EXPECT().
Put(ctx, actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, UpdatedAt: now, Hash: 2420797377841961994}).
Put(ctx, updated).
Return(expectedError)

err := handleMoreEvidenceRequired(ctx, client, event, func() time.Time { return now })
Expand All @@ -343,6 +349,8 @@ func TestHandleFeeDenied(t *testing.T) {
}

now := time.Now()
updated := actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}, UpdatedAt: now}
updated.Hash, _ = updated.GenerateHash()

client := newMockDynamodbClient(t)
client.
Expand All @@ -360,7 +368,7 @@ func TestHandleFeeDenied(t *testing.T) {
return nil
})
client.EXPECT().
Put(ctx, actor.DonorProvidedDetails{PK: "LPA#123", SK: "#DONOR#456", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}, UpdatedAt: now, Hash: 3695518532056580250}).
Put(ctx, updated).
Return(nil)

err := handleFeeDenied(ctx, client, event, func() time.Time { return now })
Expand Down
3 changes: 3 additions & 0 deletions internal/actor/donor_provided.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ type DonorProvidedDetails struct {
WantToApplyForLpa bool
// Confirmation that the applicant wants to sign the LPA
WantToSignLpa bool
// CertificateProviderNotRelatedConfirmedAt is when the donor confirmed the
// certificate provider is not related to another similar actor
CertificateProviderNotRelatedConfirmedAt time.Time
// CheckedAt is when the donor checked their LPA
CheckedAt time.Time
// CheckedHash is the Hash value of the LPA when last checked
Expand Down
4 changes: 2 additions & 2 deletions internal/actor/donor_provided_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func TestGenerateHash(t *testing.T) {
}}
hash, err := donor.GenerateHash()
assert.Nil(t, err)
assert.Equal(t, uint64(0xabd65d97f7772933), hash)
assert.Equal(t, uint64(0xdf80e0da44d7fafd), hash)

donor.Attorneys.Attorneys[0].DateOfBirth = date.New("2001", "1", "2")
hash, err = donor.GenerateHash()
assert.Nil(t, err)
assert.Equal(t, uint64(0xc5b170c4ed718e61), hash)
assert.Equal(t, uint64(0x1e06941b4d5e138e), hash)
}

func TestIdentityConfirmed(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions internal/lpastore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type lpaRequest struct {
WhenTheLpaCanBeUsed actor.CanBeUsedWhen `json:"whenTheLpaCanBeUsed,omitempty"`
LifeSustainingTreatmentOption actor.LifeSustainingTreatment `json:"lifeSustainingTreatmentOption,omitempty"`
SignedAt time.Time `json:"signedAt"`
CertificateProviderNotRelatedConfirmedAt *time.Time `json:"certificateProviderNotRelatedConfirmedAt,omitempty"`
}

type lpaRequestDonor struct {
Expand Down Expand Up @@ -131,6 +132,10 @@ func (c *Client) SendLpa(ctx context.Context, donor *actor.DonorProvidedDetails)
SignedAt: donor.SignedAt,
}

if !donor.CertificateProviderNotRelatedConfirmedAt.IsZero() {
body.CertificateProviderNotRelatedConfirmedAt = &donor.CertificateProviderNotRelatedConfirmedAt
}

switch donor.Type {
case actor.LpaTypePropertyAndAffairs:
body.WhenTheLpaCanBeUsed = donor.WhenCanTheLpaBeUsed
Expand Down
Loading

0 comments on commit 628cec6

Please sign in to comment.