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

rmaucher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 590267e7ef Improve test and add no arg constructor
590267e7ef is described below

commit 590267e7efd309f3bd537d6a03ce6a2d5f3bda91
Author: remm <[email protected]>
AuthorDate: Tue Sep 22 15:58:00 2026 +0200

    Improve test and add no arg constructor
---
 .../apache/tomcat/util/net/SSLHostConfigPreSharedKey.java   |  7 +++++++
 test/org/apache/catalina/storeconfig/TestStoreConfig.java   | 13 ++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java 
b/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java
index 7660490631..c17ce3bf4f 100644
--- a/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java
+++ b/java/org/apache/tomcat/util/net/SSLHostConfigPreSharedKey.java
@@ -37,6 +37,13 @@ public class SSLHostConfigPreSharedKey implements 
Serializable {
     private byte[] key;
     private MessageDigest digest = MessageDigest.SHA256;
 
+    /**
+     * Creates a new pre-shared key configuration with default settings.
+     */
+    public SSLHostConfigPreSharedKey() {
+        this(null);
+    }
+
     /**
      * Creates a new pre-shared key configuration for the given host.
      *
diff --git a/test/org/apache/catalina/storeconfig/TestStoreConfig.java 
b/test/org/apache/catalina/storeconfig/TestStoreConfig.java
index 09fe161b36..b287846b7d 100644
--- a/test/org/apache/catalina/storeconfig/TestStoreConfig.java
+++ b/test/org/apache/catalina/storeconfig/TestStoreConfig.java
@@ -93,7 +93,9 @@ public class TestStoreConfig extends TomcatBaseTest {
         SSLHostConfigPreSharedKey preSharedKey = new 
SSLHostConfigPreSharedKey(tc_SSLHostConfig_22);
         preSharedKey.setIdentity("test");
         preSharedKey.setKey("000102030405060708090a0b0c0d0e0f");
-        preSharedKey.setDigest("SHA256");
+        // A non-default digest: storeconfig omits attributes that equal
+        // their default value, and SHA256 is the default digest.
+        preSharedKey.setDigest("SHA384");
         tc_SSLHostConfig_22.addPreSharedKey(preSharedKey);
         tomcat.getConnector().addSslHostConfig(tc_SSLHostConfig_22);
 
@@ -155,8 +157,13 @@ public class TestStoreConfig extends TomcatBaseTest {
         Assert.assertTrue(serverXmlDump.contains("UserDatabaseRealm"));
         
Assert.assertTrue(serverXmlDump.contains("SecretKeyCredentialHandler"));
         
Assert.assertTrue(serverXmlDump.contains("certificateKeystorePassword="));
-        Assert.assertTrue(serverXmlDump.contains(
-                "<PreSharedKey digest=\"SHA256\" identity=\"test\" 
key=\"000102030405060708090a0b0c0d0e0f\""));
+        // The attributes of a stored element wrap at 60 columns, so check
+        // the element and its attributes individually rather than the
+        // whole tag.
+        Assert.assertTrue(serverXmlDump.contains("<PreSharedKey"));
+        Assert.assertTrue(serverXmlDump.contains("digest=\"SHA384\""));
+        Assert.assertTrue(serverXmlDump.contains("identity=\"test\""));
+        
Assert.assertTrue(serverXmlDump.contains("key=\"000102030405060708090a0b0c0d0e0f\""));
         Assert.assertTrue(serverXmlDump.contains("+TLSv1.1"));
         SAXParserFactory.newInstance().newSAXParser().getXMLReader().parse(new 
InputSource(new StringReader(serverXmlDump)));
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to