Skip to content

Commit

Permalink
add a few new HashVerify unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gurnec committed Aug 25, 2016
1 parent a152a3a commit 7d22d7f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 24 deletions.
47 changes: 29 additions & 18 deletions UnitTests/HashVerify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ public HashVerifySetup()
public class HashVerify : IClassFixture<HashVerifySetup>
{
// from HashCheckResources.h
const string IDC_MATCH_RESULTS = "404";
const string IDC_PENDING_RESULTS = "410";
const string IDC_MATCH_RESULTS = "404";
const string IDC_MISMATCH_RESULTS = "406";
const string IDC_UNREADABLE_RESULTS = "408";
const string IDC_PENDING_RESULTS = "410";

HashVerifySetup common;

Expand All @@ -61,19 +63,28 @@ public HashVerify(HashVerifySetup c)
}

[Theory]
[InlineData("SHA1ShortMsg.rsp.sha1")]
[InlineData("SHA1LongMsg.rsp.sha1")]
[InlineData("SHA256ShortMsg.rsp.sha256")]
[InlineData("SHA256LongMsg.rsp.sha256")]
[InlineData("SHA512ShortMsg.rsp.sha512")]
[InlineData("SHA512LongMsg.rsp.sha512")]
[InlineData("SHA3_256ShortMsg.rsp.sha3-256")]
[InlineData("SHA3_256LongMsg.rsp.sha3-256")]
[InlineData("SHA3_512ShortMsg.rsp.sha3-512")]
[InlineData("SHA3_512LongMsg.rsp.sha3-512")]
[InlineData("hashcheck.md5")]
[InlineData("hashcheck.sha1")]
public void NistTest(string name)
[InlineData("SHA1ShortMsg.rsp.sha1", IDC_MATCH_RESULTS)]
[InlineData("SHA1LongMsg.rsp.sha1", IDC_MATCH_RESULTS)]
[InlineData("SHA256ShortMsg.rsp.sha256", IDC_MATCH_RESULTS)]
[InlineData("SHA256LongMsg.rsp.sha256", IDC_MATCH_RESULTS)]
[InlineData("SHA512ShortMsg.rsp.sha512", IDC_MATCH_RESULTS)]
[InlineData("SHA512LongMsg.rsp.sha512", IDC_MATCH_RESULTS)]
[InlineData("SHA3_256ShortMsg.rsp.sha3-256", IDC_MATCH_RESULTS)]
[InlineData("SHA3_256LongMsg.rsp.sha3-256", IDC_MATCH_RESULTS)]
[InlineData("SHA3_512ShortMsg.rsp.sha3-512", IDC_MATCH_RESULTS)]
[InlineData("SHA3_512LongMsg.rsp.sha3-512", IDC_MATCH_RESULTS)]
[InlineData("hashcheck.md5", IDC_MATCH_RESULTS)]
[InlineData("hashcheck.sha1", IDC_MATCH_RESULTS)]
//
// tests for disambiguating vectors of the same bit length
[InlineData("SHA256ShortMsg.rsp.asc", IDC_MATCH_RESULTS)]
[InlineData("SHA3_256ShortMsg.rsp.asc", IDC_MATCH_RESULTS)]
//
// negative tests
[InlineData(@"mismatch.sha256", IDC_MISMATCH_RESULTS)]
[InlineData(@"mismatch.asc", IDC_MISMATCH_RESULTS)]
[InlineData(@"unreadable.sha256", IDC_UNREADABLE_RESULTS)]
public void NistTest(string name, string expected_label_id)
{
// This opens a HashCheck Verify window in the current process
Process.Start(Path.Combine(common.PATH_PREFIX, name));
Expand All @@ -88,10 +99,10 @@ public void NistTest(string name)
while (! re0.IsMatch(pending_results.Text))
System.Threading.Thread.Sleep(0);

// On success, the hash matches should be "# of #" where the #'s are the same
// On success, the expected label should read "# of #" where the #'s are the same
Label match_results = verify_window.Get<Label>(SearchCriteria.ByNativeProperty(
AutomationElement.AutomationIdProperty, IDC_MATCH_RESULTS));
Assert.Matches(@"\b(\d{2,3})\b.*\b\1\b", match_results.Text);
AutomationElement.AutomationIdProperty, expected_label_id));
Assert.Matches(@"\b(\d+)\b.*\b\1\b", match_results.Text);
}
finally
{
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/mismatch.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ffffffff6ffe3eb76178a0f938d5b78598618fed79938dc9a1360a2e81fe4a5e *..\HashVerify.cs
ed8d61f18752cab0dca7e956a4f0c4e65088fc372ec1c056d3544d59ffffffff *..\HashProp.cs
2 changes: 2 additions & 0 deletions UnitTests/unreadable.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
7b12edfa6ffe3eb76178a0f938d5b78598618fed79938dc9a1360a2e81fe4a5e *HashVerify.unreadable
ed8d61f18752cab0dca7e956a4f0c4e65088fc372ec1c056d3544d597aad2e5a *HashProp.unreadable
7 changes: 7 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ before_test:
- C:\Python35-x64\python get-sha-test-vectors.py
- C:\Python35-x64\python get-md5-test-vectors.py
- C:\Python35-x64\python gen-big-test-vector.py
# tests for disambiguating vectors of the same bit length
- copy vectors\SHA256ShortMsg.rsp.sha256 vectors\SHA256ShortMsg.rsp.asc
- copy vectors\SHA3_256ShortMsg.rsp.sha3-256 vectors\SHA3_256ShortMsg.rsp.asc
# negative tests
- copy mismatch.sha256 vectors\
- copy mismatch.sha256 vectors\mismatch.asc
- copy unreadable.sha256 vectors\

test_script:
- cd "%APPVEYOR_BUILD_FOLDER%"
Expand Down
8 changes: 4 additions & 4 deletions installer/HashCheck.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Unicode true

Name "HashCheck"
OutFile "HashCheckSetup-v2.4.0.35-beta.exe"
OutFile "HashCheckSetup-v2.4.0.36-beta.exe"

RequestExecutionLevel admin
ManifestSupportedOS all
Expand Down Expand Up @@ -53,15 +53,15 @@ FunctionEnd
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Catalan"

VIProductVersion "2.4.0.35-beta"
VIProductVersion "2.4.0.36-beta"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "HashCheck Shell Extension"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.4.0.35-beta"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.4.0.36-beta"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Installer distributed from https://github.com/gurnec/HashCheck/releases"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" ""
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" ""
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © Kai Liu, Christopher Gurnee, Tim Schlueter, et al. All rights reserved."
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installer (x86/x64) from https://github.com/gurnec/HashCheck/releases"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.4.0.35-beta"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.4.0.36-beta"

; With solid compression, files that are required before the
; actual installation should be stored first in the data block,
Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#define HASHCHECK_NAME_STR "HashCheck Shell Extension"

// Full version: MUST be in the form of major,minor,revision,build
#define HASHCHECK_VERSION_FULL 2,4,0,35
#define HASHCHECK_VERSION_FULL 2,4,0,36

// String version: May be any suitable string
#define HASHCHECK_VERSION_STR "2.4.0.35-beta"
#define HASHCHECK_VERSION_STR "2.4.0.36-beta"

#ifdef _USRDLL
// PE version: MUST be in the form of major.minor
Expand Down

0 comments on commit 7d22d7f

Please sign in to comment.