feat(identity): add server sessions and audited mail recovery
This commit is contained in:
1 parent
20c03288d6
commit
4ee53d9a74
58 files changed
+5359
-567
No files matched your search
@@ -317,6 +317,49 @@ func TestRecordAttemptRejectsInconsistentResults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStopAutomaticRetryKeepsAnUncertainDeliveryUnknown(t *testing.T) {
|
||||
start := newTestDelivery(t)
|
||||
scheduled := mustRecord(t, start, DeliveryAttemptInput{
|
||||
At: after(1), Outcome: DeliveryOutcomeUnknown, NextAttemptAt: after(2),
|
||||
})
|
||||
stopped, err := scheduled.StopAutomaticRetry(after(3))
|
||||
if err != nil {
|
||||
t.Fatalf("StopAutomaticRetry() error = %v", err)
|
||||
}
|
||||
if stopped.Status() != DeliveryStatusUnknown || !stopped.NextAttemptAt().IsZero() {
|
||||
t.Fatalf("stopped delivery is %s due %s, want unknown without a due time", stopped.Status(), stopped.NextAttemptAt())
|
||||
}
|
||||
if stopped.AttemptCount() != scheduled.AttemptCount() || stopped.Version() != scheduled.Version()+1 {
|
||||
t.Fatalf("stopped delivery has %d attempts and version %d, want %d and %d", stopped.AttemptCount(), stopped.Version(), scheduled.AttemptCount(), scheduled.Version()+1)
|
||||
}
|
||||
if stopped.IdempotencyKey() != scheduled.IdempotencyKey() || stopped.Content().Hash() != scheduled.Content().Hash() {
|
||||
t.Fatal("stopping retries changed the idempotency key or message content")
|
||||
}
|
||||
if _, err := stopped.StopAutomaticRetry(after(4)); !errors.Is(err, ErrDeliveryTransition) {
|
||||
t.Fatalf("StopAutomaticRetry() without a scheduled retry error = %v, want ErrDeliveryTransition", err)
|
||||
}
|
||||
|
||||
quotaWait := mustRecord(t, newTestDelivery(t), DeliveryAttemptInput{
|
||||
At: after(1), Outcome: DeliveryOutcomeRejected, Rejection: DeliveryRejectionQuotaExhausted, NextAttemptAt: after(2),
|
||||
})
|
||||
quotaStopped, err := quotaWait.StopAutomaticRetry(after(3))
|
||||
if err != nil || quotaStopped.Status() != DeliveryStatusUnknown || !quotaStopped.NextAttemptAt().IsZero() {
|
||||
t.Fatalf("StopAutomaticRetry() after a manual-cycle quota refusal = %s due %s, %v; want unknown without a due time",
|
||||
quotaStopped.Status(), quotaStopped.NextAttemptAt(), err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseMailRetryActor(t *testing.T) {
|
||||
if got, err := ParseMailRetryActor("operator:mail-ops"); err != nil || got != "operator:mail-ops" {
|
||||
t.Fatalf("ParseMailRetryActor() = %q, %v", got, err)
|
||||
}
|
||||
for _, value := range []string{"", "operator:Upper", "operator:has space", "person:mail-ops", "operator:" + strings.Repeat("a", 122)} {
|
||||
if _, err := ParseMailRetryActor(value); !errors.Is(err, ErrInvalidDelivery) {
|
||||
t.Fatalf("ParseMailRetryActor(%q) error = %v, want ErrInvalidDelivery", value, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func deliverySnapshot(delivery Delivery) DeliverySnapshot {
|
||||
return DeliverySnapshot{
|
||||
ID: delivery.ID(),
|
||||
|
||||
Reference in new issue
Block a user