This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 7d71bfad38c5623a74b7c90ffdc91e20888c60b8 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri May 21 17:03:00 2021 +0100 Align with 10.0.x/9.0.x --- .../tomcat/util/http/parser/Authorization.java | 6 ++++ .../util/http/parser/TestAuthorizationDigest.java | 36 +++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/java/org/apache/tomcat/util/http/parser/Authorization.java b/java/org/apache/tomcat/util/http/parser/Authorization.java index 443fcc5..8afba9b 100644 --- a/java/org/apache/tomcat/util/http/parser/Authorization.java +++ b/java/org/apache/tomcat/util/http/parser/Authorization.java @@ -51,6 +51,12 @@ public class Authorization { } + + private Authorization() { + // Utility class. Hide default constructor. + } + + /** * Parses an HTTP Authorization header for DIGEST authentication as per RFC * 2617 section 3.2.2. diff --git a/test/org/apache/tomcat/util/http/parser/TestAuthorizationDigest.java b/test/org/apache/tomcat/util/http/parser/TestAuthorizationDigest.java index b7787e9..9436f33 100644 --- a/test/org/apache/tomcat/util/http/parser/TestAuthorizationDigest.java +++ b/test/org/apache/tomcat/util/http/parser/TestAuthorizationDigest.java @@ -318,6 +318,16 @@ public class TestAuthorizationDigest { } @Test + public void testEmptyQop() throws Exception { + String header = "Digest qop="; + + StringReader input = new StringReader(header); + + Map<String,String> result = Authorization.parseAuthorizationDigest(input); + Assert.assertNull(result); + } + + @Test public void testEmptyQuotedTokenQop() throws Exception { String header = "Digest qop=\"\""; @@ -472,8 +482,20 @@ public class TestAuthorizationDigest { } @Test - public void testNotDigest() throws Exception { - String header = "SomethingElse a=b"; + public void testParseAuthParamBEscaped() throws Exception { + // Test for HttpParser.readTokenOrQuotedString() + // auth-param = token "=" ( token | quoted-string ) + String header = "Digest a=\"b\\\"b\""; + + StringReader input = new StringReader(header); + + Map<String,String> result = Authorization.parseAuthorizationDigest(input); + Assert.assertEquals("b\"b", result.get("a")); + } + + @Test + public void testQuotedStringNoQuotes() throws Exception { + String header = "Digest username=a"; StringReader input = new StringReader(header); @@ -482,8 +504,12 @@ public class TestAuthorizationDigest { } @Test - public void testCoverage() { - // Here to add code coverage of default constructor - Assert.assertNotNull(new Authorization()); + public void testNotDigest() throws Exception { + String header = "SomethingElse a=b"; + + StringReader input = new StringReader(header); + + Map<String,String> result = Authorization.parseAuthorizationDigest(input); + Assert.assertNull(result); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org