mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
torture: Add cases for username checks
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
d97a5930c9
commit
2be44b4c5a
@@ -2377,6 +2377,9 @@ static void torture_config_parse_uri(void **state)
|
|||||||
assert_null(username);
|
assert_null(username);
|
||||||
assert_string_equal(hostname, "1:2:3::4");
|
assert_string_equal(hostname, "1:2:3::4");
|
||||||
SAFE_FREE(hostname);
|
SAFE_FREE(hostname);
|
||||||
|
|
||||||
|
rc = ssh_config_parse_uri("user -name@", &username, NULL, NULL, true);
|
||||||
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
int torture_run_tests(void)
|
int torture_run_tests(void)
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ static void torture_options_set_host(void **state) {
|
|||||||
assert_non_null(session->opts.username);
|
assert_non_null(session->opts.username);
|
||||||
assert_string_equal(session->opts.username, "at@login");
|
assert_string_equal(session->opts.username, "at@login");
|
||||||
|
|
||||||
|
/* disallow metacharacters in the username */
|
||||||
|
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "shallN()tP4ss -@hostname");
|
||||||
|
assert_ssh_return_code_equal(session, rc, SSH_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_options_set_ciphers(void **state) {
|
static void torture_options_set_ciphers(void **state) {
|
||||||
@@ -393,6 +396,9 @@ static void torture_options_set_user(void **state) {
|
|||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
rc = ssh_options_set(session, SSH_OPTIONS_USER, "&shallN()tP4ss");
|
||||||
|
assert_ssh_return_code_equal(session, rc, SSH_ERROR);
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_USER, "guru");
|
rc = ssh_options_set(session, SSH_OPTIONS_USER, "guru");
|
||||||
assert_true(rc == 0);
|
assert_true(rc == 0);
|
||||||
assert_string_equal(session->opts.username, "guru");
|
assert_string_equal(session->opts.username, "guru");
|
||||||
|
|||||||
Reference in New Issue
Block a user