Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Feb 25, 2025
2 parents d8fd998 + 6fee38b commit 5b43bb4
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
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

0 comments on commit 5b43bb4

Please sign in to comment.