From: David ‘Bombe’ Roden Date: Sun, 3 Nov 2019 00:57:35 +0000 (+0100) Subject: 🐛 Make an identity’s nickname optional X-Git-Tag: v81^2~59 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c09f9eb8062ce9395c73e341f9fcb6b015bd734a;p=Sone.git 🐛 Make an identity’s nickname optional --- diff --git a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt index 3398e7f..fe84584 100644 --- a/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt +++ b/src/main/kotlin/net/pterodactylus/sone/freenet/wot/DefaultIdentity.kt @@ -22,7 +22,7 @@ import java.util.Collections.* /** * A Web of Trust identity. */ -open class DefaultIdentity(private val id: String, private val nickname: String, private val requestUri: String) : Identity { +open class DefaultIdentity(private val id: String, private val nickname: String?, private val requestUri: String) : Identity { private val contexts = mutableSetOf().synchronized() private val properties = mutableMapOf().synchronized() diff --git a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt index 5db7fe3..84acd65 100644 --- a/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/freenet/wot/PluginWebOfTrustConnectorTest.kt @@ -109,6 +109,20 @@ class PluginWebOfTrustConnectorTest { } @Test + fun `trusted identity without nickname is returned correctly`() { + val trustedIdentities = createPluginConnector("GetIdentitiesByScore") { + put("Identity0", "id0") + put("RequestURI0", "request-uri0") + }.connect { loadTrustedIdentities(ownIdentity) } + assertThat(trustedIdentities, contains( + allOf( + isIdentity("id0", null, "request-uri0", empty(), isEmptyMap()), + isTrusted(ownIdentity, isTrust(null, null, null)) + ) + )) + } + + @Test fun `trusted identity with contexts is returned correctly`() { val trustedIdentities = createPluginConnector("GetIdentitiesByScore") { put("Identity0", "id0") diff --git a/src/test/kotlin/net/pterodactylus/sone/test/Matchers.kt b/src/test/kotlin/net/pterodactylus/sone/test/Matchers.kt index e7588db..7fc9428 100644 --- a/src/test/kotlin/net/pterodactylus/sone/test/Matchers.kt +++ b/src/test/kotlin/net/pterodactylus/sone/test/Matchers.kt @@ -58,7 +58,7 @@ fun isTrusted(ownIdentity: OwnIdentity, trust: Matcher) = object : TypeSa } } -fun isIdentity(id: String, nickname: String, requestUri: String, contexts: Matcher>, properties: Matcher>) = +fun isIdentity(id: String, nickname: String?, requestUri: String, contexts: Matcher>, properties: Matcher>) = AttributeMatcher("identity") .addAttribute("id", id, Identity::getId) .addAttribute("nickname", nickname, Identity::getNickname)