aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-16 18:53:18 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-16 18:53:18 +0200
commit25a21088090dcb18ef6f0b12a47bd1db6b871153 (patch)
tree53ce5494c0dc3157fb445aa6f0ab4b89142553b8 /tests
parent9b84464748d5d4cd67b7868a6cfba5664a169503 (diff)
downloadlibssh-25a21088090dcb18ef6f0b12a47bd1db6b871153.tar.gz
libssh-25a21088090dcb18ef6f0b12a47bd1db6b871153.tar.xz
libssh-25a21088090dcb18ef6f0b12a47bd1db6b871153.zip
pki: Remove session from ssh_pki_import_privkey_* functions.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/torture_pki.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/tests/unittests/torture_pki.c b/tests/unittests/torture_pki.c
index fca7c72c..007b509c 100644
--- a/tests/unittests/torture_pki.c
+++ b/tests/unittests/torture_pki.c
@@ -103,7 +103,7 @@ static void torture_pki_import_privkey_base64_RSA(void **state) {
key_str = read_file(LIBSSH_RSA_TESTKEY);
assert_true(key_str != NULL);
- rc = ssh_pki_import_privkey_base64(session, key_str, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
assert_true(rc == 0);
free(key_str);
@@ -124,26 +124,7 @@ static void torture_pki_import_privkey_base64_NULL_key(void **state) {
assert_true(key != NULL);
/* test if it returns -1 if key is NULL */
- rc = ssh_pki_import_privkey_base64(session, key_str, passphrase, NULL);
- assert_true(rc == -1);
-
- free(key_str);
- ssh_key_free(key);
-}
-
-static void torture_pki_import_privkey_base64_NULL_session(void **state) {
- ssh_session session = *state;
- int rc;
- char *key_str;
- ssh_key key = NULL;
- const char *passphrase = LIBSSH_PASSPHRASE;
-
- key_str = read_file(LIBSSH_RSA_TESTKEY);
- assert_true(key_str != NULL);
-
- /* test if it returns -1 if session is NULL */
- (void)session;
- rc = ssh_pki_import_privkey_base64(NULL, key_str, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, NULL);
assert_true(rc == -1);
free(key_str);
@@ -161,7 +142,7 @@ static void torture_pki_import_privkey_base64_NULL_str(void **state) {
assert_true(key_str != NULL);
/* test if it returns -1 if key_str is NULL */
- rc = ssh_pki_import_privkey_base64(session, NULL, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(NULL, passphrase, NULL, NULL, &key);
assert_true(rc == -1);
free(key_str);
@@ -178,7 +159,7 @@ static void torture_pki_import_privkey_base64_DSA(void **state) {
key_str = read_file(LIBSSH_DSA_TESTKEY);
assert_true(key_str != NULL);
- rc = ssh_pki_import_privkey_base64(session, key_str, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
assert_true(rc == 0);
free(key_str);
@@ -195,18 +176,19 @@ static void torture_pki_import_privkey_base64_passphrase(void **state) {
key_str = read_file(LIBSSH_RSA_TESTKEY);
assert_true(key_str != NULL);
- rc = ssh_pki_import_privkey_base64(session, key_str, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
assert_true(rc == 0);
ssh_key_free(key);
/* test if it returns -1 if passphrase is wrong */
- rc = ssh_pki_import_privkey_base64(session, key_str, "wrong passphrase !!", &key);
+ rc = ssh_pki_import_privkey_base64(key_str, "wrong passphrase !!", NULL,
+ NULL, &key);
assert_true(rc == -1);
#ifndef HAVE_LIBCRYPTO
/* test if it returns -1 if passphrase is NULL */
/* libcrypto asks for a passphrase, so skip this test */
- rc = ssh_pki_import_privkey_base64(session, key_str, NULL, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, NULL, NULL, NULL, &key);
assert_true(rc == -1);
#endif
@@ -216,18 +198,18 @@ static void torture_pki_import_privkey_base64_passphrase(void **state) {
key_str = read_file(LIBSSH_DSA_TESTKEY);
assert_true(key_str != NULL);
- rc = ssh_pki_import_privkey_base64(session, key_str, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
assert_true(rc == 0);
ssh_key_free(key);
/* test if it returns -1 if passphrase is wrong */
- rc = ssh_pki_import_privkey_base64(session, key_str, "wrong passphrase !!", &key);
+ rc = ssh_pki_import_privkey_base64(key_str, "wrong passphrase !!", NULL, NULL, &key);
assert_true(rc == -1);
#ifndef HAVE_LIBCRYPTO
/* test if it returns -1 if passphrase is NULL */
/* libcrypto asks for a passphrase, so skip this test */
- rc = ssh_pki_import_privkey_base64(session, key_str, NULL, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, NULL, NULL, NULL, &key);
assert_true(rc == -1);
#endif
@@ -245,7 +227,7 @@ static void torture_pki_pki_publickey_from_privatekey_RSA(void **state) {
key_str = read_file(LIBSSH_RSA_TESTKEY);
assert_true(key_str != NULL);
- rc = ssh_pki_import_privkey_base64(session, key_str, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
assert_true(rc == 0);
pubkey = ssh_pki_publickey_from_privatekey(key);
@@ -267,7 +249,7 @@ static void torture_pki_pki_publickey_from_privatekey_DSA(void **state) {
key_str = read_file(LIBSSH_DSA_TESTKEY);
assert_true(key_str != NULL);
- rc = ssh_pki_import_privkey_base64(session, key_str, passphrase, &key);
+ rc = ssh_pki_import_privkey_base64(key_str, passphrase, NULL, NULL, &key);
assert_true(rc == 0);
pubkey = ssh_pki_publickey_from_privatekey(key);
@@ -360,9 +342,6 @@ int torture_run_tests(void) {
unit_test_setup_teardown(torture_pki_import_privkey_base64_NULL_key,
setup_rsa_key,
teardown),
- unit_test_setup_teardown(torture_pki_import_privkey_base64_NULL_session,
- setup_rsa_key,
- teardown),
unit_test_setup_teardown(torture_pki_import_privkey_base64_NULL_str,
setup_rsa_key,
teardown),