From 10ca47490e5f3958345ad37c43167ffafaba6c6e Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Sat, 28 May 2011 13:49:38 +0000 Subject: [PATCH] HTTPCLIENT-1097 Add a test to check status quo for 2TLD matching Also add disabled test for wildcard 2TKD matching git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1128647 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/conn/ssl/TestHostnameVerifier.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java b/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java index e82b002c2..0c7e2b5d0 100644 --- a/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java +++ b/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java @@ -314,5 +314,24 @@ public class TestHostnameVerifier { checkMatching(bhv, "s.a.b.c", cns, alt, false); // OK checkMatching(shv, "s.a.b.c", cns, alt, true); // subdomain not OK + + checkWildcard("s*.co.uk", false); // 2 character TLD, invalid 2TLD + checkWildcard("s*.gov.uk", false); // 2 character TLD, invalid 2TLD + checkWildcard("s*.gouv.uk", false); // 2 character TLD, invalid 2TLD + } + + // Helper + private void checkWildcard(String host, boolean isOK) { + Assert.assertTrue(host+" should be "+isOK, isOK==AbstractVerifier.acceptableCountryWildcard(host)); + } + + @Test + // Various checks of 2TLDs + public void testacceptableCountryWildcards() { + checkWildcard("*.co.org", true); // Not a 2 character TLD + checkWildcard("s*.co.org", true); // Not a 2 character TLD + checkWildcard("*.co.uk", false); // 2 character TLD, invalid 2TLD + checkWildcard("*.gov.uk", false); // 2 character TLD, invalid 2TLD + checkWildcard("*.gouv.uk", false); // 2 character TLD, invalid 2TLD } }