about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/config/stub_accounts.c2
-rw-r--r--tests/unittests/log/stub_log.c2
-rw-r--r--tests/unittests/otr/stub_otr.c10
-rw-r--r--tests/unittests/pgp/stub_gpg.c40
-rw-r--r--tests/unittests/test_cmd_account.c26
-rw-r--r--tests/unittests/test_cmd_connect.c6
-rw-r--r--tests/unittests/test_cmd_join.c8
-rw-r--r--tests/unittests/test_cmd_otr.c68
-rw-r--r--tests/unittests/test_cmd_otr.h4
-rw-r--r--tests/unittests/test_cmd_pgp.c129
-rw-r--r--tests/unittests/test_cmd_pgp.h17
-rw-r--r--tests/unittests/test_server_events.c6
-rw-r--r--tests/unittests/ui/stub_ui.c3
-rw-r--r--tests/unittests/unittests.c25
-rw-r--r--tests/unittests/xmpp/stub_xmpp.c10
15 files changed, 257 insertions, 99 deletions
diff --git a/tests/unittests/config/stub_accounts.c b/tests/unittests/config/stub_accounts.c
index 32a80fda..c046be86 100644
--- a/tests/unittests/config/stub_accounts.c
+++ b/tests/unittests/config/stub_accounts.c
@@ -122,6 +122,7 @@ void accounts_set_otr_policy(const char * const account_name, const char * const
 }
 
 void accounts_set_last_presence(const char * const account_name, const char * const value) {}
+void accounts_set_pgp_keyid(const char * const account_name, const char * const value) {}
 
 void accounts_set_login_presence(const char * const account_name, const char * const value)
 {
@@ -182,4 +183,5 @@ void accounts_clear_eval_password(const char * const account_name) {}
 void accounts_clear_server(const char * const account_name) {}
 void accounts_clear_port(const char * const account_name) {}
 void accounts_clear_otr(const char * const account_name) {}
+void accounts_clear_pgp_keyid(const char * const account_name) {}
 void accounts_add_otr_policy(const char * const account_name, const char * const contact_jid, const char * const policy) {}
diff --git a/tests/unittests/log/stub_log.c b/tests/unittests/log/stub_log.c
index f88871a7..c25057d8 100644
--- a/tests/unittests/log/stub_log.c
+++ b/tests/unittests/log/stub_log.c
@@ -53,10 +53,12 @@ void chat_log_init(void) {}
 
 void chat_log_msg_out(const char * const barejid, const char * const msg) {}
 void chat_log_otr_msg_out(const char * const barejid, const char * const msg) {}
+void chat_log_pgp_msg_out(const char * const barejid, const char * const msg) {}
 
 void chat_log_msg_in(const char * const barejid, const char * const msg) {}
 void chat_log_msg_in_delayed(const char * const barejid, const char * msg, GTimeVal *tv_stamp) {}
 void chat_log_otr_msg_in(const char * const barejid, const char * const msg, gboolean was_decrypted) {}
+void chat_log_pgp_msg_in(const char * const barejid, const char * const msg) {}
 
 void chat_log_close(void) {}
 GSList * chat_log_get_previous(const gchar * const login,
diff --git a/tests/unittests/otr/stub_otr.c b/tests/unittests/otr/stub_otr.c
index 482f0a7f..098484d5 100644
--- a/tests/unittests/otr/stub_otr.c
+++ b/tests/unittests/otr/stub_otr.c
@@ -41,8 +41,14 @@ char* otr_start_query(void)
 
 void otr_poll(void) {}
 void otr_on_connect(ProfAccount *account) {}
-void otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message) {}
-void otr_on_message_send(ProfChatWin *chatwin, const char * const message) {}
+char* otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *was_decrypted)
+{
+    return NULL;
+}
+gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message)
+{
+    return FALSE;
+}
 
 void otr_keygen(ProfAccount *account)
 {
diff --git a/tests/unittests/pgp/stub_gpg.c b/tests/unittests/pgp/stub_gpg.c
new file mode 100644
index 00000000..03b58b55
--- /dev/null
+++ b/tests/unittests/pgp/stub_gpg.c
@@ -0,0 +1,40 @@
+#include <glib.h>
+
+#include "pgp/gpg.h"
+
+void p_gpg_init(void) {}
+void p_gpg_close(void) {}
+
+GSList* p_gpg_list_keys(void)
+{
+    return NULL;
+}
+
+GHashTable*
+p_gpg_fingerprints(void)
+{
+    return NULL;
+}
+
+const char* p_gpg_libver(void)
+{
+    return NULL;
+}
+
+void p_gpg_free_key(ProfPGPKey *key) {}
+
+void p_gpg_verify(const char * const barejid, const char *const sign) {}
+
+char* p_gpg_sign(const char * const str, const char * const fp)
+{
+    return NULL;
+}
+
+gboolean p_gpg_available(const char * const barejid)
+{
+    return FALSE;
+}
+char * p_gpg_decrypt(const char * const barejid, const char * const cipher)
+{
+    return NULL;
+}
diff --git a/tests/unittests/test_cmd_account.c b/tests/unittests/test_cmd_account.c
index a0f71bc8..8aa13609 100644
--- a/tests/unittests/test_cmd_account.c
+++ b/tests/unittests/test_cmd_account.c
@@ -36,7 +36,7 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state)
 {
     CommandHelp *help = malloc(sizeof(CommandHelp));
     ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
-        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
     gchar *args[] = { NULL };
 
     will_return(jabber_get_connection_status, JABBER_CONNECTED);
@@ -109,7 +109,7 @@ void cmd_account_show_shows_account_when_exists(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "show", "account_name", NULL };
     ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
-        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     expect_any(accounts_get_account, name);
     will_return(accounts_get_account, account);
@@ -478,7 +478,7 @@ void cmd_account_set_password_sets_password(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
     ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
-    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
 
     expect_any(accounts_account_exists, account_name);
@@ -504,7 +504,7 @@ void cmd_account_set_eval_password_sets_eval_password(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
     ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
-    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
 
     expect_any(accounts_account_exists, account_name);
@@ -529,7 +529,7 @@ void cmd_account_set_password_when_eval_password_set(void **state) {
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
     ProfAccount *account = account_new("a_account", NULL, NULL, "a_password",
-    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
 
     expect_any(accounts_account_exists, account_name);
@@ -550,7 +550,7 @@ void cmd_account_set_eval_password_when_password_set(void **state) {
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
     ProfAccount *account = account_new("a_account", NULL, "a_password", NULL,
-    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+    TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
 
     expect_any(accounts_account_exists, account_name);
@@ -927,6 +927,7 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "set", "a_account", "online", "10", NULL };
 
+
     expect_any(accounts_account_exists, account_name);
     will_return(accounts_account_exists, TRUE);
 
@@ -934,16 +935,27 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
     expect_any(accounts_set_priority_online, value);
 
     will_return(jabber_get_connection_status, JABBER_CONNECTED);
-    will_return(jabber_get_account_name, "a_account");
 
     expect_any(accounts_get_last_presence, account_name);
     will_return(accounts_get_last_presence, RESOURCE_ONLINE);
 
+    will_return(jabber_get_account_name, "a_account");
+
+#ifdef HAVE_LIBGPGME
+    ProfAccount *account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource",
+        NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
+    will_return(jabber_get_account_name, "a_account");
+    expect_any(accounts_get_account, name);
+    will_return(accounts_get_account, account);
+#endif
+
     will_return(jabber_get_presence_message, "Free to chat");
 
     expect_value(presence_send, status, RESOURCE_ONLINE);
     expect_string(presence_send, msg, "Free to chat");
     expect_value(presence_send, idle, 0);
+    expect_value(presence_send, signed_status, NULL);
 
     expect_cons_show("Updated online priority for account a_account: 10");
     expect_cons_show("");
diff --git a/tests/unittests/test_cmd_connect.c b/tests/unittests/test_cmd_connect.c
index de79ef29..b812bf23 100644
--- a/tests/unittests/test_cmd_connect.c
+++ b/tests/unittests/test_cmd_connect.c
@@ -411,7 +411,7 @@ void cmd_connect_asks_password_when_not_in_account(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "jabber_org", NULL };
     ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
-        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
 
@@ -436,7 +436,7 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "jabber_org", NULL };
     ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL,
-        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
 
@@ -459,7 +459,7 @@ void cmd_connect_connects_with_account(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { "jabber_org", NULL };
     ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL,
-        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
 
diff --git a/tests/unittests/test_cmd_join.c b/tests/unittests/test_cmd_join.c
index 478f1c7d..cdb275d9 100644
--- a/tests/unittests/test_cmd_join.c
+++ b/tests/unittests/test_cmd_join.c
@@ -76,7 +76,7 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { room, "nick", nick, NULL };
     ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
-        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
@@ -104,7 +104,7 @@ void cmd_join_uses_supplied_nick(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { room, "nick", nick, NULL };
     ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
-        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
@@ -132,7 +132,7 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { room, NULL };
     ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
-        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
@@ -163,7 +163,7 @@ void cmd_join_uses_password_when_supplied(void **state)
     CommandHelp *help = malloc(sizeof(CommandHelp));
     gchar *args[] = { room, "password", password, NULL };
     ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
-        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c
index dc0cd907..7d4a3291 100644
--- a/tests/unittests/test_cmd_otr.c
+++ b/tests/unittests/test_cmd_otr.c
@@ -167,68 +167,6 @@ void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
     free(help);
 }
 
-void cmd_otr_warn_shows_usage_when_no_args(void **state)
-{
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-    help->usage = "Some usage";
-    gchar *args[] = { "warn", NULL };
-
-    expect_cons_show("Usage: Some usage");
-
-    gboolean result = cmd_otr(NULL, args, *help);
-    assert_true(result);
-
-    free(help);
-}
-
-void cmd_otr_warn_shows_usage_when_invalid_arg(void **state)
-{
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-    help->usage = "Some usage";
-    gchar *args[] = { "warn", "badarg", NULL };
-
-    expect_cons_show("Usage: Some usage");
-
-    gboolean result = cmd_otr(NULL, args, *help);
-    assert_true(result);
-
-    free(help);
-}
-
-void cmd_otr_warn_on_enables_unencrypted_warning(void **state)
-{
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-    gchar *args[] = { "warn", "on", NULL };
-    prefs_set_boolean(PREF_OTR_WARN, FALSE);
-
-    expect_cons_show("OTR warning message enabled.");
-
-    gboolean result = cmd_otr(NULL, args, *help);
-    gboolean otr_warn_enabled = prefs_get_boolean(PREF_OTR_WARN);
-
-    assert_true(result);
-    assert_true(otr_warn_enabled);
-
-    free(help);
-}
-
-void cmd_otr_warn_off_disables_unencrypted_warning(void **state)
-{
-    CommandHelp *help = malloc(sizeof(CommandHelp));
-    gchar *args[] = { "warn", "off", NULL };
-    prefs_set_boolean(PREF_OTR_WARN, TRUE);
-
-    expect_cons_show("OTR warning message disabled.");
-
-    gboolean result = cmd_otr(NULL, args, *help);
-    gboolean otr_warn_enabled = prefs_get_boolean(PREF_OTR_WARN);
-
-    assert_true(result);
-    assert_false(otr_warn_enabled);
-
-    free(help);
-}
-
 void cmd_otr_libver_shows_libotr_version(void **state)
 {
     CommandHelp *help = malloc(sizeof(CommandHelp));
@@ -309,7 +247,7 @@ void cmd_otr_gen_generates_key_for_connected_account(void **state)
     gchar *args[] = { "gen", NULL };
     char *account_name = "myaccount";
     ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL,
-        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(jabber_get_connection_status, JABBER_CONNECTED);
     will_return(jabber_get_account_name, account_name);
@@ -576,8 +514,8 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
     will_return(otr_key_loaded, TRUE);
     will_return(otr_start_query, query_message);
 
-    expect_string(message_send_chat_encrypted, barejid, recipient);
-    expect_string(message_send_chat_encrypted, msg, query_message);
+    expect_string(message_send_chat_otr, barejid, recipient);
+    expect_string(message_send_chat_otr, msg, query_message);
 
     gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help);
     assert_true(result);
diff --git a/tests/unittests/test_cmd_otr.h b/tests/unittests/test_cmd_otr.h
index 8ef182e9..469d7c54 100644
--- a/tests/unittests/test_cmd_otr.h
+++ b/tests/unittests/test_cmd_otr.h
@@ -10,10 +10,6 @@ void cmd_otr_log_off_disables_logging(void **state);
 void cmd_otr_redact_redacts_logging(void **state);
 void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state);
 void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state);
-void cmd_otr_warn_shows_usage_when_no_args(void **state);
-void cmd_otr_warn_shows_usage_when_invalid_arg(void **state);
-void cmd_otr_warn_on_enables_unencrypted_warning(void **state);
-void cmd_otr_warn_off_disables_unencrypted_warning(void **state);
 void cmd_otr_libver_shows_libotr_version(void **state);
 void cmd_otr_gen_shows_message_when_not_connected(void **state);
 void cmd_otr_gen_generates_key_for_connected_account(void **state);
diff --git a/tests/unittests/test_cmd_pgp.c b/tests/unittests/test_cmd_pgp.c
new file mode 100644
index 00000000..aef4baf7
--- /dev/null
+++ b/tests/unittests/test_cmd_pgp.c
@@ -0,0 +1,129 @@
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "config.h"
+
+#include "command/commands.h"
+
+#include "ui/stub_ui.h"
+
+#ifdef HAVE_LIBGPGME
+void cmd_pgp_shows_usage_when_no_args(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "Some usage";
+    gchar *args[] = { NULL };
+
+    expect_cons_show("Usage: Some usage");
+
+    gboolean result = cmd_pgp(NULL, args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "Some usage";
+    gchar *args[] = { "start", NULL };
+    ProfWin window;
+    window.type = WIN_CHAT;
+
+    will_return(jabber_get_connection_status, conn_status);
+
+    expect_cons_show("You must be connected to start PGP encrpytion.");
+
+    gboolean result = cmd_pgp(&window, args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_pgp_start_shows_message_when_disconnected(void **state)
+{
+    cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTED);
+}
+
+void cmd_pgp_start_shows_message_when_disconnecting(void **state)
+{
+    cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTING);
+}
+
+void cmd_pgp_start_shows_message_when_connecting(void **state)
+{
+    cmd_pgp_start_shows_message_when_connection(JABBER_CONNECTING);
+}
+
+void cmd_pgp_start_shows_message_when_undefined(void **state)
+{
+    cmd_pgp_start_shows_message_when_connection(JABBER_UNDEFINED);
+}
+
+void cmd_pgp_start_shows_message_when_started(void **state)
+{
+    cmd_pgp_start_shows_message_when_connection(JABBER_STARTED);
+}
+
+void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    help->usage = "Some usage";
+    gchar *args[] = { "start", NULL };
+    ProfWin window;
+    window.type = wintype;
+
+    will_return(jabber_get_connection_status, JABBER_CONNECTED);
+
+    expect_cons_show("You must be in a regular chat window to start PGP encrpytion.");
+
+    gboolean result = cmd_pgp(&window, args, *help);
+    assert_true(result);
+
+    free(help);
+}
+
+void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state)
+{
+    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONSOLE);
+}
+
+void cmd_pgp_start_shows_message_when_no_arg_in_muc(void **state)
+{
+    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC);
+}
+
+void cmd_pgp_start_shows_message_when_no_arg_in_mucconf(void **state)
+{
+    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC_CONFIG);
+}
+
+void cmd_pgp_start_shows_message_when_no_arg_in_private(void **state)
+{
+    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_PRIVATE);
+}
+
+void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state)
+{
+    cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_XML);
+}
+
+#else
+void cmd_pgp_shows_message_when_pgp_unsupported(void **state)
+{
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { "gen", NULL };
+
+    expect_cons_show("This version of Profanity has not been built with PGP support enabled");
+
+    gboolean result = cmd_pgp(NULL, args, *help);
+    assert_true(result);
+
+    free(help);
+}
+#endif
diff --git a/tests/unittests/test_cmd_pgp.h b/tests/unittests/test_cmd_pgp.h
new file mode 100644
index 00000000..fcb24500
--- /dev/null
+++ b/tests/unittests/test_cmd_pgp.h
@@ -0,0 +1,17 @@
+#include "config.h"
+
+#ifdef HAVE_LIBGPGME
+void cmd_pgp_shows_usage_when_no_args(void **state);
+void cmd_pgp_start_shows_message_when_disconnected(void **state);
+void cmd_pgp_start_shows_message_when_disconnecting(void **state);
+void cmd_pgp_start_shows_message_when_connecting(void **state);
+void cmd_pgp_start_shows_message_when_undefined(void **state);
+void cmd_pgp_start_shows_message_when_started(void **state);
+void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state);
+void cmd_pgp_start_shows_message_when_no_arg_in_muc(void **state);
+void cmd_pgp_start_shows_message_when_no_arg_in_mucconf(void **state);
+void cmd_pgp_start_shows_message_when_no_arg_in_private(void **state);
+void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state);
+#else
+void cmd_pgp_shows_message_when_pgp_unsupported(void **state);
+#endif
diff --git a/tests/unittests/test_server_events.c b/tests/unittests/test_server_events.c
index 58489807..fac1ac38 100644
--- a/tests/unittests/test_server_events.c
+++ b/tests/unittests/test_server_events.c
@@ -26,7 +26,7 @@ void console_shows_online_presence_when_set_online(void **state)
     expect_memory(ui_contact_online, resource, resource, sizeof(resource));
     expect_value(ui_contact_online, last_activity, NULL);
 
-    sv_ev_contact_online(barejid, resource, NULL);
+    sv_ev_contact_online(barejid, resource, NULL, NULL);
 
     roster_clear();
 }
@@ -43,7 +43,7 @@ void console_shows_online_presence_when_set_all(void **state)
     expect_memory(ui_contact_online, resource, resource, sizeof(resource));
     expect_value(ui_contact_online, last_activity, NULL);
 
-    sv_ev_contact_online(barejid, resource, NULL);
+    sv_ev_contact_online(barejid, resource, NULL, NULL);
 
     roster_clear();
 }
@@ -60,7 +60,7 @@ void console_shows_dnd_presence_when_set_all(void **state)
     expect_memory(ui_contact_online, resource, resource, sizeof(resource));
     expect_value(ui_contact_online, last_activity, NULL);
 
-    sv_ev_contact_online(barejid, resource, NULL);
+    sv_ev_contact_online(barejid, resource, NULL, NULL);
 
     roster_clear();
 }
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index 8ad3f236..6d008414 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -179,7 +179,7 @@ void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activi
 }
 
 void ui_contact_typing(const char * const barejid, const char * const resource) {}
-void ui_incoming_msg(const char * const from, const char * const resource, const char * const message, GTimeVal *tv_stamp) {}
+void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GTimeVal *tv_stamp, gboolean win_created) {}
 void ui_message_receipt(const char * const barejid, const char * const id) {}
 
 void ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp) {}
@@ -447,6 +447,7 @@ void cons_roster_setting(void) {}
 void cons_presence_setting(void) {}
 void cons_wrap_setting(void) {}
 void cons_winstidy_setting(void) {}
+void cons_encwarn_setting(void) {}
 void cons_time_setting(void) {}
 void cons_mouse_setting(void) {}
 void cons_statuses_setting(void) {}
diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c
index 3f860178..d20cf0b2 100644
--- a/tests/unittests/unittests.c
+++ b/tests/unittests/unittests.c
@@ -21,6 +21,7 @@
 #include "test_cmd_sub.h"
 #include "test_cmd_statuses.h"
 #include "test_cmd_otr.h"
+#include "test_cmd_pgp.h"
 #include "test_jid.h"
 #include "test_parser.h"
 #include "test_roster_list.h"
@@ -499,14 +500,6 @@ int main(int argc, char* argv[]) {
         unit_test_setup_teardown(cmd_otr_log_redact_shows_warning_when_chlog_disabled,
             load_preferences,
             close_preferences),
-        unit_test(cmd_otr_warn_shows_usage_when_no_args),
-        unit_test(cmd_otr_warn_shows_usage_when_invalid_arg),
-        unit_test_setup_teardown(cmd_otr_warn_on_enables_unencrypted_warning,
-            load_preferences,
-            close_preferences),
-        unit_test_setup_teardown(cmd_otr_warn_off_disables_unencrypted_warning,
-            load_preferences,
-            close_preferences),
         unit_test(cmd_otr_libver_shows_libotr_version),
         unit_test(cmd_otr_gen_shows_message_when_not_connected),
         unit_test(cmd_otr_gen_generates_key_for_connected_account),
@@ -539,6 +532,22 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_otr_shows_message_when_otr_unsupported),
 #endif
 
+#ifdef HAVE_LIBGPGME
+        unit_test(cmd_pgp_shows_usage_when_no_args),
+        unit_test(cmd_pgp_start_shows_message_when_disconnected),
+        unit_test(cmd_pgp_start_shows_message_when_disconnecting),
+        unit_test(cmd_pgp_start_shows_message_when_connecting),
+        unit_test(cmd_pgp_start_shows_message_when_undefined),
+        unit_test(cmd_pgp_start_shows_message_when_started),
+        unit_test(cmd_pgp_start_shows_message_when_no_arg_in_console),
+        unit_test(cmd_pgp_start_shows_message_when_no_arg_in_muc),
+        unit_test(cmd_pgp_start_shows_message_when_no_arg_in_mucconf),
+        unit_test(cmd_pgp_start_shows_message_when_no_arg_in_private),
+        unit_test(cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole),
+#else
+        unit_test(cmd_pgp_shows_message_when_pgp_unsupported),
+#endif
+
         unit_test(cmd_join_shows_message_when_disconnecting),
         unit_test(cmd_join_shows_message_when_connecting),
         unit_test(cmd_join_shows_message_when_disconnected),
diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c
index d3be1af6..79f2595a 100644
--- a/tests/unittests/xmpp/stub_xmpp.c
+++ b/tests/unittests/xmpp/stub_xmpp.c
@@ -65,13 +65,18 @@ char* message_send_chat(const char * const barejid, const char * const msg)
     return NULL;
 }
 
-char* message_send_chat_encrypted(const char * const barejid, const char * const msg)
+char* message_send_chat_otr(const char * const barejid, const char * const msg)
 {
     check_expected(barejid);
     check_expected(msg);
     return NULL;
 }
 
+char* message_send_chat_pgp(const char * const barejid, const char * const msg)
+{
+    return NULL;
+}
+
 void message_send_private(const char * const fulljid, const char * const msg) {}
 void message_send_groupchat(const char * const roomjid, const char * const msg) {}
 void message_send_groupchat_subject(const char * const roomjid, const char * const subject) {}
@@ -114,11 +119,12 @@ void presence_join_room(char *room, char *nick, char * passwd)
 void presence_change_room_nick(const char * const room, const char * const nick) {}
 void presence_leave_chat_room(const char * const room_jid) {}
 
-void presence_send(resource_presence_t status, const char * const msg, int idle)
+void presence_send(resource_presence_t status, const char * const msg, int idle, char *signed_status)
 {
     check_expected(status);
     check_expected(msg);
     check_expected(idle);
+    check_expected(signed_status);
 }
 
 gboolean presence_sub_request_exists(const char * const bare_jid)