about summary refs log tree commit diff stats
path: root/tests/test_cmd_account.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-01-13 23:48:07 +0000
committerJames Booth <boothj5@gmail.com>2015-01-13 23:48:07 +0000
commita65abed1fbb33c839cadc5e549b43e5f908b59a3 (patch)
tree33bc61aeb1438405484de5811e8be3a75c689d30 /tests/test_cmd_account.c
parent844cd2dda713458d10c1db323cdb76aed0d9b46b (diff)
parentf6da9444794f6faa984f68c8f54849a170fe0e59 (diff)
downloadprofani-tty-a65abed1fbb33c839cadc5e549b43e5f908b59a3.tar.gz
Merge remote-tracking branch 'peterlvilim/keyring'
Diffstat (limited to 'tests/test_cmd_account.c')
-rw-r--r--tests/test_cmd_account.c68
1 files changed, 68 insertions, 0 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));