Commit f4262fdf authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Floor credential validity to epoch boundary in issuance unit tests

parent c7a2406c
......@@ -256,6 +256,13 @@ func (attr *MetadataAttribute) IsValid() bool {
return attr.IsValidOn(time.Now())
}
// FloorToEpochBoundary returns the greatest time not greater than the argument
// that falls on the boundary of an epoch for attribute validity or expiry,
// of which the value is defined by ExpiryFactor (one week).
func FloorToEpochBoundary(t time.Time) time.Time {
return time.Unix((t.Unix()/ExpiryFactor)*ExpiryFactor, 0)
}
func (attr *MetadataAttribute) field(field metadataField) []byte {
return attr.Bytes()[field.offset : field.offset+field.length]
}
......
......@@ -106,7 +106,7 @@ func getSigningJwt(name string, id irma.AttributeTypeIdentifier) interface{} {
}
func getIssuanceRequest(defaultValidity bool) *irma.IssuanceRequest {
temp := irma.Timestamp(time.Now().AddDate(1, 0, 0))
temp := irma.Timestamp(irma.FloorToEpochBoundary(time.Now().AddDate(1, 0, 0)))
var expiry *irma.Timestamp
credid1 := irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")
credid2 := irma.NewCredentialTypeIdentifier("irma-demo.MijnOverheid.root")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment