| Index: components/cast_certificate/cast_certificate_unittest.cc
|
| diff --git a/components/cast_certificate/cast_certificate_unittest.cc b/components/cast_certificate/cast_certificate_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ce3c8d58541a61dfb7d5c12105fda2fb3e065184
|
| --- /dev/null
|
| +++ b/components/cast_certificate/cast_certificate_unittest.cc
|
| @@ -0,0 +1,267 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/time/time.h"
|
| +#include "components/cast_certificate/cast_cert_validator.h"
|
| +#include "components/cast_certificate/cast_cert_validator_test_helpers.h"
|
| +#include "components/cast_certificate/cast_crl.h"
|
| +#include "components/cast_certificate/proto/test_suite.pb.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace cast_certificate {
|
| +namespace {
|
| +
|
| +const unsigned char kCastCRLTestRootCaDer[] = {
|
| + 0x30, 0x82, 0x03, 0xee, 0x30, 0x82, 0x02, 0xd6, 0xa0, 0x03, 0x02, 0x01,
|
| + 0x02, 0x02, 0x02, 0x00, 0x91, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
|
| + 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x81, 0x88, 0x31,
|
| + 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53,
|
| + 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43,
|
| + 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30,
|
| + 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e,
|
| + 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31, 0x13, 0x30,
|
| + 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47, 0x6f, 0x6f, 0x67,
|
| + 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03,
|
| + 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74, 0x31, 0x28, 0x30,
|
| + 0x26, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1f, 0x43, 0x61, 0x73, 0x74,
|
| + 0x20, 0x43, 0x52, 0x4c, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x6e,
|
| + 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x20, 0x52, 0x6f, 0x6f, 0x74,
|
| + 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x36, 0x30, 0x35, 0x32,
|
| + 0x35, 0x32, 0x31, 0x30, 0x30, 0x30, 0x36, 0x5a, 0x17, 0x0d, 0x33, 0x36,
|
| + 0x30, 0x35, 0x32, 0x30, 0x32, 0x31, 0x30, 0x30, 0x30, 0x36, 0x5a, 0x30,
|
| + 0x81, 0x88, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
|
| + 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08,
|
| + 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61,
|
| + 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d,
|
| + 0x6f, 0x75, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77,
|
| + 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47,
|
| + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30,
|
| + 0x0b, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74,
|
| + 0x31, 0x28, 0x30, 0x26, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1f, 0x43,
|
| + 0x61, 0x73, 0x74, 0x20, 0x43, 0x52, 0x4c, 0x20, 0x54, 0x65, 0x73, 0x74,
|
| + 0x20, 0x55, 0x6e, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x20, 0x52,
|
| + 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
|
| + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
|
| + 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82,
|
| + 0x01, 0x01, 0x00, 0xb5, 0xc1, 0xbe, 0xd4, 0x34, 0x2c, 0xd7, 0xdf, 0x99,
|
| + 0x21, 0xa9, 0x4b, 0x56, 0xc3, 0x2e, 0x78, 0x21, 0x0d, 0xa8, 0xa9, 0xa0,
|
| + 0x4c, 0x2d, 0x62, 0xcb, 0x4f, 0xc5, 0xa0, 0xa7, 0x47, 0x1c, 0x9d, 0x2a,
|
| + 0xeb, 0x61, 0xd1, 0xd4, 0xcc, 0x24, 0x23, 0xe5, 0x11, 0x0f, 0x18, 0x81,
|
| + 0x2a, 0x56, 0x41, 0x30, 0x6f, 0x84, 0x04, 0x09, 0xba, 0x0f, 0xec, 0xd7,
|
| + 0x2f, 0xc6, 0xc4, 0xc4, 0x91, 0x2d, 0xca, 0x6d, 0x76, 0x54, 0xb2, 0xb2,
|
| + 0x5a, 0x59, 0xc1, 0x3d, 0x17, 0xf2, 0x7f,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 0x46,
|
| + 0xee, 0x57, 0x17, 0x26, 0x83, 0x4c, 0x1b, 0x02, 0x03, 0x01, 0x00, 0x01,
|
| + 0xa3, 0x60, 0x30, 0x5e, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04,
|
| + 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x1d, 0x06,
|
| + 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x56, 0x47, 0xa3, 0x12,
|
| + 0xa6, 0xdb, 0xb7, 0xf3, 0xf1, 0xe4, 0x68, 0x62, 0xcb, 0x01, 0x45, 0xfd,
|
| + 0x2b, 0x02, 0x73, 0x68, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04,
|
| + 0x18, 0x30, 0x16, 0x80, 0x14, 0x56, 0x47, 0xa3, 0x12, 0xa6, 0xdb, 0xb7,
|
| + 0xf3, 0xf1, 0xe4, 0x68, 0x62, 0xcb, 0x01, 0x45, 0xfd, 0x2b, 0x02, 0x73,
|
| + 0x68, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02,
|
| + 0x02, 0x04, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
|
| + 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x22, 0xce,
|
| + 0x56, 0x31, 0xcd, 0xe0, 0xac, 0xb4, 0xaf, 0x70, 0x8a, 0x0a, 0x60, 0x4d,
|
| + 0xa8, 0x16, 0x81, 0x11, 0xcf, 0xb6, 0xcf, 0x89, 0x87, 0x86, 0xec, 0x8e,
|
| + 0x72, 0xb3, 0xbc, 0x01, 0xb4, 0x29, 0xb1, 0x88, 0x48, 0x65, 0xcd, 0x7c,
|
| + 0x8f, 0xa0, 0x6f, 0x05, 0xb8, 0x60, 0x28, 0x60, 0x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 0xd3, 0x35, 0xd0, 0xdc, 0xa7, 0x41, 0xe0, 0xe3, 0x3e, 0x23, 0xdb, 0x63,
|
| + 0xa8, 0xfc, 0xfb, 0x76, 0x37, 0x59, 0xf8, 0xb2, 0x31, 0xe5, 0x6d, 0xcf,
|
| + 0xfa, 0x17, 0x84, 0xd9, 0x16, 0x2f, 0x97, 0x90, 0x8c, 0x83, 0xf2, 0x6f,
|
| + 0x82, 0xed};
|
| +
|
| +const unsigned char kCastTestRootCaDer[] = {
|
| + 0x30, 0x82, 0x03, 0xe5, 0x30, 0x82, 0x02, 0xcd, 0xa0, 0x03, 0x02, 0x01,
|
| + 0x02, 0x02, 0x01, 0x1c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
|
| + 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x81, 0x84, 0x31, 0x0b,
|
| + 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31,
|
| + 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61,
|
| + 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14,
|
| + 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e, 0x74,
|
| + 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31, 0x13, 0x30, 0x11,
|
| + 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47, 0x6f, 0x6f, 0x67, 0x6c,
|
| + 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55,
|
| + 0x04, 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74, 0x31, 0x24, 0x30, 0x22,
|
| + 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1b, 0x43, 0x61, 0x73, 0x74, 0x20,
|
| + 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x6e, 0x74, 0x72, 0x75, 0x73, 0x74,
|
| + 0x65, 0x64, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e,
|
| + 0x17, 0x0d, 0x31, 0x35, 0x30, 0x31, 0x32, 0x31, 0x32, 0x33, 0x34, 0x31,
|
| + 0x32, 0x36, 0x5a, 0x17, 0x0d, 0x33, 0x35, 0x30, 0x31, 0x31, 0x36, 0x32,
|
| + 0x33, 0x34, 0x31, 0x32, 0x36, 0x5a, 0x30, 0x81, 0x84, 0x31, 0x0b, 0x30,
|
| + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13,
|
| + 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c,
|
| + 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06,
|
| + 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x4d, 0x6f, 0x75, 0x6e, 0x74, 0x61,
|
| + 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77, 0x31, 0x13, 0x30, 0x11, 0x06,
|
| + 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
| + 0x20, 0x49, 0x6e, 0x63, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x04,
|
| + 0x0b, 0x0c, 0x04, 0x43, 0x61, 0x73, 0x74, 0x31, 0x24, 0x30, 0x22, 0x06,
|
| + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1b, 0x43, 0x61, 0x73, 0x74, 0x20, 0x54,
|
| + 0x65, 0x73, 0x74, 0x20, 0x55, 0x6e, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65,
|
| + 0x64, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01,
|
| + 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
|
| + 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01,
|
| + 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc1, 0xe4, 0x4c, 0x2e, 0xe0, 0xac,
|
| + 0x5c, 0xda, 0xe1, 0xb7, 0xe0, 0xfe, 0xf5, 0x19, 0x2a, 0x6b, 0xeb, 0xb5,
|
| + 0x8d, 0x9c, 0xdd, 0xf6, 0xd9, 0x5f, 0x84, 0x64, 0xf8, 0xa9, 0x4b, 0x07,
|
| + 0x55, 0x78, 0x73, 0xf7, 0x14, 0x38, 0x38, 0x94, 0x13, 0x70, 0xd9, 0x87,
|
| + 0x23, 0xd4, 0x91, 0xc2, 0x93, 0xd1, 0x3f, 0x86, 0xad, 0xa7, 0xf6, 0x39,
|
| + 0xe9, 0x78, 0xc0, 0xb8, 0x3e, 0x32, 0x40, 0xec, 0x83, 0x4c, 0xa2, 0x47,
|
| + 0x96, 0x75, 0xaf, 0xfc, 0x1d, 0x35, 0x1b, 0x00, 0xda, 0x9a, 0xa5, 0x6c,
|
| + 0xcd, 0x1b, 0x04, 0x0a, 0xe6, 0xbd, 0xa9, 0xe4, 0x5d, 0x67, 0x71, 0x7d,
|
| + 0x60, 0xc8, 0xe1, 0x59, 0x27, 0xc3, 0xf1, 0x87, 0x85, 0x69, 0xb1, 0xe8,
|
| + 0xe4, 0x39, 0x92, 0x84, 0xdb, 0xdf, 0x96, 0x71, 0xb8, 0x5b, 0xa9, 0xef,
|
| + 0xb3, 0xde, 0xd4, 0xa6, 0xc6, 0x4c, 0xcb, 0x4b, 0x02, 0xd9, 0x84, 0xd1,
|
| + 0x47, 0x1a, 0x45, 0xd8, 0x5d, 0x9f, 0xae, 0x09, 0x69, 0x39, 0x1c, 0x4a,
|
| + 0xd1, 0xf0, 0x9a, 0x88, 0x59, 0x54, 0x44, 0x8e, 0x58, 0x96, 0x58, 0x24,
|
| + 0x0c, 0xd5, 0x9a, 0xbc, 0x7b, 0x81, 0x2c, 0x2c, 0x55, 0x52, 0xac, 0x06,
|
| + 0x37, 0x7d, 0x52, 0x89, 0x58, 0x19, 0xcd, 0xfe, 0xf5, 0x55, 0x17, 0x57,
|
| + 0xe3, 0xc2, 0x47, 0xc3, 0xbe, 0x61, 0x59, 0x9f, 0x86, 0xfc, 0x51, 0x20,
|
| + 0x11, 0x13, 0xad, 0x62, 0xd1, 0x3b, 0xb4, 0x55, 0x83, 0x5e, 0x3d, 0x26,
|
| + 0xd0, 0xc8, 0x0d, 0x36, 0x2e, 0x6b, 0x86, 0xaf, 0x6c, 0xcc, 0x5d, 0x99,
|
| + 0x8f, 0x93, 0x18, 0x47, 0xdf, 0xf9, 0x29, 0xcd, 0x6b, 0xc6, 0x5d, 0x3f,
|
| + 0x01, 0x15, 0xb5, 0x06, 0x0d, 0xf4, 0xce, 0x4a, 0x21, 0xaa, 0x36, 0x4f,
|
| + 0x45, 0xa0, 0xca, 0xb1, 0x94, 0x78, 0x49, 0xb7, 0x3a, 0xc9, 0x23, 0x01,
|
| + 0x58, 0x87, 0x10, 0x85, 0x4f, 0x6e, 0xba, 0x90, 0x40, 0xef, 0x02, 0x03,
|
| + 0x01, 0x00, 0x01, 0xa3, 0x60, 0x30, 0x5e, 0x30, 0x0f, 0x06, 0x03, 0x55,
|
| + 0x1d, 0x13, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x02,
|
| + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xcc,
|
| + 0xc4, 0xce, 0x8e, 0xd4, 0x73, 0x22, 0x4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
| + 0x91, 0x64, 0x52, 0xb4, 0x56, 0x7d, 0xe2, 0x73, 0x3b, 0x65, 0x9e, 0x0e,
|
| + 0xc0, 0x8c, 0x2c, 0x44, 0xf3, 0x12, 0xb5, 0x1c, 0x4e, 0x41, 0x80, 0x3f,
|
| + 0xa2, 0x17, 0xc6, 0xf2, 0x53, 0xe6, 0x48, 0x94, 0x5d, 0xae, 0xb9, 0x7c,
|
| + 0x72, 0x4f, 0x7f, 0x77, 0x43, 0x37, 0xf8, 0xdc, 0x05, 0x8d, 0xac, 0x0b,
|
| + 0x7d, 0x61, 0x7d, 0x7d, 0xfc, 0x59, 0x6f, 0x04, 0x52, 0x35, 0xb0, 0xdc,
|
| + 0xea, 0xad, 0xce, 0xfe, 0x15, 0x36, 0x0a, 0x2e, 0x79, 0x0e, 0xb7, 0xa1,
|
| + 0x93, 0x61, 0x34, 0x9a, 0x47, 0x0d, 0xc1, 0x6b, 0xb6, 0xae, 0xd2, 0x9b,
|
| + 0x01, 0xf3, 0x6b, 0xff, 0x5b, 0xd4, 0xf9, 0x03, 0x5e, 0x81, 0x1a, 0xe7,
|
| + 0x90, 0x28, 0xe8, 0xe5, 0x7d, 0x76, 0x15, 0xc2, 0x73, 0x46, 0xa3, 0xc2,
|
| + 0xbd, 0x41, 0x51, 0xfe, 0x57, 0xef, 0x58, 0x6e, 0xb1, 0x94, 0x82, 0xea,
|
| + 0xc0, 0xf1, 0x9a, 0x6f, 0xf8, 0x31, 0x00, 0xc3, 0xce, 0x22, 0x4f, 0x28,
|
| + 0x5b, 0xa1, 0xe2, 0x17, 0xb5, 0x1c, 0xba, 0xd8, 0xde, 0x73, 0xec, 0xa2,
|
| + 0x3d, 0xcc, 0x12, 0xfe, 0xf5, 0xae, 0xc9, 0xfa, 0xa7, 0x4e, 0xe3, 0x0b,
|
| + 0x4e, 0x24, 0x18, 0xa7, 0xf0};
|
| +
|
| +// Indicates the expected result of CRL verification
|
| +enum TestResultCRL {
|
| + RESULT_CRL_INVALID,
|
| + RESULT_CRL_VALID,
|
| +};
|
| +
|
| +// Indicates the expected result of test verification
|
| +enum TestResultCert {
|
| + RESULT_CERT_INVALID,
|
| + RESULT_CERT_VALID,
|
| +};
|
| +
|
| +bool RunTest(const std::vector<std::string> certificate_chain,
|
| + const std::string& crl_bundle,
|
| + const base::Time::Exploded& time) {
|
| + ClearCRLTrustAnchorForTest();
|
| + EXPECT_TRUE(AddCRLTrustAnchorForTest(kCastCRLTestRootCaDer,
|
| + sizeof(kCastCRLTestRootCaDer)));
|
| + EXPECT_TRUE(
|
| + AddTrustAnchorForTest(kCastTestRootCaDer, sizeof(kCastTestRootCaDer)));
|
| +
|
| + std::unique_ptr<CastCRL> crl = ParseCRL(crl_bundle, time);
|
| + if (!crl_bundle.empty() && crl.get() == nullptr)
|
| + return false;
|
| +
|
| + std::unique_ptr<CertVerificationContext> context;
|
| + CastDeviceCertPolicy policy;
|
| + return VerifyDeviceCert(certificate_chain, time, &context, &policy, crl.get(),
|
| + {});
|
| +}
|
| +
|
| +void RunTestSuite(const std::string& test_suite_file_name) {
|
| + std::string testsuite_raw =
|
| + cast_certificate::testing::ReadFromFile(test_suite_file_name);
|
| + DeviceCertTestSuite test_suite;
|
| + ASSERT_TRUE(test_suite.ParseFromString(testsuite_raw));
|
| + uint16_t success = 0;
|
| + uint16_t failed = 0;
|
| + std::vector<std::string> failed_tests;
|
| + for (auto const& test_case : test_suite.tests()) {
|
| + LOG(INFO) << "[ RUN ] " << test_case.description();
|
| + bool expected_result = test_case.path_is_valid();
|
| + std::vector<std::string> certificate_chain;
|
| + for (auto const& cert : test_case.der_cert_path()) {
|
| + certificate_chain.push_back(cert);
|
| + }
|
| + uint64_t verification_time_millis = test_case.verification_time_millis();
|
| + base::Time verification_time =
|
| + base::Time::UnixEpoch() +
|
| + base::TimeDelta::FromMilliseconds(verification_time_millis);
|
| + base::Time::Exploded exploded_time;
|
| + verification_time.UTCExplode(&exploded_time);
|
| + std::string crl_bundle = test_case.crl_bundle();
|
| + bool result = RunTest(certificate_chain, crl_bundle, exploded_time);
|
| + if (expected_result != result) {
|
| + LOG(INFO) << "[ FAILED ] " << test_case.description();
|
| + ++failed;
|
| + failed_tests.push_back(test_case.description());
|
| + } else {
|
| + LOG(INFO) << "[ PASSED ] " << test_case.description();
|
| + ++success;
|
| + }
|
| + EXPECT_EQ(expected_result, result);
|
| + }
|
| + LOG(INFO) << "[ PASSED ] " << success << " test(s).";
|
| + if (failed) {
|
| + LOG(INFO) << "[ FAILED ] " << failed << " test(s), listed below:";
|
| + for (const auto& failed_test : failed_tests) {
|
| + LOG(INFO) << "[ FAILED ] " << failed_test;
|
| + }
|
| + }
|
| +}
|
| +
|
| +TEST(CastCertificateTest, TestSuite1) {
|
| + RunTestSuite("testsuite/testsuite1.pb");
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +} // namespace cast_certificate
|
|
|