2017-10-28 15:31:37 +03:00
|
|
|
#include "config.h"
|
|
|
|
|
2011-03-17 13:39:11 +03:00
|
|
|
#define LIBSSH_STATIC
|
|
|
|
|
2018-01-08 23:49:49 +03:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2011-03-17 13:39:11 +03:00
|
|
|
#include "torture.h"
|
2018-01-08 23:47:56 +03:00
|
|
|
#include "torture_pki.h"
|
2011-03-17 13:39:11 +03:00
|
|
|
#include "pki.c"
|
|
|
|
|
2011-08-21 15:13:21 +04:00
|
|
|
static void torture_pki_keytype(void **state) {
|
|
|
|
enum ssh_keytypes_e type;
|
|
|
|
const char *type_c;
|
|
|
|
|
|
|
|
(void) state; /* unused */
|
|
|
|
|
|
|
|
type = ssh_key_type(NULL);
|
|
|
|
assert_true(type == SSH_KEYTYPE_UNKNOWN);
|
|
|
|
|
|
|
|
type = ssh_key_type_from_name(NULL);
|
|
|
|
assert_true(type == SSH_KEYTYPE_UNKNOWN);
|
|
|
|
|
|
|
|
type = ssh_key_type_from_name("42");
|
|
|
|
assert_true(type == SSH_KEYTYPE_UNKNOWN);
|
|
|
|
|
|
|
|
type_c = ssh_key_type_to_char(SSH_KEYTYPE_UNKNOWN);
|
|
|
|
assert_true(type_c == NULL);
|
|
|
|
|
|
|
|
type_c = ssh_key_type_to_char(42);
|
|
|
|
assert_true(type_c == NULL);
|
|
|
|
}
|
|
|
|
|
2011-08-21 15:17:30 +04:00
|
|
|
static void torture_pki_signature(void **state)
|
|
|
|
{
|
|
|
|
ssh_signature sig;
|
|
|
|
|
|
|
|
(void) state; /* unused */
|
|
|
|
|
|
|
|
sig = ssh_signature_new();
|
|
|
|
assert_true(sig != NULL);
|
|
|
|
|
|
|
|
ssh_signature_free(sig);
|
|
|
|
}
|
|
|
|
|
2011-03-17 13:39:11 +03:00
|
|
|
int torture_run_tests(void) {
|
|
|
|
int rc;
|
2015-09-07 11:39:51 +03:00
|
|
|
struct CMUnitTest tests[] = {
|
|
|
|
cmocka_unit_test(torture_pki_keytype),
|
|
|
|
cmocka_unit_test(torture_pki_signature),
|
2011-03-17 13:39:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
ssh_init();
|
2014-09-02 11:07:17 +04:00
|
|
|
torture_filter_tests(tests);
|
2015-09-07 11:39:51 +03:00
|
|
|
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
2011-03-17 13:39:11 +03:00
|
|
|
ssh_finalize();
|
|
|
|
return rc;
|
|
|
|
}
|