mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-24 11:57:59 +01:00
Move EdgeComponent test constructor to NetworkDSL
This commit is contained in:
parent
0be42a49e7
commit
408544a11c
4 changed files with 18 additions and 18 deletions
|
@ -32,22 +32,6 @@ data class EdgeComponent(
|
||||||
val regexes: RegexSet
|
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 {
|
override fun toString(): String {
|
||||||
return if (trustDepth.limit == 0)
|
return if (trustDepth.limit == 0)
|
||||||
"${issuer.fingerprint} certifies binding: $userId <-> ${target.fingerprint} [$trustAmount]"
|
"${issuer.fingerprint} certifies binding: $userId <-> ${target.fingerprint} [$trustAmount]"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.pgpainless.wot.network
|
package org.pgpainless.wot.network
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.pgpainless.wot.dsl.NetworkDSL
|
||||||
import org.pgpainless.wot.network.Node
|
import org.pgpainless.wot.network.Node
|
||||||
import org.pgpainless.wot.network.EdgeComponent
|
import org.pgpainless.wot.network.EdgeComponent
|
||||||
import org.pgpainless.wot.network.Fingerprint
|
import org.pgpainless.wot.network.Fingerprint
|
||||||
|
@ -8,7 +9,7 @@ import org.pgpainless.wot.network.RevocationState
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
class EdgeComponentTest {
|
class EdgeComponentTest: NetworkDSL {
|
||||||
|
|
||||||
private val alice = Node(
|
private val alice = Node(
|
||||||
Fingerprint("A"),
|
Fingerprint("A"),
|
||||||
|
|
|
@ -6,11 +6,12 @@ package org.pgpainless.wot.network
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.assertThrows
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
import org.pgpainless.wot.dsl.NetworkDSL
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class EdgeTest {
|
class EdgeTest: NetworkDSL {
|
||||||
|
|
||||||
private val alice = Node(Fingerprint("A"), null, RevocationState.notRevoked(), mapOf())
|
private val alice = Node(Fingerprint("A"), null, RevocationState.notRevoked(), mapOf())
|
||||||
private val bob = Node(Fingerprint("B"), null, RevocationState.notRevoked(), mapOf())
|
private val bob = Node(Fingerprint("B"), null, RevocationState.notRevoked(), mapOf())
|
||||||
|
|
|
@ -43,6 +43,20 @@ interface NetworkDSL {
|
||||||
fun EdgeComponent(issuer: Node, target: Node, amount: Int, depth: Depth): EdgeComponent =
|
fun EdgeComponent(issuer: Node, target: Node, amount: Int, depth: Depth): EdgeComponent =
|
||||||
EdgeComponent(issuer, target, null, Date(), null, true, amount, depth, RegexSet.wildcard())
|
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.
|
* Add a single [Node] built from a [String] fingerprint to the builder.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue