]> git.proxmox.com Git - libgit2.git/blob - tests/stream/deprecated.c
2c2bbfdc354bc00f21541301112234818748233c
[libgit2.git] / tests / stream / deprecated.c
1 #undef GIT_DEPRECATE_HARD
2
3 #include "clar_libgit2.h"
4 #include "git2/sys/stream.h"
5 #include "streams/tls.h"
6 #include "streams/socket.h"
7 #include "stream.h"
8
9 static git_stream test_stream;
10 static int ctor_called;
11
12 void test_stream_deprecated__cleanup(void)
13 {
14 cl_git_pass(git_stream_register(GIT_STREAM_TLS | GIT_STREAM_STANDARD, NULL));
15 }
16
17 static int test_stream_init(git_stream **out, const char *host, const char *port)
18 {
19 GIT_UNUSED(host);
20 GIT_UNUSED(port);
21
22 ctor_called = 1;
23 *out = &test_stream;
24
25 return 0;
26 }
27
28 void test_stream_deprecated__register_tls(void)
29 {
30 git_stream *stream;
31 int error;
32
33 ctor_called = 0;
34 cl_git_pass(git_stream_register_tls(test_stream_init));
35 cl_git_pass(git_tls_stream_new(&stream, "localhost", "443"));
36 cl_assert_equal_i(1, ctor_called);
37 cl_assert_equal_p(&test_stream, stream);
38
39 ctor_called = 0;
40 stream = NULL;
41 cl_git_pass(git_stream_register_tls(NULL));
42 error = git_tls_stream_new(&stream, "localhost", "443");
43
44 /*
45 * We don't have TLS support enabled, or we're on Windows,
46 * which has no arbitrary TLS stream support.
47 */
48 #if defined(GIT_WIN32) || !defined(GIT_HTTPS)
49 cl_git_fail_with(-1, error);
50 #else
51 cl_git_pass(error);
52 #endif
53
54 cl_assert_equal_i(0, ctor_called);
55 cl_assert(&test_stream != stream);
56
57 git_stream_free(stream);
58 }