diff options
author | James Booth <boothj5@gmail.com> | 2015-01-13 23:48:07 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-01-13 23:48:07 +0000 |
commit | a65abed1fbb33c839cadc5e549b43e5f908b59a3 (patch) | |
tree | 33bc61aeb1438405484de5811e8be3a75c689d30 /tests | |
parent | 844cd2dda713458d10c1db323cdb76aed0d9b46b (diff) | |
parent | f6da9444794f6faa984f68c8f54849a170fe0e59 (diff) | |
download | profani-tty-a65abed1fbb33c839cadc5e549b43e5f908b59a3.tar.gz |
Merge remote-tracking branch 'peterlvilim/keyring'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cmd_account.c | 68 | ||||
-rw-r--r-- | tests/test_cmd_account.h | 5 | ||||
-rw-r--r-- | tests/testsuite.c | 3 |
3 files changed, 75 insertions, 1 deletions
diff --git a/tests/test_cmd_account.c b/tests/test_cmd_account.c index 553b0d83..d02fc5ba 100644 --- a/tests/test_cmd_account.c +++ b/tests/test_cmd_account.c @@ -499,6 +499,74 @@ void cmd_account_set_password_sets_password(void **state) free(help); } +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); + + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_string(accounts_get_account, name, "a_account"); + will_return(accounts_get_account, account); + + expect_string(accounts_set_eval_password, account_name, "a_account"); + expect_string(accounts_set_eval_password, value, "a_password"); + + expect_cons_show("Updated eval_password for account a_account"); + expect_cons_show(""); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + +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); + + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_string(accounts_get_account, name, "a_account"); + will_return(accounts_get_account, account); + + expect_cons_show("Cannot set password when eval_password is set."); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + +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); + + + expect_any(accounts_account_exists, account_name); + will_return(accounts_account_exists, TRUE); + + expect_string(accounts_get_account, name, "a_account"); + will_return(accounts_get_account, account); + + expect_cons_show("Cannot set eval_password when password is set."); + + gboolean result = cmd_account(args, *help); + assert_true(result); + + free(help); +} + void cmd_account_set_muc_sets_muc(void **state) { CommandHelp *help = malloc(sizeof(CommandHelp)); diff --git a/tests/test_cmd_account.h b/tests/test_cmd_account.h index d7fc6266..91bd1e70 100644 --- a/tests/test_cmd_account.h +++ b/tests/test_cmd_account.h @@ -26,6 +26,9 @@ void cmd_account_set_jid_sets_resource(void **state); void cmd_account_set_server_sets_server(void **state); void cmd_account_set_resource_sets_resource(void **state); void cmd_account_set_password_sets_password(void **state); +void cmd_account_set_eval_password_sets_eval_password(void **state); +void cmd_account_set_password_when_eval_password_set(void **state); +void cmd_account_set_eval_password_when_password_set(void **state); void cmd_account_set_muc_sets_muc(void **state); void cmd_account_set_nick_sets_nick(void **state); void cmd_account_show_message_for_missing_otr_policy(void **state); @@ -49,4 +52,4 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese void cmd_account_clear_shows_usage_when_no_args(void **state); void cmd_account_clear_shows_usage_when_one_arg(void **state); void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_clear_shows_message_when_invalid_property(void **state); \ No newline at end of file +void cmd_account_clear_shows_message_when_invalid_property(void **state); diff --git a/tests/testsuite.c b/tests/testsuite.c index eb039cbe..32d298cf 100644 --- a/tests/testsuite.c +++ b/tests/testsuite.c @@ -331,6 +331,9 @@ int main(int argc, char* argv[]) { unit_test(cmd_account_set_server_sets_server), unit_test(cmd_account_set_resource_sets_resource), unit_test(cmd_account_set_password_sets_password), + unit_test(cmd_account_set_eval_password_sets_eval_password), + unit_test(cmd_account_set_password_when_eval_password_set), + unit_test(cmd_account_set_eval_password_when_password_set), unit_test(cmd_account_set_muc_sets_muc), unit_test(cmd_account_set_nick_sets_nick), unit_test(cmd_account_show_message_for_missing_otr_policy), |