~ubuntu-branches/ubuntu/trusty/serf/trusty-security

« back to all changes in this revision

Viewing changes to test/test_ssl.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Samuelson
  • Date: 2011-06-27 18:09:28 UTC
  • mfrom: (1.2.5 upstream)
  • mto: (3.3.1 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20110627180928-ybwzd3hmx82nu3ir
Tags: 1.0.0~0+svn1514-1
* New upstream snapshot.
  - patches/abi-0.x: Remove as obsolete.
  - patches/kqueue: Forward-port.
  - Bump ABI: libserf0.7{,-dbg} -> libserf1{,-dbg}
  - patches/ip6-localhost: New patch: temporary (I hope) workaround for
    IPv4 / IPv6 confusion in testsuite.
* Implement Multi-Arch: same.
* libserf-dev Conflicts: libserf-0-0-dev, not Breaks.  Thanks, lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
static void test_ssl_init(CuTest *tc)
33
33
{
34
34
    serf_bucket_t *bkt, *stream;
 
35
    serf_ssl_context_t *ssl_context;
 
36
    apr_status_t status;
 
37
 
 
38
    apr_pool_t *test_pool = test_setup();
35
39
    serf_bucket_alloc_t *alloc = serf_bucket_allocator_create(test_pool, NULL,
36
40
                                                              NULL);
37
 
    serf_ssl_context_t *ssl_context;
38
 
    apr_status_t status;
39
41
 
40
42
    stream = SERF_BUCKET_SIMPLE_STRING("", alloc);
41
43
 
49
51
    status = serf_ssl_use_default_certificates(ssl_context);
50
52
 
51
53
    CuAssertIntEquals(tc, APR_SUCCESS, status);
 
54
    test_teardown(test_pool);
52
55
}
53
56
 
54
57
/* Test that loading a custom CA certificate file works. */
55
58
static void test_ssl_load_cert_file(CuTest *tc)
56
59
{
57
60
    serf_ssl_certificate_t *cert = NULL;
 
61
 
 
62
    apr_pool_t *test_pool = test_setup();
58
63
    apr_status_t status = serf_ssl_load_cert_file(&cert, "test/serftestca.pem",
59
64
                                                  test_pool);
60
65
 
61
66
    CuAssertIntEquals(tc, APR_SUCCESS, status);
62
67
    CuAssertPtrNotNull(tc, cert);
 
68
    test_teardown(test_pool);
63
69
}
64
70
 
65
71
/* Test that reading a custom CA certificate file works. */
66
72
static void test_ssl_cert_subject(CuTest *tc)
67
73
{
68
 
    apr_pool_t *subpool;
69
74
    apr_hash_t *subject;
70
75
    serf_ssl_certificate_t *cert = NULL;
71
76
    apr_status_t status;
72
77
 
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();
 
79
 
 
80
    status = serf_ssl_load_cert_file(&cert, "test/serftestca.pem", test_pool);
75
81
 
76
82
    CuAssertIntEquals(tc, APR_SUCCESS, status);
77
83
    CuAssertPtrNotNull(tc, cert);
78
84
 
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));
92
98
 
93
 
    apr_pool_destroy(subpool);
 
99
    test_teardown(test_pool);
94
100
}
95
101
 
96
102
CuSuite *test_ssl(void)