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: net/cert/internal/extended_key_usage_unittest.cc

Issue 1664243002: Using == instead of Equals for der::Input comparison. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing comment. Created 4 years, 10 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
« no previous file with comments | « net/cert/internal/certificate_policies.cc ('k') | net/cert/internal/signature_algorithm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "net/cert/internal/extended_key_usage.h" 8 #include "net/cert/internal/extended_key_usage.h"
9 #include "net/der/input.h" 9 #include "net/der/input.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 namespace { 14 namespace {
15 15
16 // Helper method to check if an EKU is present in a std::vector of EKUs. 16 // Helper method to check if an EKU is present in a std::vector of EKUs.
17 bool HasEKU(const std::vector<der::Input>& list, const der::Input& eku) { 17 bool HasEKU(const std::vector<der::Input>& list, const der::Input& eku) {
18 for (const auto& oid : list) { 18 for (const auto& oid : list) {
19 if (oid.Equals(eku)) 19 if (oid == eku)
20 return true; 20 return true;
21 } 21 }
22 return false; 22 return false;
23 } 23 }
24 24
25 // Check that we can read multiple EKUs from an extension. 25 // Check that we can read multiple EKUs from an extension.
26 TEST(ExtendedKeyUsageTest, ParseEKUExtension) { 26 TEST(ExtendedKeyUsageTest, ParseEKUExtension) {
27 // clang-format off 27 // clang-format off
28 const uint8_t raw_extension_value[] = { 28 const uint8_t raw_extension_value[] = {
29 0x30, 0x14, // SEQUENCE (20 bytes) 29 0x30, 0x14, // SEQUENCE (20 bytes)
(...skipping 25 matching lines...) Expand all
55 0x06, 0x08, // OBJECT IDENTIFIER (8 bytes) 55 0x06, 0x08, // OBJECT IDENTIFIER (8 bytes)
56 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01 // 1.3.6.1.5.5.7.3.1 56 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01 // 1.3.6.1.5.5.7.3.1
57 }; 57 };
58 // clang-format on 58 // clang-format on
59 der::Input extension(extension_bytes); 59 der::Input extension(extension_bytes);
60 60
61 std::vector<der::Input> ekus; 61 std::vector<der::Input> ekus;
62 EXPECT_TRUE(ParseEKUExtension(extension, &ekus)); 62 EXPECT_TRUE(ParseEKUExtension(extension, &ekus));
63 EXPECT_EQ(2u, ekus.size()); 63 EXPECT_EQ(2u, ekus.size());
64 for (const auto& eku : ekus) { 64 for (const auto& eku : ekus) {
65 EXPECT_TRUE(eku.Equals(ServerAuth())); 65 EXPECT_EQ(ServerAuth(), eku);
66 } 66 }
67 } 67 }
68 68
69 // Check that parsing an EKU extension which contains a private OID doesn't 69 // Check that parsing an EKU extension which contains a private OID doesn't
70 // cause an error. 70 // cause an error.
71 TEST(ExtendedKeyUsageTest, ParseEKUExtensionGracefullyHandlesPrivateOids) { 71 TEST(ExtendedKeyUsageTest, ParseEKUExtensionGracefullyHandlesPrivateOids) {
72 // clang-format off 72 // clang-format off
73 const uint8_t extension_bytes[] = { 73 const uint8_t extension_bytes[] = {
74 0x30, 0x13, // SEQUENCE (19 bytes) 74 0x30, 0x13, // SEQUENCE (19 bytes)
75 0x06, 0x08, // OBJECT IDENTIFIER (8 bytes) 75 0x06, 0x08, // OBJECT IDENTIFIER (8 bytes)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 // The extension value must not be empty. 159 // The extension value must not be empty.
160 TEST(ExtendedKeyUsageTest, EmptyExtension) { 160 TEST(ExtendedKeyUsageTest, EmptyExtension) {
161 std::vector<der::Input> ekus; 161 std::vector<der::Input> ekus;
162 EXPECT_FALSE(ParseEKUExtension(der::Input(), &ekus)); 162 EXPECT_FALSE(ParseEKUExtension(der::Input(), &ekus));
163 } 163 }
164 164
165 } // namespace 165 } // namespace
166 166
167 } // namespace net 167 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/certificate_policies.cc ('k') | net/cert/internal/signature_algorithm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698