1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-17 00:54:50 +02:00

Move EdgeComponent test constructor to NetworkDSL

This commit is contained in:
Paul Schaub 2023-07-09 13:17:58 +02:00
parent 4be4633266
commit b12fc5e4d2
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 18 additions and 18 deletions

View file

@ -32,22 +32,6 @@ data class EdgeComponent(
val regexes: RegexSet
) {
/**
* Construct a [EdgeComponent] with default values. The result is non-expiring, will be exportable and has a
* trust amount of 120, a depth of 0 and a wildcard regex.
*
* @param issuer synopsis of the certificate that issued the [EdgeComponent]
* @param target synopsis of the certificate that is target of this [EdgeComponent]
* @param targetUserId optional user-id. If this is null, the [EdgeComponent] is made over the primary key of the target.
* @param creationTime creation time of the [EdgeComponent]
*/
constructor(
issuer: Node,
target: Node,
targetUserId: String? = null,
creationTime: Date) :
this(issuer, target, targetUserId, creationTime, null, true, 120, Depth.limited(0), RegexSet.wildcard())
override fun toString(): String {
return if (trustDepth.limit == 0)
"${issuer.fingerprint} certifies binding: $userId <-> ${target.fingerprint} [$trustAmount]"

View file

@ -1,6 +1,7 @@
package org.pgpainless.wot.network
import org.junit.jupiter.api.Test
import org.pgpainless.wot.dsl.NetworkDSL
import org.pgpainless.wot.network.Node
import org.pgpainless.wot.network.EdgeComponent
import org.pgpainless.wot.network.Fingerprint
@ -8,7 +9,7 @@ import org.pgpainless.wot.network.RevocationState
import java.util.*
import kotlin.test.assertEquals
class EdgeComponentTest {
class EdgeComponentTest: NetworkDSL {
private val alice = Node(
Fingerprint("A"),

View file

@ -6,11 +6,12 @@ package org.pgpainless.wot.network
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.pgpainless.wot.dsl.NetworkDSL
import java.util.*
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class EdgeTest {
class EdgeTest: NetworkDSL {
private val alice = Node(Fingerprint("A"), null, RevocationState.notRevoked(), mapOf())
private val bob = Node(Fingerprint("B"), null, RevocationState.notRevoked(), mapOf())

View file

@ -43,6 +43,20 @@ interface NetworkDSL {
fun EdgeComponent(issuer: Node, target: Node, amount: Int, depth: Depth): EdgeComponent =
EdgeComponent(issuer, target, null, Date(), null, true, amount, depth, RegexSet.wildcard())
/**
* Construct a [EdgeComponent] with default values. The result is non-expiring, will be exportable and has a
* trust amount of 120, a depth of 0 and a wildcard regex.
*
* @param issuer synopsis of the certificate that issued the [EdgeComponent]
* @param target synopsis of the certificate that is target of this [EdgeComponent]
* @param targetUserId optional user-id. If this is null, the [EdgeComponent] is made over the primary key of the target.
* @param creationTime creation time of the [EdgeComponent]
*/
fun EdgeComponent(issuer: Node, target: Node, targetUserId: String? = null, creationTime: Date): EdgeComponent =
EdgeComponent(issuer, target, targetUserId, creationTime, null, true, 120, Depth.limited(0), RegexSet.wildcard())
/**
* Add a single [Node] built from a [String] fingerprint to the builder.
*/