Fix broken support for case-sensitive account names

Don't lower account name before calling accounts_get_account().
Only lower if there is no account with the given name and the name is
interpreted as a jid.
Updated unittests to test this behaviour.

Fixes #725

.
This commit is contained in:
Philip Flohr
2019-02-22 11:07:19 +01:00
parent 6034b833be
commit 5b7f9dffbc
4 changed files with 35 additions and 13 deletions

View File

@@ -89,29 +89,49 @@ void cmd_connect_fail_message(void **state)
assert_true(result);
}
void cmd_connect_lowercases_argument(void **state)
void cmd_connect_lowercases_argument_with_no_account(void **state)
{
gchar *args[] = { "USER@server.ORG", NULL };
will_return(connection_get_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
expect_string(accounts_get_account, name, "USER@server.ORG");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_cons_show("Connecting as user@server.org");
expect_any(session_connect_with_details, jid);
expect_any(session_connect_with_details, passwd);
expect_any(session_connect_with_details, altdomain);
expect_any(session_connect_with_details, port);
expect_string(session_connect_with_details, jid, "user@server.org");
expect_string(session_connect_with_details, passwd, "password");
expect_value(session_connect_with_details, altdomain, NULL);
expect_value(session_connect_with_details, port, 0);
will_return(session_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_lowercases_argument_with_account(void **state)
{
gchar *args[] = { "Jabber_org", NULL };
ProfAccount *account = account_new("Jabber_org", "me@jabber.org", "password", NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
will_return(connection_get_status, JABBER_DISCONNECTED);
expect_any(accounts_get_account, name);
will_return(accounts_get_account, account);
expect_cons_show("Connecting with account Jabber_org as me@jabber.org");
expect_memory(session_connect_with_account, account, account, sizeof(account));
will_return(session_connect_with_account, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_asks_password_when_not_in_account(void **state)
{
gchar *args[] = { "jabber_org", NULL };

View File

@@ -5,7 +5,8 @@ void cmd_connect_shows_message_when_undefined(void **state);
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_lowercases_argument_with_no_account(void **state);
void cmd_connect_lowercases_argument_with_account(void **state);
void cmd_connect_asks_password_when_not_in_account(void **state);
void cmd_connect_shows_message_when_connecting_with_account(void **state);
void cmd_connect_connects_with_account(void **state);

View File

@@ -244,7 +244,10 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(cmd_connect_fail_message,
load_preferences,
close_preferences),
unit_test_setup_teardown(cmd_connect_lowercases_argument,
unit_test_setup_teardown(cmd_connect_lowercases_argument_with_account,
load_preferences,
close_preferences),
unit_test_setup_teardown(cmd_connect_lowercases_argument_with_no_account,
load_preferences,
close_preferences),
unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account,