feat(identity): confirm registration email atomically

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 09:12:15 +03:00
1 parent 8e7ce8d71c
commit fade4e76e4
75 files changed
+4188 -403

No files matched your search

+15 -8
View File
@@ -171,12 +171,13 @@ func TestNewContactFieldSetIsCanonicalAndRefusesDuplicates(t *testing.T) {
func validGrantInput() ConsentGrantInput {
return ConsentGrantInput{
SubjectID: uuid.Must(uuid.NewV7()),
Purpose: ConsentPurposePersonalData,
TextVersion: consentTestVersion,
TextHash: HashConsentText("I consent."),
Source: ConsentSourceRegistration,
GrantedAt: consentTestTime,
SubjectID: uuid.Must(uuid.NewV7()),
Purpose: ConsentPurposePersonalData,
TextVersion: consentTestVersion,
TextHash: HashConsentText("I consent."),
Source: ConsentSourceRegistration,
RegistrationVersion: 1,
GrantedAt: consentTestTime,
}
}
@@ -185,7 +186,7 @@ func TestNewConsentGrantValidatesEveryField(t *testing.T) {
if err != nil {
t.Fatalf("NewConsentGrant() error = %v", err)
}
if grant.ID().Version() != 7 || grant.Purpose() != ConsentPurposePersonalData || grant.IsZero() {
if grant.ID().Version() != 7 || grant.Purpose() != ConsentPurposePersonalData || grant.RegistrationVersion() != 1 || grant.IsZero() {
t.Fatalf("grant = %s %s, want a UUIDv7 C1 grant", grant.ID(), grant.Purpose())
}
for name, change := range map[string]func(*ConsentGrantInput){
@@ -197,7 +198,13 @@ func TestNewConsentGrantValidatesEveryField(t *testing.T) {
"malformed text version": func(input *ConsentGrantInput) { input.TextVersion = "c1 v2" },
"missing text hash": func(input *ConsentGrantInput) { input.TextHash = ConsentTextHash{} },
"missing subject": func(input *ConsentGrantInput) { input.SubjectID = uuid.Nil },
"registration of C2": func(input *ConsentGrantInput) { input.Purpose = ConsentPurposePublication },
"missing registration version": func(input *ConsentGrantInput) {
input.RegistrationVersion = 0
},
"settings grant with registration version": func(input *ConsentGrantInput) {
input.Source = ConsentSourceConsentSettings
},
"registration of C2": func(input *ConsentGrantInput) { input.Purpose = ConsentPurposePublication },
"invitation acceptance of C3": func(input *ConsentGrantInput) {
input.Purpose, input.Source = ConsentPurposeAutoCategorization, ConsentSourceInvitationAcceptance
},