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
This commit is contained in:
Sebastian Bazley 2011-05-28 13:49:38 +00:00
parent 2a08b55242
commit 10ca47490e
1 changed files with 19 additions and 0 deletions

View File

@ -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
}
}