From eb2fb85459e6090c530c30b52b8bf65b945a2965 Mon Sep 17 00:00:00 2001 From: Yves Langisch Date: Mon, 17 Dec 2012 17:06:26 +0000 Subject: [PATCH] Add test. Former-commit-id: 588cd4d1ad71bbcaa63a87846cd8ce1bc0cfd6ce --- .gitattributes | 1 + .../ch/cyberduck/core/ssl/HostnameVerifier.cs | 4 +- test/ch/cyberduck/Test.csproj | 1 + .../core/ssl/HostnameVerifierTest.cs | 37 +++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/ch/cyberduck/core/ssl/HostnameVerifierTest.cs diff --git a/.gitattributes b/.gitattributes index 7edd7e6802a..eabb1c8ea04 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2948,6 +2948,7 @@ test/ch/cyberduck/core/local/LocalImplTest.cs -text svneol=unset#application/oct test/ch/cyberduck/core/serializer/impl/1c158c34-db8a-4c32-a732-abd9447bb27c.duck -text test/ch/cyberduck/core/serializer/impl/Dropbox.cyberduckprofile -text test/ch/cyberduck/core/sftp/openssh/config -text +test/ch/cyberduck/core/ssl/HostnameVerifierTest.cs -text test/ch/cyberduck/core/ssl/\*.cyberduck.ch[!!-~](OXxlRDVcWqdPEvFm).cer -text test/ch/cyberduck/ui/controller/PersistentFormHandlerTest.cs -text test/org/kohsuke/putty/PuTTYKeyTest.java -text diff --git a/source/ch/cyberduck/core/ssl/HostnameVerifier.cs b/source/ch/cyberduck/core/ssl/HostnameVerifier.cs index cda57136045..23be7bf9276 100644 --- a/source/ch/cyberduck/core/ssl/HostnameVerifier.cs +++ b/source/ch/cyberduck/core/ssl/HostnameVerifier.cs @@ -28,7 +28,7 @@ namespace Ch.Cyberduck.Core.Ssl { - internal class HostnameVerifier + public class HostnameVerifier { private static readonly Logger Log = Logger.getLogger(typeof (HostnameVerifier).FullName); @@ -146,7 +146,7 @@ private static string GetCommonName(X509Certificate2 cert) return null; } - private static bool Match(string hostname, string pattern) + public static bool Match(string hostname, string pattern) { // check if this is a pattern int index = pattern.IndexOf('*'); diff --git a/test/ch/cyberduck/Test.csproj b/test/ch/cyberduck/Test.csproj index f5845425913..b80228a05ca 100644 --- a/test/ch/cyberduck/Test.csproj +++ b/test/ch/cyberduck/Test.csproj @@ -76,6 +76,7 @@ + diff --git a/test/ch/cyberduck/core/ssl/HostnameVerifierTest.cs b/test/ch/cyberduck/core/ssl/HostnameVerifierTest.cs new file mode 100644 index 00000000000..93d62c8e5f3 --- /dev/null +++ b/test/ch/cyberduck/core/ssl/HostnameVerifierTest.cs @@ -0,0 +1,37 @@ +// +// Copyright (c) 2010-2012 Yves Langisch. All rights reserved. +// http://cyberduck.ch/ +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Bug fixes, suggestions and comments should be sent to: +// yves@cyberduck.ch +// + +using NUnit.Framework; + +namespace Ch.Cyberduck.Core.Ssl +{ + [TestFixture] + internal class HostnameVerifierTest + { + [SetUp] + public void Init() + { + } + + [Test] + public void WilcardCertificate() + { + Assert.True(HostnameVerifier.Match("foo.secure.example.com", "*.secure.example.com")); + } + } +} \ No newline at end of file