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

33 Commits

Author SHA1 Message Date
Frank Lichtenheld
273297d630 test/unittests: Add newly imported unittests
Note that the test suite now depends on jsoncpp
and xxHash.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-07-06 11:21:28 +02:00
Heiko Hund
b660e5642b
add support for --dns option
As a first step towards DNS configuration in openvpn and a unified way
to push DNS related settings to clients in v2 and v3, this commit adds
support for parsing the new --dns option. Later commits will add support
for setting up DNS on different platforms.

For now, --dns and DNS related --dhcp-option can be used together for
smoother transition. Settings from --dns will override ones --dhcp-option
where applicable.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2022-02-10 18:35:02 +01:00
James Yonan
5be7dee87f Added fast IP address formatting via BufferFormat::ipv4/ipv6
Signed-off-by: James Yonan <james@openvpn.net>
2022-01-13 09:40:13 -06:00
Frank Lichtenheld
88b0d28295 unittests: fix test_sitnl
- Test for CAP_NET_ADMIN instead of root.
  This correctly skips the test if you're root but have
  dropped capabilities, e.g. inside docker.
- Fix TestSetMTU to correctly ignore any additional lines
  in the output.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-01-11 15:00:44 +01:00
Arne Schwabe
de0d52b7ce [OSSL 3.0] Use new EVP_MAC API for HMAC implementation
The old API is deprecated in OpenSSL 3.0 and the new API does not yet
exist in OpenSSL 1.1. Emulating the new API or using one class with
ifdefs would be more complex than just having two implementations. So
this adds a new implementation for OpenSSL 3.0.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-11-12 14:27:12 +01:00
Mark Deric
989d2f590a
WIP Fix the rhel7 unit test target failure
This might not be the final fix.  Note the extensive code comment
inside the cmake file if().  The comment suggest a potentially better
fix, but it's unlikely.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2021-09-22 14:04:48 +02:00
James Yonan
303a39ad6c SafeString: use timing-attack-resistant crypto::str_neq for comparisons
Also added unit test.

Signed-off-by: James Yonan <james@openvpn.net>
2021-08-17 13:07:40 -06:00
James Yonan
abd1c5b208
PacketStream: minor cleanup and added a unit test
Removed declared_size_defined in favor of just setting
declared_size to a special value (SIZE_UNDEF) when it's
undefined.

Signed-off-by: James Yonan <james@openvpn.net>
2021-08-03 10:42:35 +02:00
Heiko Hund
e9a903fd9f add support for the --peer-fingerprint option
This option lets you specify the SHA256 fingerprint of a peer's self-signed
certificate. The peer's certificate, presented during connection bring-up,
is compared to the fingerprint. The connection fails if it doesn't
match.

So, this serves as an easy, yet secure, alternative to setting up a PKI,
but can also be used in conjunction with one to add one more check during
leaf certificate validation.

The option can also be given as inline block, for easier management for
multiple fingerprints:

  <peer-fingerprint>
  00:11:22:33:...:BB:CC:DD:FF
  BB:CC:DD:FF:...:00:11:22:33
  </peer-fingerprint>

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-04-28 23:56:22 +02:00
David Sommerseth
38f2a08d2b
cmake: Clean up duplications
The CMakeLists.txt settings from the project root directory are
inherited by the defined subdirectories automatically.

Also switch to a simpler way of setting the CMAKE_MODULE_PATH.
According to the CMake documentation, this variable is empty by
default [1] and should not need to pull in existing settings.

Finally remove the comment regarding CMake's use case, as we are
moving towards full CMake support for OpenVPN 3.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-04-22 12:54:26 +02:00
Heiko Hund
f2508d9363
add unit test for HTTP proxy options
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-04-14 22:40:07 +02:00
Heiko Hund
08a02669c5 add support for remote-random-hostname option
Add the option from openvpn2. If given, prepend hostnames
from remote options with six random hex bytes before
DNS resolution is taking place, e.g.

	host.domain -> e3b17bf7cd57.host.domain

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-03-02 11:07:09 +01:00
Heiko Hund
cb7b37b1d7 Add unit test for class PushedOptionsFilter
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-02-09 15:43:16 +01:00
David Sommerseth
5b15dbe940
Merge changes from Core library v3.5 2020-09-23 20:13:07 +02:00
Lev Stipakov
242cdad9c9
win: add ipv4 routes via IP Helper API
Use ::CreateIpForwardEntry2() to add route instead of
expensive netsh call. Make it as a default choce.

Add unit test.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 18:25:38 +03:00
Lev Stipakov
d0e2e036eb
win: add ipv4 routes via IP Helper API
Use ::CreateIpForwardEntry2() to add route instead of
expensive netsh call. Make it as a default choce.

Add unit test.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 13:07:06 +03:00
Lev Stipakov
d79536240e
unittests/CMakeLists.txt: fix tests execution
Commit 941104cf4 refactored the way how test files are added, but
broke (disabled) execution of sitnl and cputime tests. Fix that.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-09 12:35:25 +03:00
James Yonan
3555b12a16
push-continuation: added new server-side fragmentor
Includes new unit test for both client and
server-side push-continuation code.

Signed-off-by: James Yonan <james@openvpn.net>
2020-08-19 18:53:00 +02:00
Arne Schwabe
941104cf49
Implement supporting IANA cipher names in tls-cipher and unit tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-03-11 19:51:37 +01:00
Arne Schwabe
8f4da2ec62 Move CMAKE module path to root directory
This fixes the cmake build when using openvpn3 standonline

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-01-30 14:52:57 +01: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
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
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
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
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
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