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