}
@Test
- public void creatingIdentityFailsWhenDifferentReplyIsSentByPlugin() {
- FcpConnection fcpConnection = createFcpConnection(message -> (listener, connection) -> {
- Map<String, String> fields = createWebOfTrustReplyFields("OtherMessage", true);
- FcpMessage replyMessage = createPluginReply(message, fields);
- listener.receivedFCPPluginReply(connection, new FCPPluginReply(replyMessage, null));
- });
+ public void creatingIdentityFailsWithoutKeysFailsWhenDifferentReplyIsSentByPlugin() {
+ FcpConnection fcpConnection = createConnectionThatSendsOtherMessage();
+ WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+ assertThrows(FcpException.class, () -> webOfTrustPlugin.createIdentity("Test Nickname", "test-context", true));
+ }
+
+ @Test
+ public void creatingIdentityFailsWithInsertKeyFailsWhenDifferentReplyIsSentByPlugin() {
+ FcpConnection fcpConnection = createConnectionThatSendsOtherMessage();
+ WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+ assertThrows(FcpException.class, () -> webOfTrustPlugin.createIdentity("Test Nickname", "test-context", true, "insert-uri"));
+ }
+
+ @Test
+ public void creatingIdentityWithInsertAndRequestKeyFailsWhenDifferentReplyIsSentByPlugin() {
+ FcpConnection fcpConnection = createConnectionThatSendsOtherMessage();
WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
assertThrows(FcpException.class, () -> webOfTrustPlugin.createIdentity("Test Nickname", "test-context", true, "some-request-uri", "insert-uri"));
}
});
}
+ @Test
+ public void getOwnIdentitiesFailsWhenDifferentReplyIsSentByPlugin() {
+ FcpConnection fcpConnection = createConnectionThatSendsOtherMessage();
+ WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+ assertThrows(FcpException.class, webOfTrustPlugin::getOwnIdentities);
+ }
+
+ @Test
+ public void getOwnIdentitiesWithDeprecatedMethodFailsWhenDifferentReplyIsSentByPlugin() {
+ FcpConnection fcpConnection = createConnectionThatSendsOtherMessage();
+ WebOfTrustPlugin webOfTrustPlugin = createWebOfTrustPlugin(fcpConnection);
+ assertThrows(FcpException.class, webOfTrustPlugin::getOwnIdentites);
+ }
+
+ private FcpConnection createConnectionThatSendsOtherMessage() {
+ return createFcpConnection(message -> (listener, connection) -> {
+ Map<String, String> fields = createWebOfTrustReplyFields("OtherMessage", true);
+ FcpMessage replyMessage = createPluginReply(message, fields);
+ listener.receivedFCPPluginReply(connection, new FCPPluginReply(replyMessage, null));
+ });
+ }
private static WebOfTrustPlugin createWebOfTrustPlugin(FcpConnection fcpConnection) {
return new WebOfTrustPlugin(new FcpClient(fcpConnection));