diff options
author | James Booth <boothj5@gmail.com> | 2014-03-08 21:50:55 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-03-08 21:50:55 +0000 |
commit | 15fce2cf9597cc5fa243a121313a906b79ea4c22 (patch) | |
tree | 7966f0f040f13f30c81c7fbb5071b124113db7f0 | |
parent | baf46c6ae54071054caaea6c77b0b55cd17a3593 (diff) | |
download | profani-tty-15fce2cf9597cc5fa243a121313a906b79ea4c22.tar.gz |
Test for password usage on /join
-rw-r--r-- | tests/test_cmd_join.c | 30 | ||||
-rw-r--r-- | tests/test_cmd_join.h | 1 | ||||
-rw-r--r-- | tests/testsuite.c | 1 |
3 files changed, 32 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); +} diff --git a/tests/test_cmd_join.h b/tests/test_cmd_join.h index c4e9234f..812aee87 100644 --- a/tests/test_cmd_join.h +++ b/tests/test_cmd_join.h @@ -7,3 +7,4 @@ void cmd_join_shows_error_message_when_invalid_room_jid(void **state); void cmd_join_uses_account_mucservice_when_no_service_specified(void **state); void cmd_join_uses_supplied_nick(void **state); void cmd_join_uses_account_nick_when_not_supplied(void **state); +void cmd_join_uses_password_when_supplied(void **state); diff --git a/tests/testsuite.c b/tests/testsuite.c index ee929435..0c2101f3 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -496,6 +496,7 @@ int main(int argc, char* argv[]) { unit_test(cmd_join_uses_account_mucservice_when_no_service_specified), unit_test(cmd_join_uses_supplied_nick), unit_test(cmd_join_uses_account_nick_when_not_supplied), + unit_test(cmd_join_uses_password_when_supplied), }; return run_tests(all_tests); |