/**
* 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<String>().synchronized()
private val properties = mutableMapOf<String, String>().synchronized()
}
@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))
+ )
+ ))
+ }
+
+ @Test
fun `trusted identity with contexts is returned correctly`() {
val trustedIdentities = createPluginConnector("GetIdentitiesByScore") {
put("Identity0", "id0")
}
}
-fun isIdentity(id: String, nickname: String, requestUri: String, contexts: Matcher<out Iterable<String>>, properties: Matcher<out Map<out String, String>>) =
+fun isIdentity(id: String, nickname: String?, requestUri: String, contexts: Matcher<out Iterable<String>>, properties: Matcher<out Map<out String, String>>) =
AttributeMatcher<Identity>("identity")
.addAttribute("id", id, Identity::getId)
.addAttribute("nickname", nickname, Identity::getNickname)