Add tests for certificate expiration
This commit is contained in:
parent
e0109e79af
commit
27c8c552a2
@ -1,6 +1,7 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -309,3 +310,32 @@ func TestCondition_evaluateWithConnectedFailure(t *testing.T) {
|
|||||||
t.Errorf("Condition '%s' should have been a failure", condition)
|
t.Errorf("Condition '%s' should have been a failure", condition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCondition_evaluateWithUnsetCertificateExpiration(t *testing.T) {
|
||||||
|
condition := Condition("[CERTIFICATE_EXPIRATION] == 0")
|
||||||
|
result := &Result{}
|
||||||
|
condition.evaluate(result)
|
||||||
|
if !result.ConditionResults[0].Success {
|
||||||
|
t.Errorf("Condition '%s' should have been a success", condition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCondition_evaluateWithCertificateExpirationGreaterThan(t *testing.T) {
|
||||||
|
acceptable := (time.Hour * 24 * 28).Milliseconds()
|
||||||
|
condition := Condition("[CERTIFICATE_EXPIRATION] > " + strconv.FormatInt(acceptable, 10))
|
||||||
|
result := &Result{CertificateExpiration: time.Hour * 24 * 60}
|
||||||
|
condition.evaluate(result)
|
||||||
|
if !result.ConditionResults[0].Success {
|
||||||
|
t.Errorf("Condition '%s' should have been a success", condition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCondition_evaluateWithCertificateExpirationGreaterThanFailure(t *testing.T) {
|
||||||
|
acceptable := (time.Hour * 24 * 28).Milliseconds()
|
||||||
|
condition := Condition("[CERTIFICATE_EXPIRATION] > " + strconv.FormatInt(acceptable, 10))
|
||||||
|
result := &Result{CertificateExpiration: time.Hour * 24 * 14}
|
||||||
|
condition.evaluate(result)
|
||||||
|
if result.ConditionResults[0].Success {
|
||||||
|
t.Errorf("Condition '%s' should have been a failure", condition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user