mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 04:17:59 +01:00
Test RevocationState class
This commit is contained in:
parent
a9cb991a2d
commit
169f680b58
1 changed files with 43 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
||||||
|
package org.pgpainless.wot.dijkstra
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.pgpainless.wot.dijkstra.sq.ReferenceTime
|
||||||
|
import org.pgpainless.wot.dijkstra.sq.RevocationState
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.test.assertFalse
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class RevocationStateTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testNotRevoked() {
|
||||||
|
val notRevoked = RevocationState.notRevoked()
|
||||||
|
assertTrue { notRevoked.isNotRevoked() }
|
||||||
|
assertFalse { notRevoked.isSoftRevocation() }
|
||||||
|
assertFalse { notRevoked.isHardRevocation() }
|
||||||
|
assertFalse { notRevoked.isEffective(ReferenceTime.timestamp(Date())) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSoftRevocation() {
|
||||||
|
val timestamp = Date()
|
||||||
|
val before = Date(timestamp.time - 5000)
|
||||||
|
val after = Date(timestamp.time + 5000)
|
||||||
|
val softRevoked = RevocationState.softRevoked(timestamp)
|
||||||
|
|
||||||
|
assertTrue { softRevoked.isSoftRevocation() }
|
||||||
|
assertFalse { softRevoked.isHardRevocation() }
|
||||||
|
assertFalse { softRevoked.isNotRevoked() }
|
||||||
|
assertTrue { softRevoked.isEffective(ReferenceTime.timestamp(after)) }
|
||||||
|
assertFalse { softRevoked.isEffective(ReferenceTime.timestamp(before)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testHardRevoked() {
|
||||||
|
val hardRevoked = RevocationState.hardRevoked()
|
||||||
|
assertTrue { hardRevoked.isHardRevocation() }
|
||||||
|
assertFalse { hardRevoked.isSoftRevocation() }
|
||||||
|
assertFalse { hardRevoked.isNotRevoked() }
|
||||||
|
assertTrue { hardRevoked.isEffective(ReferenceTime.now()) }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue