diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2018-10-25 08:49:01 +0100 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-11-28 15:46:57 +0000 |
| commit | 43b592ac84dbd3d649022ff9503f00ecc83d5278 (patch) | |
| tree | aeb52e3f745cf99eb5d7807073dab1d3d7a07709 /tests/core | |
| parent | 6ba3e6affc73b84f6cd2cadf476c0e0c5e58e404 (diff) | |
| download | libgit2-43b592ac84dbd3d649022ff9503f00ecc83d5278.tar.gz | |
tls: introduce a wrap function
Introduce `git_tls_stream_wrap` which will take an existing `stream`
with an already connected socket and begin speaking TLS on top of it.
This is useful if you've built a connection to a proxy server and you
wish to begin CONNECT over it to tunnel a TLS connection.
Also update the pluggable TLS stream layer so that it can accept a
registration structure that provides an `init` and `wrap` function,
instead of a single initialization function.
Diffstat (limited to 'tests/core')
| -rw-r--r-- | tests/core/stream.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/core/stream.c b/tests/core/stream.c index 262888b10..872571f39 100644 --- a/tests/core/stream.c +++ b/tests/core/stream.c @@ -6,7 +6,7 @@ static git_stream test_stream; static int ctor_called; -static int test_ctor(git_stream **out, const char *host, const char *port) +static int test_stream_init(git_stream **out, const char *host, const char *port) { GIT_UNUSED(host); GIT_UNUSED(port); @@ -17,13 +17,29 @@ static int test_ctor(git_stream **out, const char *host, const char *port) return 0; } +static int test_stream_wrap(git_stream **out, git_stream *in, const char *host) +{ + GIT_UNUSED(in); + GIT_UNUSED(host); + + ctor_called = 1; + *out = &test_stream; + + return 0; +} + void test_core_stream__register_tls(void) { git_stream *stream; + git_stream_registration registration = {0}; int error; + registration.version = 1; + registration.init = test_stream_init; + registration.wrap = test_stream_wrap; + ctor_called = 0; - cl_git_pass(git_stream_register_tls(test_ctor)); + cl_git_pass(git_stream_register_tls(®istration)); cl_git_pass(git_tls_stream_new(&stream, "localhost", "443")); cl_assert_equal_i(1, ctor_called); cl_assert_equal_p(&test_stream, stream); |
