diff --git a/tests/config/mock_accounts.c b/tests/config/mock_accounts.c index 3174cb35..e2732acb 100644 --- a/tests/config/mock_accounts.c +++ b/tests/config/mock_accounts.c @@ -110,6 +110,7 @@ gint accounts_get_priority_for_presence_type(const char * const account_name, } void accounts_clear_password(const char * const account_name) {} + char * accounts_create_full_jid(ProfAccount *account) { return (char *)mock(); diff --git a/tests/test_cmd_connect.c b/tests/test_cmd_connect.c index a05267ea..e07543f8 100644 --- a/tests/test_cmd_connect.c +++ b/tests/test_cmd_connect.c @@ -144,3 +144,29 @@ void cmd_connect_lowercases_argument(void **state) free(help); } + +void cmd_connect_asks_password_when_not_in_account(void **state) +{ + CommandHelp *help = malloc(sizeof(CommandHelp)); + gchar *args[] = { "jabber_org", NULL }; + ProfAccount *account = malloc(sizeof(ProfAccount)); + account->password = NULL; + + will_return(jabber_get_connection_status, JABBER_DISCONNECTED); + + expect_any(accounts_get_account, name); + will_return(accounts_get_account, account); + + will_return(accounts_create_full_jid, strdup("user@jabber.org")); + + will_return(ui_ask_password, strdup("password")); + + expect_any(cons_show, output); + will_return(jabber_connect_with_account, JABBER_CONNECTING); + + gboolean result = cmd_connect(args, *help); + assert_true(result); + + free(help); + free(account); +} diff --git a/tests/test_cmd_connect.h b/tests/test_cmd_connect.h index 3f9e72a8..5349442b 100644 --- a/tests/test_cmd_connect.h +++ b/tests/test_cmd_connect.h @@ -6,3 +6,4 @@ void cmd_connect_when_no_account(void **state); void cmd_connect_with_altdomain_when_provided(void **state); void cmd_connect_fail_message(void **state); void cmd_connect_lowercases_argument(void **state); +void cmd_connect_asks_password_when_not_in_account(void **state); diff --git a/tests/testsuite.c b/tests/testsuite.c index d02787e3..b88037e2 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -22,6 +22,7 @@ int main(int argc, char* argv[]) { unit_test(cmd_connect_with_altdomain_when_provided), unit_test(cmd_connect_fail_message), unit_test(cmd_connect_lowercases_argument), + unit_test(cmd_connect_asks_password_when_not_in_account), unit_test(cmd_rooms_shows_message_when_disconnected), unit_test(cmd_rooms_shows_message_when_disconnecting),