Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: components/cast_certificate/cast_certificate_unittest.cc

Issue 2050983002: Cast device revocation checking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test suite runner. Updated some tests. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/time/time.h"
6 #include "components/cast_certificate/cast_cert_validator.h"
7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h"
8 #include "components/cast_certificate/cast_crl.h"
9 #include "components/cast_certificate/proto/test_suite.pb.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace cast_certificate {
13 namespace {
14
15 const unsigned char kCastCRLTestRootCaDer[] = {
16 0x30, 0x82, 0x03, 0xee, 0x30, 0x82, 0x02, 0xd6, 0xa0, 0x03, 0x02, 0x01,
17 0x02, 0x02, 0x02, 0x00, 0x91, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
18 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x81, 0x88, 0x31,
19 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53,
20 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43,
21 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30,
22 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e,
23 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31, 0x13, 0x30,
24 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47, 0x6f, 0x6f, 0x67,
25 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03,
26 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74, 0x31, 0x28, 0x30,
27 0x26, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1f, 0x43, 0x61, 0x73, 0x74,
28 0x20, 0x43, 0x52, 0x4c, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x6e,
29 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x20, 0x52, 0x6f, 0x6f, 0x74,
30 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x35, 0x32,
31 0x35, 0x32, 0x31, 0x30, 0x30, 0x30, 0x36, 0x5a, 0x17, 0x0d, 0x33, 0x36,
32 0x30, 0x35, 0x32, 0x30, 0x32, 0x31, 0x30, 0x30, 0x30, 0x36, 0x5a, 0x30,
33 0x81, 0x88, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
34 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08,
35 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61,
36 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d,
37 0x6f, 0x75, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77,
38 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47,
39 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30,
40 0x0b, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74,
41 0x31, 0x28, 0x30, 0x26, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1f, 0x43,
42 0x61, 0x73, 0x74, 0x20, 0x43, 0x52, 0x4c, 0x20, 0x54, 0x65, 0x73, 0x74,
43 0x20, 0x55, 0x6e, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x20, 0x52,
44 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
45 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
46 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82,
47 0x01, 0x01, 0x00, 0xb5, 0xc1, 0xbe, 0xd4, 0x34, 0x2c, 0xd7, 0xdf, 0x99,
48 0x21, 0xa9, 0x4b, 0x56, 0xc3, 0x2e, 0x78, 0x21, 0x0d, 0xa8, 0xa9, 0xa0,
49 0x4c, 0x2d, 0x62, 0xcb, 0x4f, 0xc5, 0xa0, 0xa7, 0x47, 0x1c, 0x9d, 0x2a,
50 0xeb, 0x61, 0xd1, 0xd4, 0xcc, 0x24, 0x23, 0xe5, 0x11, 0x0f, 0x18, 0x81,
51 0x2a, 0x56, 0x41, 0x30, 0x6f, 0x84, 0x04, 0x09, 0xba, 0x0f, 0xec, 0xd7,
52 0x2f, 0xc6, 0xc4, 0xc4, 0x91, 0x2d, 0xca, 0x6d, 0x76, 0x54, 0xb2, 0xb2,
53 0x5a, 0x59, 0xc1, 0x3d, 0x17, 0xf2, 0x7f, 0x80, 0x22, 0xb9, 0x39, 0xc5,
54 0xc0, 0x74, 0x74, 0x9d, 0x70, 0xb9, 0xc7, 0x60, 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x55, 0x1d, 0x13, 0x04,
70 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x1d, 0x06,
71 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x56, 0x47, 0xa3, 0x12,
72 0xa6, 0xdb, 0xb7, 0xf3, 0xf1, 0xe4, 0x68, 0x62, 0xcb, 0x01, 0x45, 0xfd,
73 0x2b, 0x02, 0x73, 0x68, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04,
74 0x18, 0x30, 0x16, 0x80, 0x14, 0x56, 0x47, 0xa3, 0x12, 0xa6, 0xdb, 0xb7,
75 0xf3, 0xf1, 0xe4, 0x68, 0x62, 0xcb, 0x01, 0x45, 0xfd, 0x2b, 0x02, 0x73,
76 0x68, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02,
77 0x02, 0x04, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
78 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x22, 0xce,
79 0x56, 0x31, 0xcd, 0xe0, 0xac, 0xb4, 0xaf, 0x70, 0x8a, 0x0a, 0x60, 0x4d,
80 0xa8, 0x16, 0x81, 0x11, 0xcf, 0xb6, 0xcf, 0x89, 0x87, 0x86, 0xec, 0x8e,
81 0x72, 0xb3, 0xbc, 0x01, 0xb4, 0x29, 0xb1, 0x88, 0x48, 0x65, 0xcd, 0x7c,
82 0x8f, 0xa0, 0x6f, 0x05, 0xb8, 0x60, 0x28, 0x60, 0x1b, 0x8d, 0x61, 0xeb,
83 0xe5, 0xa5, 0xc0, 0xb5, 0x11, 0x8d, 0x4d, 0x73, 0x73, 0x3a, 0x82, 0xa9,
84 0x39, 0xfe, 0x5a, 0x54, 0x28, 0x69, 0x1c, 0xec, 0x9e, 0xb7, 0x1c, 0x3d,
85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
100 0x82, 0xed};
101
102 const unsigned char kCastTestRootCaDer[] = {
103 0x30, 0x82, 0x03, 0xe5, 0x30, 0x82, 0x02, 0xcd, 0xa0, 0x03, 0x02, 0x01,
104 0x02, 0x02, 0x01, 0x1c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
105 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x81, 0x84, 0x31, 0x0b,
106 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31,
107 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61,
108 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14,
109 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e, 0x74,
110 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31, 0x13, 0x30, 0x11,
111 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47, 0x6f, 0x6f, 0x67, 0x6c,
112 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55,
113 0x04, 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74, 0x31, 0x24, 0x30, 0x22,
114 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1b, 0x43, 0x61, 0x73, 0x74, 0x20,
115 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x6e, 0x74, 0x72, 0x75, 0x73, 0x74,
116 0x65, 0x64, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e,
117 0x17, 0x0d, 0x31, 0x35, 0x30, 0x31, 0x32, 0x31, 0x32, 0x33, 0x34, 0x31,
118 0x32, 0x36, 0x5a, 0x17, 0x0d, 0x33, 0x35, 0x30, 0x31, 0x31, 0x36, 0x32,
119 0x33, 0x34, 0x31, 0x32, 0x36, 0x5a, 0x30, 0x81, 0x84, 0x31, 0x0b, 0x30,
120 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13,
121 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c,
122 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06,
123 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e, 0x74, 0x61,
124 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31, 0x13, 0x30, 0x11, 0x06,
125 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
126 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04,
127 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74, 0x31, 0x24, 0x30, 0x22, 0x06,
128 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1b, 0x43, 0x61, 0x73, 0x74, 0x20, 0x54,
129 0x65, 0x73, 0x74, 0x20, 0x55, 0x6e, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65,
130 0x64, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01,
131 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
132 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01,
133 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc1, 0xe4, 0x4c, 0x2e, 0xe0, 0xac,
134 0x5c, 0xda, 0xe1, 0xb7, 0xe0, 0xfe, 0xf5, 0x19, 0x2a, 0x6b, 0xeb, 0xb5,
135 0x8d, 0x9c, 0xdd, 0xf6, 0xd9, 0x5f, 0x84, 0x64, 0xf8, 0xa9, 0x4b, 0x07,
136 0x55, 0x78, 0x73, 0xf7, 0x14, 0x38, 0x38, 0x94, 0x13, 0x70, 0xd9, 0x87,
137 0x23, 0xd4, 0x91, 0xc2, 0x93, 0xd1, 0x3f, 0x86, 0xad, 0xa7, 0xf6, 0x39,
138 0xe9, 0x78, 0xc0, 0xb8, 0x3e, 0x32, 0x40, 0xec, 0x83, 0x4c, 0xa2, 0x47,
139 0x96, 0x75, 0xaf, 0xfc, 0x1d, 0x35, 0x1b, 0x00, 0xda, 0x9a, 0xa5, 0x6c,
140 0xcd, 0x1b, 0x04, 0x0a, 0xe6, 0xbd, 0xa9, 0xe4, 0x5d, 0x67, 0x71, 0x7d,
141 0x60, 0xc8, 0xe1, 0x59, 0x27, 0xc3, 0xf1, 0x87, 0x85, 0x69, 0xb1, 0xe8,
142 0xe4, 0x39, 0x92, 0x84, 0xdb, 0xdf, 0x96, 0x71, 0xb8, 0x5b, 0xa9, 0xef,
143 0xb3, 0xde, 0xd4, 0xa6, 0xc6, 0x4c, 0xcb, 0x4b, 0x02, 0xd9, 0x84, 0xd1,
144 0x47, 0x1a, 0x45, 0xd8, 0x5d, 0x9f, 0xae, 0x09, 0x69, 0x39, 0x1c, 0x4a,
145 0xd1, 0xf0, 0x9a, 0x88, 0x59, 0x54, 0x44, 0x8e, 0x58, 0x96, 0x58, 0x24,
146 0x0c, 0xd5, 0x9a, 0xbc, 0x7b, 0x81, 0x2c, 0x2c, 0x55, 0x52, 0xac, 0x06,
147 0x37, 0x7d, 0x52, 0x89, 0x58, 0x19, 0xcd, 0xfe, 0xf5, 0x55, 0x17, 0x57,
148 0xe3, 0xc2, 0x47, 0xc3, 0xbe, 0x61, 0x59, 0x9f, 0x86, 0xfc, 0x51, 0x20,
149 0x11, 0x13, 0xad, 0x62, 0xd1, 0x3b, 0xb4, 0x55, 0x83, 0x5e, 0x3d, 0x26,
150 0xd0, 0xc8, 0x0d, 0x36, 0x2e, 0x6b, 0x86, 0xaf, 0x6c, 0xcc, 0x5d, 0x99,
151 0x8f, 0x93, 0x18, 0x47, 0xdf, 0xf9, 0x29, 0xcd, 0x6b, 0xc6, 0x5d, 0x3f,
152 0x01, 0x15, 0xb5, 0x06, 0x0d, 0xf4, 0xce, 0x4a, 0x21, 0xaa, 0x36, 0x4f,
153 0x45, 0xa0, 0xca, 0xb1, 0x94, 0x78, 0x49, 0xb7, 0x3a, 0xc9, 0x23, 0x01,
154 0x58, 0x87, 0x10, 0x85, 0x4f, 0x6e, 0xba, 0x90, 0x40, 0xef, 0x02, 0x03,
155 0x01, 0x00, 0x01, 0xa3, 0x60, 0x30, 0x5e, 0x30, 0x0f, 0x06, 0x03, 0x55,
156 0x1d, 0x13, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x02,
157 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xcc,
158 0xc4, 0xce, 0x8e, 0xd4, 0x73, 0x22, 0x4d, 0x0f, 0xbc, 0x8c, 0xfb, 0xf5,
159 0x55, 0xf1, 0x61, 0xa5, 0x38, 0x90, 0xc9, 0x30, 0x1f, 0x06, 0x03, 0x55,
160 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xcc, 0xc4, 0xce, 0x8e,
161 0xd4, 0x73, 0x22, 0x4d, 0x0f, 0xbc, 0x8c, 0xfb, 0xf5, 0x55, 0xf1, 0x61,
162 0xa5, 0x38, 0x90, 0xc9, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04,
163 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
164 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01,
165 0x00, 0xa9, 0xbc, 0x38, 0x09, 0xa4, 0x2b, 0x56, 0x2c, 0xad, 0xed, 0x32,
166 0xfb, 0x9a, 0x71, 0x62, 0x8d, 0x12, 0x3d, 0xff, 0x2d, 0x9a, 0x84, 0x70,
167 0x9a, 0x09, 0x5a, 0x0b, 0x29, 0xa8, 0x7f, 0x6f, 0x91, 0x93, 0x9d, 0x93,
168 0xcc, 0x4c, 0xa3, 0xd8, 0x9d, 0x75, 0x81, 0x27, 0xc4, 0x16, 0xc4, 0x8e,
169 0x25, 0x97, 0xa5, 0xce, 0x3e, 0x33, 0x2a, 0x1a, 0x6f, 0x03, 0x68, 0xb9,
170 0x35, 0x0e, 0xee, 0x99, 0xd5, 0xe0, 0x96, 0xd9, 0x59, 0x7b, 0xa7, 0xb9,
171 0x8d, 0x86, 0x7d, 0x5d, 0x54, 0x7d, 0xb9, 0x48, 0xac, 0xfe, 0x57, 0xdd,
172 0x50, 0x94, 0xc7, 0x6b, 0xf4, 0x29, 0xf4, 0xeb, 0x9a, 0xaa, 0x63, 0xbb,
173 0x91, 0x64, 0x52, 0xb4, 0x56, 0x7d, 0xe2, 0x73, 0x3b, 0x65, 0x9e, 0x0e,
174 0xc0, 0x8c, 0x2c, 0x44, 0xf3, 0x12, 0xb5, 0x1c, 0x4e, 0x41, 0x80, 0x3f,
175 0xa2, 0x17, 0xc6, 0xf2, 0x53, 0xe6, 0x48, 0x94, 0x5d, 0xae, 0xb9, 0x7c,
176 0x72, 0x4f, 0x7f, 0x77, 0x43, 0x37, 0xf8, 0xdc, 0x05, 0x8d, 0xac, 0x0b,
177 0x7d, 0x61, 0x7d, 0x7d, 0xfc, 0x59, 0x6f, 0x04, 0x52, 0x35, 0xb0, 0xdc,
178 0xea, 0xad, 0xce, 0xfe, 0x15, 0x36, 0x0a, 0x2e, 0x79, 0x0e, 0xb7, 0xa1,
179 0x93, 0x61, 0x34, 0x9a, 0x47, 0x0d, 0xc1, 0x6b, 0xb6, 0xae, 0xd2, 0x9b,
180 0x01, 0xf3, 0x6b, 0xff, 0x5b, 0xd4, 0xf9, 0x03, 0x5e, 0x81, 0x1a, 0xe7,
181 0x90, 0x28, 0xe8, 0xe5, 0x7d, 0x76, 0x15, 0xc2, 0x73, 0x46, 0xa3, 0xc2,
182 0xbd, 0x41, 0x51, 0xfe, 0x57, 0xef, 0x58, 0x6e, 0xb1, 0x94, 0x82, 0xea,
183 0xc0, 0xf1, 0x9a, 0x6f, 0xf8, 0x31, 0x00, 0xc3, 0xce, 0x22, 0x4f, 0x28,
184 0x5b, 0xa1, 0xe2, 0x17, 0xb5, 0x1c, 0xba, 0xd8, 0xde, 0x73, 0xec, 0xa2,
185 0x3d, 0xcc, 0x12, 0xfe, 0xf5, 0xae, 0xc9, 0xfa, 0xa7, 0x4e, 0xe3, 0x0b,
186 0x4e, 0x24, 0x18, 0xa7, 0xf0};
187
188 // Indicates the expected result of CRL verification
189 enum TestResultCRL {
190 RESULT_CRL_INVALID,
191 RESULT_CRL_VALID,
192 };
193
194 // Indicates the expected result of test verification
195 enum TestResultCert {
196 RESULT_CERT_INVALID,
197 RESULT_CERT_VALID,
198 };
199
200 bool RunTest(const std::vector<std::string> certificate_chain,
201 const std::string& crl_bundle,
202 const base::Time::Exploded& time) {
203 ClearCRLTrustAnchorForTest();
204 EXPECT_TRUE(AddCRLTrustAnchorForTest(kCastCRLTestRootCaDer,
205 sizeof(kCastCRLTestRootCaDer)));
206 EXPECT_TRUE(
207 AddTrustAnchorForTest(kCastTestRootCaDer, sizeof(kCastTestRootCaDer)));
208
209 std::unique_ptr<CastCRL> crl = ParseCRL(crl_bundle, time);
210 if (!crl_bundle.empty() && crl.get() == nullptr)
211 return false;
212
213 std::unique_ptr<CertVerificationContext> context;
214 CastDeviceCertPolicy policy;
215 return VerifyDeviceCert(certificate_chain, time, &context, &policy, crl.get(),
216 {});
217 }
218
219 void RunTestSuite(const std::string& test_suite_file_name) {
220 std::string testsuite_raw =
221 cast_certificate::testing::ReadFromFile(test_suite_file_name);
222 DeviceCertTestSuite test_suite;
223 ASSERT_TRUE(test_suite.ParseFromString(testsuite_raw));
224 uint16_t success = 0;
225 uint16_t failed = 0;
226 std::vector<std::string> failed_tests;
227 for (auto const& test_case : test_suite.tests()) {
228 LOG(INFO) << "[ RUN ] " << test_case.description();
229 bool expected_result = test_case.path_is_valid();
230 std::vector<std::string> certificate_chain;
231 for (auto const& cert : test_case.der_cert_path()) {
232 certificate_chain.push_back(cert);
233 }
234 uint64_t verification_time_millis = test_case.verification_time_millis();
235 base::Time verification_time =
236 base::Time::UnixEpoch() +
237 base::TimeDelta::FromMilliseconds(verification_time_millis);
238 base::Time::Exploded exploded_time;
239 verification_time.UTCExplode(&exploded_time);
240 std::string crl_bundle = test_case.crl_bundle();
241 bool result = RunTest(certificate_chain, crl_bundle, exploded_time);
242 if (expected_result != result) {
243 LOG(INFO) << "[ FAILED ] " << test_case.description();
244 ++failed;
245 failed_tests.push_back(test_case.description());
246 } else {
247 LOG(INFO) << "[ PASSED ] " << test_case.description();
248 ++success;
249 }
250 EXPECT_EQ(expected_result, result);
251 }
252 LOG(INFO) << "[ PASSED ] " << success << " test(s).";
253 if (failed) {
254 LOG(INFO) << "[ FAILED ] " << failed << " test(s), listed below:";
255 for (const auto& failed_test : failed_tests) {
256 LOG(INFO) << "[ FAILED ] " << failed_test;
257 }
258 }
259 }
260
261 TEST(CastCertificateTest, TestSuite1) {
262 RunTestSuite("testsuite/testsuite1.pb");
263 }
264
265 } // namespace
266
267 } // namespace cast_certificate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698