32
32
static void test_ssl_init(CuTest *tc)
34
34
serf_bucket_t *bkt, *stream;
35
serf_ssl_context_t *ssl_context;
38
apr_pool_t *test_pool = test_setup();
35
39
serf_bucket_alloc_t *alloc = serf_bucket_allocator_create(test_pool, NULL,
37
serf_ssl_context_t *ssl_context;
40
42
stream = SERF_BUCKET_SIMPLE_STRING("", alloc);
49
51
status = serf_ssl_use_default_certificates(ssl_context);
51
53
CuAssertIntEquals(tc, APR_SUCCESS, status);
54
test_teardown(test_pool);
54
57
/* Test that loading a custom CA certificate file works. */
55
58
static void test_ssl_load_cert_file(CuTest *tc)
57
60
serf_ssl_certificate_t *cert = NULL;
62
apr_pool_t *test_pool = test_setup();
58
63
apr_status_t status = serf_ssl_load_cert_file(&cert, "test/serftestca.pem",
61
66
CuAssertIntEquals(tc, APR_SUCCESS, status);
62
67
CuAssertPtrNotNull(tc, cert);
68
test_teardown(test_pool);
65
71
/* Test that reading a custom CA certificate file works. */
66
72
static void test_ssl_cert_subject(CuTest *tc)
69
74
apr_hash_t *subject;
70
75
serf_ssl_certificate_t *cert = NULL;
71
76
apr_status_t status;
73
apr_pool_create(&subpool, test_pool);
74
status = serf_ssl_load_cert_file(&cert, "test/serftestca.pem", subpool);
78
apr_pool_t *test_pool = test_setup();
80
status = serf_ssl_load_cert_file(&cert, "test/serftestca.pem", test_pool);
76
82
CuAssertIntEquals(tc, APR_SUCCESS, status);
77
83
CuAssertPtrNotNull(tc, cert);
79
subject = serf_ssl_cert_subject(cert, subpool);
85
subject = serf_ssl_cert_subject(cert, test_pool);
80
86
CuAssertStrEquals(tc, "Test Suite",
81
87
apr_hash_get(subject, "OU", APR_HASH_KEY_STRING));
82
88
CuAssertStrEquals(tc, "In Serf we trust, Inc.",
90
96
CuAssertStrEquals(tc, "serf@example.com",
91
97
apr_hash_get(subject, "E", APR_HASH_KEY_STRING));
93
apr_pool_destroy(subpool);
99
test_teardown(test_pool);
96
102
CuSuite *test_ssl(void)