Implement unit tests for auth-gen-token
PATCH v6 7/7 Implement unit tests for auth-gen-token
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
Patch V2: adapt unit tests to other V2 patches Patch V4: Resolve rebase conflicts
Patch V5: Add \ lost in rebase that broke compilation
--- tests/unit_tests/openvpn/Makefile.am | 18 +- tests/unit_tests/openvpn/test_auth_token.c | 375 +++++++++++++++++++++ 2 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 tests/unit_tests/openvpn/test_auth_token.c
tests/unit_tests/openvpn/Makefile.am +17 -1
@@ -6,7 +6,7 @@ if HAVE_LD_WRAP_SUPPORT test_binaries += argv_testdriver buffer_testdriver endif -test_binaries += crypto_testdriver packet_id_testdriver +test_binaries += crypto_testdriver packet_id_testdriver auth_token_testdriver if HAVE_LD_WRAP_SUPPORT test_binaries += tls_crypt_testdriver endif
@@ -94,3 +94,19 @@ networking_testdriver_SOURCES = test_networking.c mock_msg.c \ $(openvpn_srcdir)/packet_id.c \ $(openvpn_srcdir)/platform.c endif + +auth_token_testdriver_CFLAGS = @TEST_CFLAGS@ \ + -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) \ + $(OPTIONAL_CRYPTO_CFLAGS) +auth_token_testdriver_LDFLAGS = @TEST_LDFLAGS@ \ + $(OPTIONAL_CRYPTO_LIBS) + +auth_token_testdriver_SOURCES = test_auth_token.c mock_msg.c \ + $(openvpn_srcdir)/buffer.c \ + $(openvpn_srcdir)/crypto.c \ + $(openvpn_srcdir)/crypto_mbedtls.c \ + $(openvpn_srcdir)/crypto_openssl.c \ + $(openvpn_srcdir)/otime.c \ + $(openvpn_srcdir)/packet_id.c \ + $(openvpn_srcdir)/platform.c \ + $(openvpn_srcdir)/base64.c
tests/unit_tests/openvpn/test_auth_token.c new file +375 -0
375 lines not on this page · raw message
Signature · 1 line
2.22.0
Quoted 10 lines · Arne Schwabe
From: Arne Schwabe <[email protected]...>
Patch V2: adapt unit tests to other V2 patches Patch V4: Resolve rebase conflicts
Patch V5: Add \ lost in rebase that broke compilation--- tests/unit_tests/openvpn/Makefile.am | 18 +- tests/unit_tests/openvpn/test_auth_token.c | 375 +++++++++++++++++++++ 2 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 tests/unit_tests/openvpn/test_auth_token.c
Code generally looks good. But I do have some nitpicks here though.
* Many of the lines break our 80 chars per line rule
* The "dummy" functions added at the end of the test_auth_token.c file should be declared higher up and not after the main() function.
And finally ... the unit test doesn't pass for me :/
------------------------------------------------------
[==========] Running 8 test(s).
[ RUN ] auth_token_basic_test
[ OK ] auth_token_basic_test
[ RUN ] auth_token_fail_invalid_key
--auth-token-gen: HMAC on token from client failed (test user name)
[ OK ] auth_token_fail_invalid_key
[ RUN ] auth_token_test_known_keys
[ OK ] auth_token_test_known_keys
[ RUN ] auth_token_test_empty_user [ ERROR ] --- 0x3 != 0x7 [ LINE ] --- test_auth_token.c:265: error: Failure! [ FAILED ] auth_token_test_empty_user [ RUN ] auth_token_test_env
[ OK ] auth_token_test_env
[ RUN ] auth_token_test_random_keys
[ OK ] auth_token_test_random_keys
[ RUN ] auth_token_test_key_load
--auth-token-gen: HMAC on token from client failed (test user name)
[ OK ] auth_token_test_key_load
[ RUN ] auth_token_test_timeout
[ OK ] auth_token_test_timeout
[==========] 8 test(s) run.
[ PASSED ] 7 test(s). [ FAILED ] 1 test(s), listed below: [ FAILED ] auth_token_test_empty_user
1 FAILED TEST(S)
------------------------------------------------------
Seems like the verify_auth_token() call doesn't add AUTH_TOKEN_VALID_EMPTYUSER flag. I didn't dive deep enough to try to understand why.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
PATCH v7 7/7 Implement unit tests for auth-gen-token
From: Arne Schwabe <[email protected]...>
The unit test is breaking the 80 char limit in some places but the remaining lines it breaks the limit I feel forcing the 80 char limit will impair readibility
Patch V2: adapt unit tests to other V2 patches Patch V4: Resolve rebase conflicts
Patch V5: Add \ lost in rebase that broke compilation Patch V7: Fix unit test failure, try to stay below 80
--- tests/unit_tests/openvpn/Makefile.am | 18 +- tests/unit_tests/openvpn/test_auth_token.c | 394 +++++++++++++++++++++ 2 files changed, 411 insertions(+), 1 deletion(-) create mode 100644 tests/unit_tests/openvpn/test_auth_token.c
tests/unit_tests/openvpn/Makefile.am +17 -1
@@ -6,7 +6,7 @@ if HAVE_LD_WRAP_SUPPORT test_binaries += argv_testdriver buffer_testdriver endif -test_binaries += crypto_testdriver packet_id_testdriver +test_binaries += crypto_testdriver packet_id_testdriver auth_token_testdriver if HAVE_LD_WRAP_SUPPORT test_binaries += tls_crypt_testdriver endif
@@ -94,3 +94,19 @@ networking_testdriver_SOURCES = test_networking.c mock_msg.c \ $(openvpn_srcdir)/packet_id.c \ $(openvpn_srcdir)/platform.c endif + +auth_token_testdriver_CFLAGS = @TEST_CFLAGS@ \ + -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) \ + $(OPTIONAL_CRYPTO_CFLAGS) +auth_token_testdriver_LDFLAGS = @TEST_LDFLAGS@ \ + $(OPTIONAL_CRYPTO_LIBS) + +auth_token_testdriver_SOURCES = test_auth_token.c mock_msg.c \ + $(openvpn_srcdir)/buffer.c \ + $(openvpn_srcdir)/crypto.c \ + $(openvpn_srcdir)/crypto_mbedtls.c \ + $(openvpn_srcdir)/crypto_openssl.c \ + $(openvpn_srcdir)/otime.c \ + $(openvpn_srcdir)/packet_id.c \ + $(openvpn_srcdir)/platform.c \ + $(openvpn_srcdir)/base64.c
tests/unit_tests/openvpn/test_auth_token.c new file +394 -0
394 lines not on this page · raw message
Signature · 1 line
2.22.0
Quoted 10 lines · Arne Schwabe
From: Arne Schwabe <[email protected]...>
The unit test is breaking the 80 char limit in some places but the remaining lines it breaks the limit I feel forcing the 80 char limit will impair readibility
Patch V2: adapt unit tests to other V2 patches Patch V4: Resolve rebase conflicts
Patch V5: Add \ lost in rebase that broke compilation Patch V7: Fix unit test failure, try to stay below 80
Quoted 5 lines
--- tests/unit_tests/openvpn/Makefile.am | 18 +- tests/unit_tests/openvpn/test_auth_token.c | 394 +++++++++++++++++++++ 2 files changed, 411 insertions(+), 1 deletion(-) create mode 100644 tests/unit_tests/openvpn/test_auth_token.c
This looks good now, and passes on my system.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc
Your patch has been applied to the master branch.
Did client side tests, see the unit tests pass on linux and freebsd...
..
[ RUN ] auth_token_test_timeout
[ OK ] auth_token_test_timeout
[==========] 8 test(s) run.
[ PASSED ] 8 test(s).
PASS: auth_token_testdriver
The "Fox Crypto B.V." copyright notice in a *new* C source looks a bit funky, though.
commit ef2c7b2fa4fd9fae934e608e37dc8d98edbace5f
Author: Arne Schwabe Date: Tue Sep 17 14:33:21 2019 +0200
Implement unit tests for auth-gen-token
Acked-by: David Sommerseth <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18821.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Am 01.10.19 um 13:27 schrieb Gert Doering:
Quoted 11 lines
Your patch has been applied to the master branch.
Did client side tests, see the unit tests pass on linux and freebsd...
..
[ RUN ]auth_token_test_timeout
[ OK ]auth_token_test_timeout
[==========] 8 test(s) run.
[ PASSED ] 8 test(s).
PASS:auth_token_testdriver
Quoted 3 lines
The "Fox Crypto B.V." copyright notice in a *new* C source looks a bit funky, though.
Part of the tests are rewritten test from the tls_crypt test suite (but too different to make sense to have a common file), so I copied the copyright too.
Arne