aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_tortls.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-04 12:08:06 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-04 14:52:35 -0400
commit3cdf0497f9672bc281b0aac2606123249d7b9ddc (patch)
tree3412ccb314ff152f620aef9b2bc037a4e5ac2a5c /src/test/test_tortls.c
parent7acb8c8d1835f919fee09585c966dee837f2e9f6 (diff)
downloadtor-3cdf0497f9672bc281b0aac2606123249d7b9ddc.tar.gz
tor-3cdf0497f9672bc281b0aac2606123249d7b9ddc.zip
Add unit test for bridge-style TLS initialization.
Diffstat (limited to 'src/test/test_tortls.c')
-rw-r--r--src/test/test_tortls.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/test_tortls.c b/src/test/test_tortls.c
index b16a880585..3d0ca5e85f 100644
--- a/src/test/test_tortls.c
+++ b/src/test/test_tortls.c
@@ -265,6 +265,8 @@ test_tortls_double_init(void *arg)
r = tor_tls_context_init(TOR_TLS_CTX_IS_PUBLIC_SERVER,
pk2, pk1, 86400);
tt_int_op(r, OP_EQ, 0);
+ /* For a public server context, these are the same */
+ tt_ptr_op(tor_tls_context_get(0), OP_EQ, tor_tls_context_get(1));
done:
crypto_pk_free(pk1);
@@ -272,6 +274,26 @@ test_tortls_double_init(void *arg)
}
static void
+test_tortls_bridge_init(void *arg)
+{
+ (void)arg;
+ crypto_pk_t *pk1 = NULL, *pk2 = NULL;
+ pk1 = pk_generate(2);
+ pk2 = pk_generate(0);
+
+ /* If we pass in a server identity key but not the
+ TOR_TLS_CTX_IS_PUBLIC_SERVER flag, we should get a bridge-style
+ configuration, with two distinct contexts. */
+ int r = tor_tls_context_init(0 /* flags */, pk1, pk2, 86400);
+
+ tt_int_op(r, OP_EQ, 0);
+ tt_ptr_op(tor_tls_context_get(0), OP_NE, tor_tls_context_get(1));
+ done:
+ crypto_pk_free(pk1);
+ crypto_pk_free(pk2);
+}
+
+static void
test_tortls_address(void *arg)
{
(void)arg;
@@ -344,5 +366,6 @@ struct testcase_t tortls_tests[] = {
LOCAL_TEST_CASE(double_init, TT_FORK),
LOCAL_TEST_CASE(address, TT_FORK),
LOCAL_TEST_CASE(is_server, 0),
+ LOCAL_TEST_CASE(bridge_init, TT_FORK),
END_OF_TESTCASES
};