0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00
Commit Graph

254 Commits

Author SHA1 Message Date
Lev Stipakov
1a7cb2b694
cmake: Don't use "Wno-unused-private-field" for msvc
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-01-30 10:31:14 +02:00
Lev Stipakov
1c9834c50d win: replace msvc project files with cmake
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-01-29 23:24:54 +01:00
Arne Schwabe
4c089df991 Add cmake build file for proto
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-01-29 18:13:28 +01:00
Arne Schwabe
86008fd2ee Remove dependency on std::regex from getSortedString
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-01-29 18:13:28 +01:00
Arne Schwabe
70923f41df
Silence used return value warning of BIO_flush 2020-01-15 23:08:32 +01:00
Arne Schwabe
984c601090
Fix multiple instances of comparison of signed with unsigned 2020-01-15 23:08:30 +01:00
Arne Schwabe
cb229c7bba
Add -Wall option by default to openvpn compile
Fix DCO compile from a fresh checkout

Allow do use -DUSE_WERROR=true to error out on warnings during the build
2020-01-15 23:08:29 +01:00
Arne Schwabe
6dc5d5ddf0
Fix various warnings reported by -Wall/clang
- missing override annotations
- wrong order of init in constructor
- delete on a pointer to a virtual class without virtual destructor
2020-01-15 23:08:28 +01:00
Arne Schwabe
4c361ec4c3 Expand Unittest documentation 2019-12-03 11:04:15 +01:00
James Yonan
4d138252df
unittests: added missing #include <mutex>
Signed-off-by: James Yonan <james@openvpn.net>
2019-11-27 18:55:08 +01:00
Arne Schwabe
a8275e13f4
Add ovpnclinull and ovpnclidco variants to cmake build script 2019-11-20 11:07:49 +01:00
David Sommerseth
ae6bf893bb
mbedtls: Add unit tests for x509_get_subject() and x509_get_common_name()
These functions are found in openvpn/mbedtls/pki/x509certinfo.hpp.

This change also adds support to build coreUnitTests against mbed TLS
instead of OpenSSL (default) by providing -DUSE_MBEDTLS=true to cmake.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-11-08 10:00:44 +01:00
David Sommerseth
61ba6e9c41
openssl: Add unit tests for OpenSSLPKI::x509_get_*() functions
This adds some basic unit tests for the various functions retrieving
information from a X.509 certificate.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-11-08 10:00:41 +01:00
David Sommerseth
71a14a3553
verify-x509-name: Implement base class for processing this option
This new VerifyX509Name class handles both extracting and parsing the
appropriate --verify-x509-name option and is able to verify if a given
subject or hostname is matching the expectation.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-11-08 10:00:34 +01:00
Arne Schwabe
6ae997472c Add macOS implementation in cpu time helper and adjust unit test
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:55 +01:00
Arne Schwabe
12309c31b6 Document unit tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
Arne Schwabe
204d7e4a20 Replace OPENVPN_INSECURE_RANDOM with FakeRandom class
This avoids the mistake of using the insecure MTRand in anything but
a unit test and has the advantage that not all MTRand in a unit test
suite report being secure

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
Arne Schwabe
e790c45eda Add helper functions for temporary file and joining test outputs
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
Arne Schwabe
16342679fe Add helper function to get the content of a expected output file
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
Arne Schwabe
7324ca879e Add OPENVPN_LOG implementation that can collect logs in a variable
To support the pre unittest tests that compare the output against an
expected output without fully rewriting them, this logger provides a
facility to integrate them in the unit test framework

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-11-07 09:58:54 +01:00
James Yonan
e8b31c5454 cli: advertise "openurl" as supported SSO method
Signed-off-by: James Yonan <james@openvpn.net>
2019-09-06 22:24:57 -06:00
Arne Schwabe
63ab5b5e46 Only initialise static member in OpenSSLContext once
This avoid a linkage problem encountered when building core with two
compilation units and OPENVPN_EXTERN being used.

Also adjust core unit tests with regard to now different extern usage
2019-08-29 16:21:57 +02:00
Antonio Quartulli
47046cf6d2
Merge branch 'qa' 2019-07-19 14:39:43 +02:00
James Yonan
4eaa46a879 MbedTLS: added MBEDTLS_DISABLE_NAME_CONSTRAINTS preprocessor flag
This allows building a client against a generic mbedTLS library.

Signed-off-by: James Yonan <james@openvpn.net>
2019-07-17 10:53:46 -06:00
Lev Stipakov
03a906771e win: add OpenSSL as solution configuration
This also removes unittest.vcxproj from solution, since
it is deprecated in favor of CMake-based unit tests.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-06-05 13:54:13 +03:00
David Sommerseth
a55fe2b554
tests: Added unit test for linux/cputime.hpp
This test attempts to assure that the measurements we get from
openvpn::cpu_time() is within a reasonable range of what we should
normally expect.

This is achieved by using a simple worker thread which ensures the
process is not "idling" (like it would with sleep()) but in a real busy
loop which takes some time.  Then we measure the time spent in the busy
loop, both using a simplistic time() and comparing that with what
cpu_time() returns.

This unit test also supports measuring multiple running threads
individually too.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2019-06-03 19:05:34 +02:00
Lev Stipakov
a2496a3616 Wintun: experimental support
This introduces experimental support for Wintun
as an alternative for tap-windows6.

In order to use wintun, set "ClientAPI::Config::wintun"
flag to "true" or use "-w" option in test client.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-29 20:21:28 +03:00
Lev Stipakov
b55f78dd1d test_sitnl.cpp: account for old iptools output
On CentOS 7 "ip route get" produces different
output comparison to Ubuntu 18 etc.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-14 16:32:03 +03:00
Arne Schwabe
d56e049ea4 Refactor dependencies to be in a cmake script
This allows the dependencies to be used by multiple parts of the project,
e.g. non public unit tests, ovpncli etc.

Building ovpncli demostrates this
2019-05-13 14:49:36 +02:00
Lev Stipakov
e9dc75ec90 sitnl: add unit tests
This adds unit tests for sitnl code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-10 10:48:53 +03:00
Lev Stipakov
dfcc4bc437 [OVPN3-354] cli.cpp: support for round-robin DNS and redirect gw
This takes into use new TunSetup API which enables to create bypass
routes before establishing connection.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-10 10:48:53 +03:00
Lev Stipakov
7d112eb3e5 cli: enable utf8 console output
This allows cli to display non-ASCII strings,
assuming they're utf8 encoded.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-06 17:10:12 +03:00
Lev Stipakov
7150f72e09 tun: remove code duplications in Linux tun implementations
There are two ways how Linux tun can be manipulated -
by using iproute2 or netlink. Both implementations have
defined identical Setup class implementation.

This commit factors out Setup class from tun implementations
and templatizes it, which removes need in duplicated code.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-02 21:34:20 +03:00
Lev Stipakov
8112f0cd7c [OVPN3-378] cli: support for TunBuilder API
This enables to use TunBuidler API by test client
on Linux and Mac platforms.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-05-02 21:34:20 +03:00
Lev Stipakov
4d7c12ac4d [OVPN3-405] Support for non-ASCII profile path on Windows
This uses Windows-specific wchar_t override of std::ifstream
to make it work with UNICODE paths. It is assumed that caller
passes UTF8-encoded string.

To support passing non-ASCII chars via command line, we
read it as wstring and then convert to UTF-8 encoded string.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2019-04-30 17:45:01 +03:00
Arne Schwabe
aba98471fc Fix base64 unit test with mbedtls and windows
- the output buffer was sometimes too small in mbed tls
- msvc compiler does not like stack arrays with dynamic sizes
2019-04-18 14:47:16 +02:00
Arne Schwabe
9f84174f0b Add unit tests for Base64 2019-04-15 17:23:37 +02:00
Arne Schwabe
dfdd528dc1 Convert unit test to Googletest
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:23:37 +02:00
Arne Schwabe
bd9ee482e6 Add copyright header to test_comp 2019-04-15 17:23:37 +02:00
Arne Schwabe
059f20f2b2 Move compression unit test from common to core repository
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:05:09 +02:00
James Yonan
5a024cde5c Added Snappy corpus for testing compression/decompression.
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2019-04-15 17:05:09 +02:00
Arne Schwabe
6ef089164e Allow unit tests to be also compiled with mbed TLS and on Windows 2019-03-12 11:36:29 +01:00
Arne Schwabe
7c67bf7f50 Add unit tests for route emulation and establish common test suite
This puts the log demo unit test and real route emulation into the same
unit test compilation unit to save compilation time.
2019-03-12 11:36:29 +01:00
Arne Schwabe
64a7b2f124 Add build file for core unit tests
Currently we only have unit test build file for Visual Studio. Add one
that is compatible with Unix like systems.
2019-03-12 11:36:29 +01:00
Lev Stipakov
1bf3fc0e4a win: update project files
Remove Win32 target, set platform version to Windows 10 and set platform toolset to v141.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2018-12-21 10:30:31 +02:00
Arne Schwabe
84dbc5b9b2 Allow test/cli.cpp to be used with NetCfg Tunbuilder client
This requires cli.cpp to be included in openvpn3-linux build environment
and the right defines set before the test.cpp is included.

This workaround is necessary since the dbus dependencies are not part
of the core and to adding an extra copy of cli.cpp to openvpn3-linux

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2018-12-06 11:49:30 +01:00
Antonio Quartulli
9814079944
tls-crypt-v2: implement abstract metadata parser
The metadata that may be possibly be contained in the WKc has to be
verified by means of a user implemented behaviour.

Implement an abstract class that exports a verify() method to be
used for this purpose.

Users can extend this class and override the verify() method with
their own.

A basic implementation is also provided: it will just ignore the
metadata (if any) and report success to the core.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
Antonio Quartulli
be38bbeb84
tls-crypt-v2: test/ssl/proto.cpp - extend protocol test
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-12-06 09:19:22 +10:00
Arne Schwabe
2ea88a93ba Add Remote endpoint information to protect_socket call
On the linux client we need the information to which remote the client
is connecting to query the route information to ultimately discover the
device. On other platform that do not need these extra information we
ignore the extra arguments

The API uses std::string and bool instead of passing of passing IPAddr as
the API needs to be understand by Swig/Java and similar methods also opt in
favour of call by value and simply types.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2018-12-04 13:33:18 +01:00
Antonio Quartulli
0a081ee17f
[OVPN3-315] cli/go: add option to compile SITNL component
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2018-11-30 08:51:14 +10:00