♻️ Make plugin connector fully suspendable
[Sone.git] / src / test / kotlin / net / pterodactylus / sone / freenet / wot / PluginWebOfTrustConnectorTest.kt
index e5d7da2..1af177f 100644 (file)
@@ -99,11 +99,25 @@ class PluginWebOfTrustConnectorTest {
                assertThat(trustedIdentities, contains(
                                allOf(
                                                isIdentity("id0", "nickname0", "request-uri0", empty<String>(), isEmptyMap()),
-                                               isTrusted(ownIdentity, isTrust(null, 0, 0))
+                                               isTrusted(ownIdentity, isTrust(null, null, null))
                                ),
                                allOf(
                                                isIdentity("id1", "nickname1", "request-uri1", empty<String>(), isEmptyMap()),
-                                               isTrusted(ownIdentity, isTrust(null, 0, 0))
+                                               isTrusted(ownIdentity, isTrust(null, null, null))
+                               )
+               ))
+       }
+
+       @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<String>(), isEmptyMap()),
+                                               isTrusted(ownIdentity, isTrust(null, null, null))
                                )
                ))
        }
@@ -305,7 +319,7 @@ private fun <R> PluginConnector.connect(block: PluginWebOfTrustConnector.() -> R
 
 fun createPluginConnector(message: String, fieldsMatcher: Matcher<SimpleFieldSet> = IsAnything<SimpleFieldSet>(), build: SimpleFieldSetBuilder.() -> Unit = {}) =
                object : PluginConnector {
-                       override fun sendRequest(pluginName: String, identifier: String, fields: SimpleFieldSet, data: Bucket?) =
+                       override suspend fun sendRequest(pluginName: String, fields: SimpleFieldSet, data: Bucket?) =
                                        if ((pluginName != wotPluginName) || (fields.get("Message") != message)) {
                                                throw PluginException()
                                        } else {