You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2024/09/27 08:37:04 UTC

(tomcat) branch 9.0.x updated (c9293e2ab4 -> 273caa8c71)

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

remm pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from c9293e2ab4 Always use code blocks
     new e45d8fb100 Added a unit test to make sure that the Expires and Date headers have consisent formatting and contain GMT
     new 273caa8c71 Checkstyle and comment

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../authenticator/TestFormAuthenticatorA.java      | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


(tomcat) 02/02: Checkstyle and comment

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 273caa8c71bc9cf862fb413aef5d8481800df1b1
Author: remm <re...@apache.org>
AuthorDate: Fri Sep 27 10:23:34 2024 +0200

    Checkstyle and comment
---
 test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java b/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java
index 9ab563c000..91b1da1a3c 100644
--- a/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java
+++ b/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java
@@ -40,11 +40,11 @@ import org.apache.catalina.startup.TesterMapRealm;
 import org.apache.catalina.startup.TesterServlet;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
 import org.apache.tomcat.util.descriptor.web.LoginConfig;
 import org.apache.tomcat.util.descriptor.web.SecurityCollection;
 import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
 import org.apache.tomcat.websocket.server.WsContextListener;
-import org.apache.tomcat.util.buf.ByteChunk;
 
 /*
  * Test FORM authentication for sessions that do and do not use cookies.
@@ -222,7 +222,7 @@ public class TestFormAuthenticatorA extends TomcatBaseTest {
 
 
     /*
-     * Test to ensure that the Expir and 
+     * Test to ensure that the expire and date headers use a GMT date.
      */
     @Test
     public void testDateAndExpireHeadersUseGMT() throws Exception {
@@ -235,7 +235,7 @@ public class TestFormAuthenticatorA extends TomcatBaseTest {
         ctxt.getPipeline().addValve(form);
         tomcat.start();
 
-        Map<String,List<String>> responseHeaders = new HashMap();
+        Map<String,List<String>> responseHeaders = new HashMap<>();
         ByteChunk bc = new ByteChunk();
         String path = "http://localhost:" + getPort() + "/examples/jsp/security/protected/index.jsp";
         int rc = getUrl(path, bc, responseHeaders);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


(tomcat) 01/02: Added a unit test to make sure that the Expires and Date headers have consisent formatting and contain GMT

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit e45d8fb1004439bf3c4dfceba1f56e18c1309085
Author: Paul Lodge <pl...@redhat.com>
AuthorDate: Tue Sep 17 16:39:58 2024 +0200

    Added a unit test to make sure that the Expires and Date headers have consisent formatting and contain GMT
---
 .../authenticator/TestFormAuthenticatorA.java      | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java b/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java
index baf3bed5c9..9ab563c000 100644
--- a/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java
+++ b/test/org/apache/catalina/authenticator/TestFormAuthenticatorA.java
@@ -18,8 +18,12 @@ package org.apache.catalina.authenticator;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -40,6 +44,7 @@ import org.apache.tomcat.util.descriptor.web.LoginConfig;
 import org.apache.tomcat.util.descriptor.web.SecurityCollection;
 import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
 import org.apache.tomcat.websocket.server.WsContextListener;
+import org.apache.tomcat.util.buf.ByteChunk;
 
 /*
  * Test FORM authentication for sessions that do and do not use cookies.
@@ -216,6 +221,38 @@ public class TestFormAuthenticatorA extends TomcatBaseTest {
     }
 
 
+    /*
+     * Test to ensure that the Expir and 
+     */
+    @Test
+    public void testDateAndExpireHeadersUseGMT() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+
+        File appDir = new File(getBuildDirectory(), "webapps/examples");
+        Context ctxt  = tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
+        FormAuthenticator form = new FormAuthenticator();
+        form.setSecurePagesWithPragma(true);
+        ctxt.getPipeline().addValve(form);
+        tomcat.start();
+
+        Map<String,List<String>> responseHeaders = new HashMap();
+        ByteChunk bc = new ByteChunk();
+        String path = "http://localhost:" + getPort() + "/examples/jsp/security/protected/index.jsp";
+        int rc = getUrl(path, bc, responseHeaders);
+        Assert.assertTrue(String.format("Expecting 200, but got ", rc), rc == 200);
+        String expiresDate = responseHeaders.get("Expires").get(0).toString();
+
+        String ExpectedDateFormatRegx = "^[A-za-z]{3}, \\d{2} \\w{3} \\d{4} \\d{2}:\\d{2}:\\d{2} GMT$";
+        Pattern pattern = Pattern.compile(ExpectedDateFormatRegx);
+        Matcher matcher = pattern.matcher((CharSequence)expiresDate);
+        Assert.assertTrue("Expires header date not in expected format", matcher.matches());
+
+        String Date = responseHeaders.get("Date").get(0).toString();
+        matcher = pattern.matcher((CharSequence)Date);
+        Assert.assertTrue("Date header not in expected format", matcher.matches());
+    }
+
+
     /*
      * Choreograph the steps of the test dialogue with the server
      *  1. while not authenticated, try to access a protected resource


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org