This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git


The following commit(s) were added to refs/heads/master by this push:
     new c2865b7c Allow OpenSSL check to be skipped for Windows
c2865b7c is described below

commit c2865b7c7fc77675113fb48bff2f319cc3338306
Author: Sebb <s...@apache.org>
AuthorDate: Thu Nov 2 12:37:43 2023 +0000

    Allow OpenSSL check to be skipped for Windows
---
 .github/workflows/maven.yml                                     | 7 +++++--
 src/test/java/org/apache/commons/crypto/CryptoTest.java         | 4 +++-
 src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java | 4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 7bdb4902..3a1972ad 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -95,11 +95,14 @@ jobs:
       # e.g. ENGINESDIR: "C:\Program Files\OpenSSL\lib\engines-1_1"
       # The code below extracts "C:\Program Files\OpenSSL\lib", as expected
       # but this does not seem to be the correct setting to override system 
library
+      # To avoid failing tests unnecessarily, skip the check for OpenSSL in 
the library name
       # To be resolved...
+      shell: bash
       run: |
         openssl version -e
         chcp 65001 #set code page to utf-8
-        echo ((openssl version -e) -replace ': "','=' -replace 
'\\engines-.*','') >> $env:GITHUB_ENV
+        echo $(openssl version -e | sed -n -e 's/engines-.*//' -e 's/: "/=/p') 
>> "$GITHUB_ENV"
+        echo "CHECK_SKIP=skip" >> $GITHUB_ENV
     - name: Build with Maven
       shell: bash
       # OPENSSL_HOME is needed for Windows build to find some header files
@@ -111,7 +114,7 @@ jobs:
       env:
         OPENSSL_HOME: "C:\\Miniconda\\Library"
       run: |
-        mvn --show-version --batch-mode --no-transfer-progress 
-DtrimStackTrace=false -D"jni.library.path=$ENGINESDIR" 
-D"jna.library.path=$ENGINESDIR"
+        mvn --show-version --batch-mode --no-transfer-progress 
-DtrimStackTrace=false -D"jni.library.path=$ENGINESDIR" 
-D"jna.library.path=$ENGINESDIR" -D"commons.crypto.openssl.check=$CHECK_SKIP"
     - name: Run Crypto (JNI - override default lib)
       shell: bash
       run: |
diff --git a/src/test/java/org/apache/commons/crypto/CryptoTest.java 
b/src/test/java/org/apache/commons/crypto/CryptoTest.java
index 1c5cff2f..a775b937 100644
--- a/src/test/java/org/apache/commons/crypto/CryptoTest.java
+++ b/src/test/java/org/apache/commons/crypto/CryptoTest.java
@@ -63,7 +63,9 @@ public class CryptoTest {
         assertTrue(Crypto.isNativeCodeLoaded(), "Completed OK");
         // Ensure that test loaded OpenSSL, not some other library
         // This may require jni.library.path to be defined if the default 
library is not OpenSSL
-        assertThat(OpenSslInfoNative.OpenSSLVersion(0), 
containsString("OpenSSL"));
+        if 
(!"skip".equals(System.getProperty("commons.crypto.openssl.check"))) { // allow 
check to be skipped
+            assertThat(OpenSslInfoNative.OpenSSLVersion(0), 
containsString("OpenSSL"));
+        }
     }
 
 }
diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java 
b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java
index 94b26463..1859a4c2 100644
--- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java
+++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaTest.java
@@ -29,6 +29,8 @@ public class OpenSslJnaTest {
         OpenSslJna.main(new String[0]);
         // Ensure that test loaded OpenSSL, not some other library
         // This may require jna.library.path to be defined if the default 
library is not OpenSSL
-        assertThat(OpenSslNativeJna.OpenSSLVersion(0), 
containsString("OpenSSL"));
+        if 
(!"skip".equals(System.getProperty("commons.crypto.openssl.check"))) { // allow 
check to be skipped
+            assertThat(OpenSslNativeJna.OpenSSLVersion(0), 
containsString("OpenSSL"));
+        }
     }
 }

Reply via email to