mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
EventManager: add datetime placeholder
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -5431,7 +5431,7 @@ func TestBackupAsAttachment(t *testing.T) {
|
||||
|
||||
common.HandleCertificateEvent(common.EventParams{
|
||||
Name: "example.com",
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
Timestamp: time.Now(),
|
||||
Status: 1,
|
||||
Event: renewalEvent,
|
||||
})
|
||||
@@ -7108,7 +7108,7 @@ func TestEventRuleCertificate(t *testing.T) {
|
||||
Recipients: []string{"test@example.com"},
|
||||
Subject: `"{{Event}} {{StatusString}}"`,
|
||||
ContentType: 0,
|
||||
Body: "Domain: {{Name}} Timestamp: {{Timestamp}} {{ErrorString}}",
|
||||
Body: "Domain: {{Name}} Timestamp: {{Timestamp}} {{ErrorString}} Date time: {{DateTime}}",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -7163,7 +7163,7 @@ func TestEventRuleCertificate(t *testing.T) {
|
||||
|
||||
common.HandleCertificateEvent(common.EventParams{
|
||||
Name: "example.com",
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
Timestamp: time.Now(),
|
||||
Status: 1,
|
||||
Event: renewalEvent,
|
||||
})
|
||||
@@ -7178,9 +7178,10 @@ func TestEventRuleCertificate(t *testing.T) {
|
||||
assert.Contains(t, email.Data, `Domain: example.com Timestamp`)
|
||||
|
||||
lastReceivedEmail.reset()
|
||||
dateTime := time.Now()
|
||||
params := common.EventParams{
|
||||
Name: "example.com",
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
Timestamp: dateTime,
|
||||
Status: 2,
|
||||
Event: renewalEvent,
|
||||
}
|
||||
@@ -7195,6 +7196,7 @@ func TestEventRuleCertificate(t *testing.T) {
|
||||
assert.True(t, slices.Contains(email.To, "test@example.com"))
|
||||
assert.Contains(t, email.Data, fmt.Sprintf(`Subject: "%s KO"`, renewalEvent))
|
||||
assert.Contains(t, email.Data, `Domain: example.com Timestamp`)
|
||||
assert.Contains(t, email.Data, dateTime.UTC().Format("2006-01-02T15:04:05.000"))
|
||||
assert.Contains(t, email.Data, errRenew.Error())
|
||||
|
||||
_, err = httpdtest.RemoveEventRule(rule1, http.StatusOK)
|
||||
@@ -7208,7 +7210,7 @@ func TestEventRuleCertificate(t *testing.T) {
|
||||
// ignored no more certificate rules
|
||||
common.HandleCertificateEvent(common.EventParams{
|
||||
Name: "example.com",
|
||||
Timestamp: time.Now().UnixNano(),
|
||||
Timestamp: time.Now(),
|
||||
Status: 1,
|
||||
Event: renewalEvent,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user