main
cs 57 lines 2.2 KB
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolsetTest.CoreNative
4 {
5 using System.Linq;
6 using WixInternal.TestSupport;
7 using WixToolset.Core.Native;
8 using Xunit;
9
10 public class CertificateHashesFixture
11 {
12 [Fact]
13 public void CanGetHashesFromSignedFile()
14 {
15 var cabFile = TestData.Get(@"TestData\test.cab");
16
17 var hashes = CertificateHashes.Read(new[] { cabFile });
18
19 var hash = hashes.Single();
20 WixInternal.TestSupport.WixAssert.StringEqual(cabFile, hash.Path);
21 WixInternal.TestSupport.WixAssert.StringEqual("7EC90B3FC3D580EB571210011F1095E149DCC6BB", hash.PublicKey);
22 WixInternal.TestSupport.WixAssert.StringEqual("0B13494DB50BC185A34389BBBAA01EDD1CF56350", hash.Thumbprint);
23 Assert.Null(hash.Exception);
24 }
25
26 [Fact]
27 public void CannotGetHashesFromUnsignedFile()
28 {
29 var txtFile = TestData.Get(@"TestData\test.txt");
30
31 var hashes = CertificateHashes.Read(new[] { txtFile });
32
33 var hash = hashes.Single();
34 WixInternal.TestSupport.WixAssert.StringEqual(txtFile, hash.Path);
35 Assert.Null(hash.Exception);
36 }
37
38 [Fact]
39 public void CanGetMultipleHashes()
40 {
41 var cabFile = TestData.Get(@"TestData\test.cab");
42 var txtFile = TestData.Get(@"TestData\test.txt");
43
44 var hashes = CertificateHashes.Read(new[] { cabFile, txtFile });
45
46 WixInternal.TestSupport.WixAssert.StringEqual(cabFile, hashes[0].Path);
47 WixInternal.TestSupport.WixAssert.StringEqual("7EC90B3FC3D580EB571210011F1095E149DCC6BB", hashes[0].PublicKey);
48 WixInternal.TestSupport.WixAssert.StringEqual("0B13494DB50BC185A34389BBBAA01EDD1CF56350", hashes[0].Thumbprint);
49 Assert.Null(hashes[0].Exception);
50
51 Assert.Equal(txtFile, hashes[1].Path);
52 Assert.Empty(hashes[1].PublicKey);
53 Assert.Empty(hashes[1].Thumbprint);
54 Assert.Null(hashes[1].Exception);
55 }
56 }
57 }