Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
Former-commit-id: 588cd4d1ad71bbcaa63a87846cd8ce1bc0cfd6ce
  • Loading branch information
ylangisc committed Dec 17, 2012
1 parent bcad72f commit eb2fb85
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions source/ch/cyberduck/core/ssl/HostnameVerifier.cs
Expand Up @@ -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);

Expand Down Expand Up @@ -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('*');
Expand Down
1 change: 1 addition & 0 deletions test/ch/cyberduck/Test.csproj
Expand Up @@ -76,6 +76,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="core\local\LocalImplTest.cs" />
<Compile Include="core\ssl\HostnameVerifierTest.cs" />
<Compile Include="ui\controller\PersistentFormHandlerTest.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
37 changes: 37 additions & 0 deletions 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"));
}
}
}

0 comments on commit eb2fb85

Please sign in to comment.