[S] Change in openvpn[master]: test_tls_crypt: Fix test failure on Windows

"flichtenheld \(Code Review\) via Openvpn-devel" <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <[email protected]>
Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1781?usp=email

to review the following change.


Change subject: test_tls_crypt: Fix test failure on Windows
......................................................................

test_tls_crypt: Fix test failure on Windows

- Exclude tests that use verify_script on Windows.
  We currently do not have openvpn_execve available
  for Windows tests. It would also need more work
  to replace the hardcoded paths.
- Use platform_gen_path instead of hard-coding /
  Do to the previous change that is not strictly
  necessary, but it also doesn't hurt and it fixes
  at least one issue if anyone ever decides to port
  this to Windows).

Change-Id: I45ddc8e350d3948b3197ae725df102d8ce73fa77
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M CMakeLists.txt
M tests/unit_tests/openvpn/test_tls_crypt.c
2 files changed, 8 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/1781/1

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4779d69..b2da69b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -811,7 +811,6 @@
 
     target_sources(test_mbuf PRIVATE
         tests/unit_tests/openvpn/mock_get_random.c
-        src/openvpn/buffer.c
         src/openvpn/mbuf.c
         )
 
diff --git a/tests/unit_tests/openvpn/test_tls_crypt.c b/tests/unit_tests/openvpn/test_tls_crypt.c
index a2987c6..db03437 100644
--- a/tests/unit_tests/openvpn/test_tls_crypt.c
+++ b/tests/unit_tests/openvpn/test_tls_crypt.c
@@ -710,7 +710,7 @@
     assert_true(tls_crypt_v2_extract_client_key(&tmp, &wrap_ctx, &tls_options));
     tls_wrap_free(&wrap_ctx);
 
-
+#ifndef _WIN32
     /* Use /bin/true as verify script */
     script_security_set(2);
     tls_options.tls_crypt_v2_verify_script = "/usr/bin/true";
@@ -727,11 +727,12 @@
      * platform_create_temp_file() */
     char non_random_tmpfile[128];
     snprintf(non_random_tmpfile, sizeof(non_random_tmpfile),
-             "%s/" PACKAGE "_tls_crypt_v2_metadata__%08" PRIx64 "%08" PRIx64 ".tmp",
-             tls_options.tmp_dir, get_random(), get_random());
-    unlink(non_random_tmpfile);
+             PACKAGE "_tls_crypt_v2_metadata__%08" PRIx64 "%08" PRIx64 ".tmp",
+             get_random(), get_random());
+    const char *tmpfile_path = platform_gen_path(tls_options.tmp_dir, non_random_tmpfile, &ctx->gc);
+    unlink(tmpfile_path);
 
-    expect_string(__wrap_buffer_write_file, filename, non_random_tmpfile);
+    expect_string(__wrap_buffer_write_file, filename, tmpfile_path);
 
     /* We do not write the first byte (type) to the file but rather to a
      * metadata_type environment variable */
@@ -752,7 +753,7 @@
         tls_options.tls_crypt_v2_verify_script = "/bin/false";
     }
 
-    expect_string(__wrap_buffer_write_file, filename, non_random_tmpfile);
+    expect_string(__wrap_buffer_write_file, filename, tmpfile_path);
     expect_memory(__wrap_buffer_write_file, pem, buf_bptr(&expected_metadata), buf_len(&expected_metadata));
     will_return(__wrap_buffer_write_file, true);
 
@@ -760,8 +761,8 @@
     assert_false(tls_crypt_v2_extract_client_key(&tmp, &wrap_ctx, &tls_options));
     tls_wrap_free(&wrap_ctx);
 
-
     tls_options.tls_crypt_v2_verify_script = NULL;
+#endif
 
     /* An outdated time should fail */
     tmp = create_client_key_input(ctx, 31);

-- 
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1781?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I45ddc8e350d3948b3197ae725df102d8ce73fa77
Gerrit-Change-Number: 1781
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.