mirror of https://github.com/usbharu/Hideout.git
wip
This commit is contained in:
parent
997e28bdf6
commit
58077d13f6
|
@ -47,7 +47,7 @@ class Actor2 private constructor(
|
||||||
var lastPostDate: Instant? = null,
|
var lastPostDate: Instant? = null,
|
||||||
suspend: Boolean,
|
suspend: Boolean,
|
||||||
var lastUpdate: Instant = createdAt,
|
var lastUpdate: Instant = createdAt,
|
||||||
alsoKnownAs: List<ActorId> = emptyList(),
|
alsoKnownAs: Set<ActorId> = emptySet(),
|
||||||
moveTo: ActorId? = null,
|
moveTo: ActorId? = null,
|
||||||
) : DomainEventStorable() {
|
) : DomainEventStorable() {
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class Actor2 private constructor(
|
||||||
var alsoKnownAs = alsoKnownAs
|
var alsoKnownAs = alsoKnownAs
|
||||||
set(value) {
|
set(value) {
|
||||||
require(value.find { it == id } == null)
|
require(value.find { it == id } == null)
|
||||||
field = value.distinct()
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
var moveTo = moveTo
|
var moveTo = moveTo
|
||||||
|
|
|
@ -1,10 +1,26 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.actor
|
package dev.usbharu.hideout.core.domain.model.actor
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
|
||||||
class Actor2Test {
|
class Actor2Test {
|
||||||
@Test
|
@Test
|
||||||
fun alsoKnownAsに自分自身が含まれてはいけない() {
|
fun alsoKnownAsに自分自身が含まれてはいけない() {
|
||||||
TestActor2Factory.create()
|
val actor = TestActor2Factory.create(publicKey = ActorPublicKey(""))
|
||||||
|
|
||||||
|
assertThrows<IllegalArgumentException> {
|
||||||
|
actor.alsoKnownAs = setOf(actor.id)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun moveToに自分自身が設定されてはいけない() {
|
||||||
|
val actor = TestActor2Factory.create(publicKey = ActorPublicKey(""))
|
||||||
|
|
||||||
|
assertThrows<IllegalArgumentException> {
|
||||||
|
actor.moveTo = actor.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ object TestActor2Factory : Actor2.Actor2Factory() {
|
||||||
outbox: URI = URI.create("https://example.com/$id/outbox"),
|
outbox: URI = URI.create("https://example.com/$id/outbox"),
|
||||||
uri: URI = URI.create("https://example.com/$id"),
|
uri: URI = URI.create("https://example.com/$id"),
|
||||||
publicKey: ActorPublicKey,
|
publicKey: ActorPublicKey,
|
||||||
privateKey: ActorPrivateKey?,
|
privateKey: ActorPrivateKey? = null,
|
||||||
createdAt: Instant = Instant.now(),
|
createdAt: Instant = Instant.now(),
|
||||||
keyId: String = "https://example.com/$id#key-id",
|
keyId: String = "https://example.com/$id#key-id",
|
||||||
followersEndpoint: URI = URI.create("https://example.com/$id/followers"),
|
followersEndpoint: URI = URI.create("https://example.com/$id/followers"),
|
||||||
|
|
|
@ -1,14 +1,41 @@
|
||||||
package dev.usbharu.hideout.core.domain.service.actor
|
package dev.usbharu.hideout.core.domain.service.actor
|
||||||
|
|
||||||
import dev.usbharu.hideout.application.config.ApplicationConfig
|
import dev.usbharu.hideout.application.config.ApplicationConfig
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.ActorPublicKey
|
||||||
|
import dev.usbharu.hideout.core.domain.model.actor.TestActor2Factory
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
import kotlin.test.assertFalse
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class RemoteActorCheckDomainServiceTest {
|
class RemoteActorCheckDomainServiceTest {
|
||||||
@Test
|
@Test
|
||||||
fun リモートのドメインならtrueを返す() {
|
fun リモートのドメインならtrueを返す() {
|
||||||
val actor =
|
val actor = TestActor2Factory.create(publicKey = ActorPublicKey(""))
|
||||||
|
|
||||||
RemoteActorCheckDomainService(ApplicationConfig(URI.create("https://example.com").toURL())).isRemoteActor()
|
val remoteActor = RemoteActorCheckDomainService(
|
||||||
|
ApplicationConfig(
|
||||||
|
URI.create("https://local.example.com").toURL()
|
||||||
|
)
|
||||||
|
).isRemoteActor(
|
||||||
|
actor
|
||||||
|
)
|
||||||
|
|
||||||
|
assertTrue(remoteActor)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun ローカルのActorならfalseを返す() {
|
||||||
|
val actor = TestActor2Factory.create(domain = "local.example.com", publicKey = ActorPublicKey(""))
|
||||||
|
|
||||||
|
val localActor = RemoteActorCheckDomainService(
|
||||||
|
ApplicationConfig(
|
||||||
|
URI.create("https://local.example.com").toURL()
|
||||||
|
)
|
||||||
|
).isRemoteActor(
|
||||||
|
actor
|
||||||
|
)
|
||||||
|
|
||||||
|
assertFalse(localActor)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue