Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CD12A6A3B for ; Sat, 28 May 2011 13:50:04 +0000 (UTC) Received: (qmail 7804 invoked by uid 500); 28 May 2011 13:50:04 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 7772 invoked by uid 500); 28 May 2011 13:50:04 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 7765 invoked by uid 99); 28 May 2011 13:50:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 May 2011 13:50:04 +0000 X-ASF-Spam-Status: No, hits=-1996.5 required=5.0 tests=ALL_TRUSTED,URIBL_BLACK X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 May 2011 13:49:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0E73723889BF; Sat, 28 May 2011 13:49:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1128647 - /httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java Date: Sat, 28 May 2011 13:49:39 -0000 To: commits@hc.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110528134939.0E73723889BF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebb Date: Sat May 28 13:49:38 2011 New Revision: 1128647 URL: http://svn.apache.org/viewvc?rev=1128647&view=rev Log: HTTPCLIENT-1097 Add a test to check status quo for 2TLD matching Also add disabled test for wildcard 2TKD matching Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java?rev=1128647&r1=1128646&r2=1128647&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java Sat May 28 13:49:38 2011 @@ -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 } }