about summary refs log tree commit diff stats
path: root/tests/test_cmd_join.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-03-08 21:50:55 +0000
committerJames Booth <boothj5@gmail.com>2014-03-08 21:50:55 +0000
commit15fce2cf9597cc5fa243a121313a906b79ea4c22 (patch)
tree7966f0f040f13f30c81c7fbb5071b124113db7f0 /tests/test_cmd_join.c
parentbaf46c6ae54071054caaea6c77b0b55cd17a3593 (diff)
downloadprofani-tty-15fce2cf9597cc5fa243a121313a906b79ea4c22.tar.gz
Test for password usage on /join
Diffstat (limited to 'tests/test_cmd_join.c')
-rw-r--r--tests/test_cmd_join.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_cmd_join.c b/tests/test_cmd_join.c
index 871e3295..19e4de9a 100644
--- a/tests/test_cmd_join.c
+++ b/tests/test_cmd_join.c
@@ -170,3 +170,33 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
 
     free(help);
 }
+
+void cmd_join_uses_password_when_supplied(void **state)
+{
+    char *account_name = "an_account";
+    char *room = "room";
+    char *password = "a_password";
+    char *account_nick = "a_nick";
+    char *account_service = "a_service";
+    char *expected_room = "room@a_service";
+    CommandHelp *help = malloc(sizeof(CommandHelp));
+    gchar *args[] = { room, "passwd", password, NULL };
+    ProfAccount *account = account_new(account_name, "user@server.org", NULL,
+        TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick);
+
+    muc_init();
+
+    mock_connection_status(JABBER_CONNECTED);
+    mock_connection_account_name(account_name);
+    mock_accounts_get_account();
+    accounts_get_account_expect_and_return(account_name, account);
+
+    mock_presence_join_room();
+    presence_join_room_expect(expected_room, account_nick, password);
+    ui_room_join_expect(expected_room);
+
+    gboolean result = cmd_join(args, *help);
+    assert_true(result);
+
+    free(help);
+}