mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Merge pull request #1033 from philipflohr/master
Fix broken support for case-sensitive account names
This commit is contained in:
commit
681e5de523
@ -386,12 +386,11 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *lower = g_utf8_strdown(user, -1);
|
|
||||||
char *jid;
|
char *jid;
|
||||||
g_free(def);
|
g_free(def);
|
||||||
|
|
||||||
// connect with account
|
// connect with account
|
||||||
ProfAccount *account = accounts_get_account(lower);
|
ProfAccount *account = accounts_get_account(user);
|
||||||
if (account) {
|
if (account) {
|
||||||
// override account options with connect options
|
// override account options with connect options
|
||||||
if (altdomain != NULL)
|
if (altdomain != NULL)
|
||||||
@ -414,7 +413,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
|||||||
account->password = NULL;
|
account->password = NULL;
|
||||||
} else {
|
} else {
|
||||||
cons_show("Error evaluating password, see logs for details.");
|
cons_show("Error evaluating password, see logs for details.");
|
||||||
g_free(lower);
|
g_free(user);
|
||||||
account_free(account);
|
account_free(account);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -432,7 +431,7 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
|||||||
|
|
||||||
// connect with JID
|
// connect with JID
|
||||||
} else {
|
} else {
|
||||||
jid = strdup(lower);
|
jid = g_utf8_strdown(user, -1);
|
||||||
char *passwd = ui_ask_password();
|
char *passwd = ui_ask_password();
|
||||||
conn_status = cl_ev_connect_jid(jid, passwd, altdomain, port, tls_policy);
|
conn_status = cl_ev_connect_jid(jid, passwd, altdomain, port, tls_policy);
|
||||||
free(passwd);
|
free(passwd);
|
||||||
@ -444,7 +443,6 @@ cmd_connect(ProfWin *window, const char *const command, gchar **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
options_destroy(options);
|
options_destroy(options);
|
||||||
g_free(lower);
|
|
||||||
free(jid);
|
free(jid);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -89,29 +89,49 @@ void cmd_connect_fail_message(void **state)
|
|||||||
assert_true(result);
|
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 };
|
gchar *args[] = { "USER@server.ORG", NULL };
|
||||||
|
|
||||||
will_return(connection_get_status, JABBER_DISCONNECTED);
|
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(accounts_get_account, NULL);
|
||||||
|
|
||||||
will_return(ui_ask_password, strdup("password"));
|
will_return(ui_ask_password, strdup("password"));
|
||||||
|
|
||||||
expect_cons_show("Connecting as user@server.org");
|
expect_cons_show("Connecting as user@server.org");
|
||||||
|
|
||||||
expect_any(session_connect_with_details, jid);
|
expect_string(session_connect_with_details, jid, "user@server.org");
|
||||||
expect_any(session_connect_with_details, passwd);
|
expect_string(session_connect_with_details, passwd, "password");
|
||||||
expect_any(session_connect_with_details, altdomain);
|
expect_value(session_connect_with_details, altdomain, NULL);
|
||||||
expect_any(session_connect_with_details, port);
|
expect_value(session_connect_with_details, port, 0);
|
||||||
will_return(session_connect_with_details, JABBER_CONNECTING);
|
will_return(session_connect_with_details, JABBER_CONNECTING);
|
||||||
|
|
||||||
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
|
||||||
assert_true(result);
|
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)
|
void cmd_connect_asks_password_when_not_in_account(void **state)
|
||||||
{
|
{
|
||||||
gchar *args[] = { "jabber_org", NULL };
|
gchar *args[] = { "jabber_org", NULL };
|
||||||
|
@ -5,7 +5,8 @@ void cmd_connect_shows_message_when_undefined(void **state);
|
|||||||
void cmd_connect_when_no_account(void **state);
|
void cmd_connect_when_no_account(void **state);
|
||||||
void cmd_connect_with_altdomain_when_provided(void **state);
|
void cmd_connect_with_altdomain_when_provided(void **state);
|
||||||
void cmd_connect_fail_message(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_asks_password_when_not_in_account(void **state);
|
||||||
void cmd_connect_shows_message_when_connecting_with_account(void **state);
|
void cmd_connect_shows_message_when_connecting_with_account(void **state);
|
||||||
void cmd_connect_connects_with_account(void **state);
|
void cmd_connect_connects_with_account(void **state);
|
||||||
|
@ -244,7 +244,10 @@ int main(int argc, char* argv[]) {
|
|||||||
unit_test_setup_teardown(cmd_connect_fail_message,
|
unit_test_setup_teardown(cmd_connect_fail_message,
|
||||||
load_preferences,
|
load_preferences,
|
||||||
close_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,
|
load_preferences,
|
||||||
close_preferences),
|
close_preferences),
|
||||||
unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account,
|
unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account,
|
||||||
|
Loading…
Reference in New Issue
Block a user