@@ -13,76 +13,76 @@ using namespace AppInstaller::Certificates;
13
13
TEST_CASE (" Certificates_NoPinningSucceeds" , " [certificates]" )
14
14
{
15
15
PinningDetails expected;
16
- expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::None);
16
+ expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::None);
17
17
18
18
PinningDetails actual;
19
- actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
19
+ actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
20
20
21
21
REQUIRE (expected.Validate (actual.GetCertificate ()));
22
22
}
23
23
24
24
TEST_CASE (" Certificates_PublicKeyMismatch" , " [certificates]" )
25
25
{
26
26
PinningDetails expected;
27
- expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::PublicKey);
27
+ expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::PublicKey);
28
28
29
29
PinningDetails actual;
30
- actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
30
+ actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
31
31
32
32
REQUIRE (!expected.Validate (actual.GetCertificate ()));
33
33
}
34
34
35
35
TEST_CASE (" Certificates_PublicKeyMatch" , " [certificates]" )
36
36
{
37
37
PinningDetails expected;
38
- expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::PublicKey);
38
+ expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::PublicKey);
39
39
40
40
PinningDetails actual;
41
- actual.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2);
41
+ actual.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE );
42
42
43
43
REQUIRE (expected.Validate (actual.GetCertificate ()));
44
44
}
45
45
46
46
TEST_CASE (" Certificates_SubjectMismatch" , " [certificates]" )
47
47
{
48
48
PinningDetails expected;
49
- expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::Subject);
49
+ expected.LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject);
50
50
51
51
PinningDetails actual;
52
- actual.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2);
52
+ actual.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE );
53
53
54
54
REQUIRE (!expected.Validate (actual.GetCertificate ()));
55
55
}
56
56
57
57
TEST_CASE (" Certificates_SubjectMatch" , " [certificates]" )
58
58
{
59
59
PinningDetails expected;
60
- expected.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2).SetPinning (PinningVerificationType::Subject);
60
+ expected.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject);
61
61
62
62
PinningDetails actual;
63
- actual.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2);
63
+ actual.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE );
64
64
65
65
REQUIRE (expected.Validate (actual.GetCertificate ()));
66
66
}
67
67
68
68
TEST_CASE (" Certificates_IssuerMismatch" , " [certificates]" )
69
69
{
70
70
PinningDetails expected;
71
- expected.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2).SetPinning (PinningVerificationType::Issuer);
71
+ expected.LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Issuer);
72
72
73
73
PinningDetails actual;
74
- actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
74
+ actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
75
75
76
76
REQUIRE (!expected.Validate (actual.GetCertificate ()));
77
77
}
78
78
79
79
TEST_CASE (" Certificates_IssuerMatch" , " [certificates]" )
80
80
{
81
81
PinningDetails expected;
82
- expected.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2).SetPinning (PinningVerificationType::Issuer);
82
+ expected.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Issuer);
83
83
84
84
PinningDetails actual;
85
- actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
85
+ actual.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
86
86
87
87
REQUIRE (expected.Validate (actual.GetCertificate ()));
88
88
}
@@ -91,15 +91,15 @@ TEST_CASE("Certificates_ChainLengthDiffers", "[certificates]")
91
91
{
92
92
PinningChain chain;
93
93
auto chainElement = chain.Root ();
94
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::PublicKey);
94
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::PublicKey);
95
95
chainElement = chainElement.Next ();
96
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
96
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
97
97
98
98
PinningConfiguration config;
99
99
config.AddChain (chain);
100
100
101
101
PinningDetails details;
102
- details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
102
+ details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
103
103
104
104
REQUIRE (!config.Validate (details.GetCertificate ()));
105
105
}
@@ -112,7 +112,7 @@ TEST_CASE("Certificates_EmptyChainRejects", "[certificates]")
112
112
config.AddChain (chain);
113
113
114
114
PinningDetails details;
115
- details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
115
+ details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
116
116
117
117
REQUIRE (!config.Validate (details.GetCertificate ()));
118
118
}
@@ -121,17 +121,17 @@ TEST_CASE("Certificates_ChainOrderDiffers", "[certificates]")
121
121
{
122
122
PinningChain chain;
123
123
auto chainElement = chain.Root ();
124
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::PublicKey);
124
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::PublicKey);
125
125
chainElement = chainElement.Next ();
126
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
126
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
127
127
chainElement = chainElement.Next ();
128
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
128
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
129
129
130
130
PinningConfiguration config;
131
131
config.AddChain (chain);
132
132
133
133
PinningDetails details;
134
- details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
134
+ details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
135
135
136
136
REQUIRE (!config.Validate (details.GetCertificate ()));
137
137
}
@@ -140,17 +140,17 @@ TEST_CASE("Certificates_StoreChain_BuiltInTest", "[certificates]")
140
140
{
141
141
PinningChain chain;
142
142
auto chainElement = chain.Root ();
143
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::PublicKey);
143
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::PublicKey);
144
144
chainElement = chainElement.Next ();
145
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
145
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
146
146
chainElement = chainElement.Next ();
147
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
147
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
148
148
149
149
PinningConfiguration config;
150
150
config.AddChain (chain);
151
151
152
152
PinningDetails details;
153
- details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
153
+ details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
154
154
155
155
REQUIRE (config.Validate (details.GetCertificate ()));
156
156
}
@@ -159,27 +159,27 @@ TEST_CASE("Certificates_MultipleChains_Success", "[certificates]")
159
159
{
160
160
PinningChain chainOutOfOrder;
161
161
auto chainElement = chainOutOfOrder.Root ();
162
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::PublicKey);
162
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::PublicKey);
163
163
chainElement = chainElement.Next ();
164
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
164
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
165
165
chainElement = chainElement.Next ();
166
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
166
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
167
167
168
168
PinningConfiguration config;
169
169
config.AddChain (chainOutOfOrder);
170
170
171
171
PinningChain chain;
172
172
chainElement = chain.Root ();
173
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2).SetPinning (PinningVerificationType::PublicKey);
173
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_ROOT_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::PublicKey);
174
174
chainElement = chainElement.Next ();
175
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
175
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_INTERMEDIATE_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
176
176
chainElement = chainElement.Next ();
177
- chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
177
+ chainElement->LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE ).SetPinning (PinningVerificationType::Subject | PinningVerificationType::Issuer);
178
178
179
179
config.AddChain (chain);
180
180
181
181
PinningDetails details;
182
- details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2);
182
+ details.LoadCertificate (IDX_CERTIFICATE_STORE_LEAF_2, CERTIFICATE_RESOURCE_TYPE );
183
183
184
184
REQUIRE (config.Validate (details.GetCertificate ()));
185
185
}
0 commit comments