mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
tests: Reformat torture_auth_pkcs11
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Pavol Žáčik <pzacik@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@@ -58,17 +58,22 @@ static int setup_tokens(void **state, const char *type, const char *obj_name)
|
|||||||
cwd = test_state->temp_dir;
|
cwd = test_state->temp_dir;
|
||||||
assert_non_null(cwd);
|
assert_non_null(cwd);
|
||||||
|
|
||||||
snprintf(priv_filename, sizeof(priv_filename), "%s%s", test_state->keys_dir, type);
|
snprintf(priv_filename,
|
||||||
|
sizeof(priv_filename),
|
||||||
|
"%s%s",
|
||||||
|
test_state->keys_dir,
|
||||||
|
type);
|
||||||
|
|
||||||
torture_setup_tokens(cwd, priv_filename, obj_name, "1");
|
torture_setup_tokens(cwd, priv_filename, obj_name, "1");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int session_setup(void **state)
|
static int session_setup(void **state)
|
||||||
{
|
{
|
||||||
int verbosity = torture_libssh_verbosity();
|
int verbosity = torture_libssh_verbosity();
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
struct passwd *pwd;
|
struct passwd *pwd = NULL;
|
||||||
bool b = false;
|
bool b = false;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -110,7 +115,7 @@ static int setup_pkcs11(void **state)
|
|||||||
struct pki_st *test_state = NULL;
|
struct pki_st *test_state = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
char keys_dir[1024] = {0};
|
char keys_dir[1024] = {0};
|
||||||
char *temp_dir;
|
char *temp_dir = NULL;
|
||||||
|
|
||||||
test_state = malloc(sizeof(struct pki_st));
|
test_state = malloc(sizeof(struct pki_st));
|
||||||
assert_non_null(test_state);
|
assert_non_null(test_state);
|
||||||
@@ -150,8 +155,8 @@ static int sshd_setup(void **state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sshd_teardown(void **state) {
|
static int sshd_teardown(void **state)
|
||||||
|
{
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
struct pki_st *test_state = s->private_data;
|
struct pki_st *test_state = s->private_data;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -176,7 +181,9 @@ static int sshd_teardown(void **state) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_auth_autopubkey(void **state, const char *obj_name, const char *pin) {
|
static void
|
||||||
|
torture_auth_autopubkey(void **state, const char *obj_name, const char *pin)
|
||||||
|
{
|
||||||
struct torture_state *s = *state;
|
struct torture_state *s = *state;
|
||||||
ssh_session session = s->ssh.session;
|
ssh_session session = s->ssh.session;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -186,8 +193,12 @@ static void torture_auth_autopubkey(void **state, const char *obj_name, const ch
|
|||||||
rc = ssh_options_set(session, SSH_OPTIONS_USER, TORTURE_SSH_USER_CHARLIE);
|
rc = ssh_options_set(session, SSH_OPTIONS_USER, TORTURE_SSH_USER_CHARLIE);
|
||||||
assert_int_equal(rc, SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
snprintf(priv_uri, sizeof(priv_uri), "pkcs11:token=%s;object=%s;type=private?pin-value=%s",
|
snprintf(priv_uri,
|
||||||
obj_name, obj_name, pin);
|
sizeof(priv_uri),
|
||||||
|
"pkcs11:token=%s;object=%s;type=private?pin-value=%s",
|
||||||
|
obj_name,
|
||||||
|
obj_name,
|
||||||
|
pin);
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, priv_uri);
|
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, priv_uri);
|
||||||
assert_int_equal(rc, SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
@@ -207,23 +218,28 @@ static void torture_auth_autopubkey(void **state, const char *obj_name, const ch
|
|||||||
assert_int_equal(rc, SSH_AUTH_SUCCESS);
|
assert_int_equal(rc, SSH_AUTH_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_auth_autopubkey_rsa(void **state) {
|
static void torture_auth_autopubkey_rsa(void **state)
|
||||||
|
{
|
||||||
torture_auth_autopubkey(state, "rsa", "1234");
|
torture_auth_autopubkey(state, "rsa", "1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_auth_autopubkey_ecdsa_key_256(void **state) {
|
static void torture_auth_autopubkey_ecdsa_key_256(void **state)
|
||||||
|
{
|
||||||
torture_auth_autopubkey(state, "ecdsa256", "1234");
|
torture_auth_autopubkey(state, "ecdsa256", "1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_auth_autopubkey_ecdsa_key_384(void **state) {
|
static void torture_auth_autopubkey_ecdsa_key_384(void **state)
|
||||||
|
{
|
||||||
torture_auth_autopubkey(state, "ecdsa384", "1234");
|
torture_auth_autopubkey(state, "ecdsa384", "1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_auth_autopubkey_ecdsa_key_521(void **state) {
|
static void torture_auth_autopubkey_ecdsa_key_521(void **state)
|
||||||
|
{
|
||||||
torture_auth_autopubkey(state, "ecdsa521", "1234");
|
torture_auth_autopubkey(state, "ecdsa521", "1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
int torture_run_tests(void) {
|
int torture_run_tests(void)
|
||||||
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct CMUnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
cmocka_unit_test_setup_teardown(torture_auth_autopubkey_rsa,
|
cmocka_unit_test_setup_teardown(torture_auth_autopubkey_rsa,
|
||||||
|
|||||||
Reference in New Issue
Block a user