Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

MLPAB-2634 Set (im)material change when donor has signed then confirmed #1805

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/event-received/sirius_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func handleChangeConfirmed(ctx context.Context, client dynamodbClient, certifica
return fmt.Errorf("failed to get donor: %w", err)
}

if donor.Tasks.ConfirmYourIdentity.IsPending() && donor.ContinueWithMismatchedIdentity {
if donor.Tasks.ConfirmYourIdentity.IsPending() && (donor.ContinueWithMismatchedIdentity || !donor.SignedAt.IsZero()) {
if materialChange {
donor.MaterialChangeConfirmedAt = now()
donor.Tasks.ConfirmYourIdentity = task.IdentityStateProblem
Expand Down
87 changes: 85 additions & 2 deletions cmd/event-received/sirius_event_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"
"testing"

"github.com/aws/aws-lambda-go/events"
Expand Down Expand Up @@ -1473,6 +1474,54 @@ func TestHandleImmaterialChangeConfirmed(t *testing.T) {
},
setupCertificateProviderStore: unusedCertificateProviderStore,
},
"donor when signed": {
setupDynamoClient: func(t *testing.T) *mockDynamodbClient {
updated := &donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
Tasks: donordata.Tasks{ConfirmYourIdentity: task.IdentityStateCompleted},
SignedAt: testNow,
ImmaterialChangeConfirmedAt: testNow,
UpdatedAt: testNow,
}
updated.UpdateHash()

c := newMockDynamodbClient(t)
c.EXPECT().
OneByUID(ctx, "M-1111-2222-3333", mock.Anything).
Return(nil).
SetData(dynamo.Keys{PK: dynamo.LpaKey("123"), SK: dynamo.DonorKey("456")})
c.EXPECT().
One(ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(nil).
SetData(donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
Tasks: donordata.Tasks{ConfirmYourIdentity: task.IdentityStatePending},
SignedAt: testNow,
})
c.EXPECT().
Put(ctx, updated).
Return(nil)

return c
},
setupLpaStoreClient: func(t *testing.T) *mockLpaStoreClient {
c := newMockLpaStoreClient(t)
c.EXPECT().
SendDonorConfirmIdentity(ctx, &donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
Tasks: donordata.Tasks{ConfirmYourIdentity: task.IdentityStateCompleted},
SignedAt: testNow,
ImmaterialChangeConfirmedAt: testNow,
}).
Return(nil)

return c
},
setupCertificateProviderStore: unusedCertificateProviderStore,
},
"certificateProvider": {
setupDynamoClient: unusedDynamoClient,
setupLpaStoreClient: func(t *testing.T) *mockLpaStoreClient {
Expand Down Expand Up @@ -1517,7 +1566,7 @@ func TestHandleImmaterialChangeConfirmed(t *testing.T) {
t.Run(actorType, func(t *testing.T) {
event := &events.CloudWatchEvent{
DetailType: "immaterial-change-confirmed",
Detail: json.RawMessage(fmt.Sprintf(`{"uid":"M-1111-2222-3333","actorUID":"740e5834-3a29-46b4-9a6f-16142fde533a","actorType":"%s"}`, actorType)),
Detail: json.RawMessage(fmt.Sprintf(`{"uid":"M-1111-2222-3333","actorUID":"740e5834-3a29-46b4-9a6f-16142fde533a","actorType":"%s"}`, strings.Split(actorType, " ")[0])),
}

factory := newMockFactory(t)
Expand Down Expand Up @@ -1872,6 +1921,40 @@ func TestHandleMaterialChangeConfirmed(t *testing.T) {
},
setupCertificateProviderStore: unusedCertificateProviderStore,
},
"donor when signed": {
setupDynamoClient: func(t *testing.T) *mockDynamodbClient {
updated := &donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
Tasks: donordata.Tasks{ConfirmYourIdentity: task.IdentityStateProblem},
SignedAt: testNow,
UpdatedAt: testNow,
MaterialChangeConfirmedAt: testNow,
}
updated.UpdateHash()

c := newMockDynamodbClient(t)
c.EXPECT().
OneByUID(ctx, "M-1111-2222-3333", mock.Anything).
Return(nil).
SetData(dynamo.Keys{PK: dynamo.LpaKey("123"), SK: dynamo.DonorKey("456")})
c.EXPECT().
One(ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything).
Return(nil).
SetData(donordata.Provided{
PK: dynamo.LpaKey("123"),
SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")),
Tasks: donordata.Tasks{ConfirmYourIdentity: task.IdentityStatePending},
SignedAt: testNow,
})
c.EXPECT().
Put(ctx, updated).
Return(nil)

return c
},
setupCertificateProviderStore: unusedCertificateProviderStore,
},
"certificateProvider": {
setupDynamoClient: unusedDynamoClient,
setupCertificateProviderStore: func(t *testing.T) *mockCertificateProviderStore {
Expand Down Expand Up @@ -1902,7 +1985,7 @@ func TestHandleMaterialChangeConfirmed(t *testing.T) {
t.Run(actorType, func(t *testing.T) {
event := &events.CloudWatchEvent{
DetailType: "material-change-confirmed",
Detail: json.RawMessage(fmt.Sprintf(`{"uid":"M-1111-2222-3333","actorUID":"740e5834-3a29-46b4-9a6f-16142fde533a","actorType":"%s"}`, actorType)),
Detail: json.RawMessage(fmt.Sprintf(`{"uid":"M-1111-2222-3333","actorUID":"740e5834-3a29-46b4-9a6f-16142fde533a","actorType":"%s"}`, strings.Split(actorType, " ")[0])),
}

factory := newMockFactory(t)
Expand Down
Loading