mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-31 00:03:07 +03:00
tests: Test vectors for related documentation
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@ -1127,6 +1127,9 @@ static void torture_ssh_check_hostname_syntax(void **state)
|
|||||||
assert_int_equal(rc, SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
rc = ssh_check_hostname_syntax("libssh.");
|
rc = ssh_check_hostname_syntax("libssh.");
|
||||||
assert_int_equal(rc, SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
// IDN
|
||||||
|
rc = ssh_check_hostname_syntax("xn--bcher-kva.tld");
|
||||||
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_check_hostname_syntax(NULL);
|
rc = ssh_check_hostname_syntax(NULL);
|
||||||
assert_int_equal(rc, SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
@ -1170,6 +1173,9 @@ static void torture_ssh_check_hostname_syntax(void **state)
|
|||||||
assert_int_equal(rc, SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
rc = ssh_check_hostname_syntax("..");
|
rc = ssh_check_hostname_syntax("..");
|
||||||
assert_int_equal(rc, SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
|
// IDN non-encoded
|
||||||
|
rc = ssh_check_hostname_syntax("bücher.tld");
|
||||||
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_ssh_check_username_syntax(void **state) {
|
static void torture_ssh_check_username_syntax(void **state) {
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include "torture.h"
|
#include "torture.h"
|
||||||
#include "torture_key.h"
|
#include "torture_key.h"
|
||||||
#include <libssh/session.h>
|
#include <libssh/session.h>
|
||||||
@ -91,6 +92,40 @@ static void torture_options_set_host(void **state) {
|
|||||||
assert_string_equal(ssh_get_error(session),
|
assert_string_equal(ssh_get_error(session),
|
||||||
"Invalid argument in ssh_options_set");
|
"Invalid argument in ssh_options_set");
|
||||||
assert_ssh_return_code_equal(session, rc, SSH_ERROR);
|
assert_ssh_return_code_equal(session, rc, SSH_ERROR);
|
||||||
|
|
||||||
|
/* IPv6 hostnames should work without square braces */
|
||||||
|
SAFE_FREE(session->opts.username);
|
||||||
|
rc = ssh_options_set(session,
|
||||||
|
SSH_OPTIONS_HOST,
|
||||||
|
"fd4d:5449:7400:111:626d:3cff:fedf:4d39");
|
||||||
|
assert_return_code(rc, errno);
|
||||||
|
assert_non_null(session->opts.host);
|
||||||
|
assert_string_equal(session->opts.host,
|
||||||
|
"fd4d:5449:7400:111:626d:3cff:fedf:4d39");
|
||||||
|
assert_null(session->opts.username);
|
||||||
|
|
||||||
|
/* IPv6 hostnames should work also with square braces */
|
||||||
|
rc = ssh_options_set(session,
|
||||||
|
SSH_OPTIONS_HOST,
|
||||||
|
"[fd4d:5449:7400:111:626d:3cff:fedf:4d39]");
|
||||||
|
assert_return_code(rc, errno);
|
||||||
|
assert_non_null(session->opts.host);
|
||||||
|
assert_string_equal(session->opts.host,
|
||||||
|
"fd4d:5449:7400:111:626d:3cff:fedf:4d39");
|
||||||
|
assert_null(session->opts.username);
|
||||||
|
|
||||||
|
/* IDN need to be in punycode format */
|
||||||
|
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "xn--bcher-kva.tld");
|
||||||
|
assert_return_code(rc, errno);
|
||||||
|
assert_non_null(session->opts.host);
|
||||||
|
assert_string_equal(session->opts.host, "xn--bcher-kva.tld");
|
||||||
|
assert_null(session->opts.username);
|
||||||
|
|
||||||
|
/* IDN in UTF8 wont work */
|
||||||
|
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "bücher.tld");
|
||||||
|
assert_string_equal(ssh_get_error(session),
|
||||||
|
"Invalid argument in ssh_options_set");
|
||||||
|
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)
|
||||||
|
Reference in New Issue
Block a user