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

Side by Side Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 448143008: Move StringToUpperASCII and LowerCaseEqualsASCII to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « content/child/web_url_loader_impl.cc ('k') | content/common/android/address_parser.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if (!dict.get() || dict->empty()) 662 if (!dict.get() || dict->empty())
663 return ::testing::AssertionFailure() << "JSON parsing failed"; 663 return ::testing::AssertionFailure() << "JSON parsing failed";
664 664
665 // ---- k 665 // ---- k
666 std::string value_string; 666 std::string value_string;
667 if (!dict->GetString("k", &value_string)) 667 if (!dict->GetString("k", &value_string))
668 return ::testing::AssertionFailure() << "Missing 'k'"; 668 return ::testing::AssertionFailure() << "Missing 'k'";
669 std::string k_value; 669 std::string k_value;
670 if (!webcrypto::Base64DecodeUrlSafe(value_string, &k_value)) 670 if (!webcrypto::Base64DecodeUrlSafe(value_string, &k_value))
671 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(k) failed"; 671 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(k) failed";
672 if (!LowerCaseEqualsASCII(base::HexEncode(k_value.data(), k_value.size()), 672 if (!base::LowerCaseEqualsASCII(
673 k_expected_hex.c_str())) { 673 base::HexEncode(k_value.data(), k_value.size()),
674 k_expected_hex.c_str())) {
674 return ::testing::AssertionFailure() << "Expected 'k' to be " 675 return ::testing::AssertionFailure() << "Expected 'k' to be "
675 << k_expected_hex 676 << k_expected_hex
676 << " but found something different"; 677 << " but found something different";
677 } 678 }
678 679
679 return VerifyJwk(dict, "oct", alg_expected, use_mask_expected); 680 return VerifyJwk(dict, "oct", alg_expected, use_mask_expected);
680 } 681 }
681 682
682 // Verifies that the JSON in the input vector contains the provided 683 // Verifies that the JSON in the input vector contains the provided
683 // expected values. Exact matches are required on the fields examined. 684 // expected values. Exact matches are required on the fields examined.
(...skipping 19 matching lines...) Expand all
703 "value"; 704 "value";
704 } 705 }
705 // TODO(padolph): LowerCaseEqualsASCII() does not work for above! 706 // TODO(padolph): LowerCaseEqualsASCII() does not work for above!
706 707
707 // ---- e 708 // ---- e
708 if (!dict->GetString("e", &value_string)) 709 if (!dict->GetString("e", &value_string))
709 return ::testing::AssertionFailure() << "Missing 'e'"; 710 return ::testing::AssertionFailure() << "Missing 'e'";
710 std::string e_value; 711 std::string e_value;
711 if (!webcrypto::Base64DecodeUrlSafe(value_string, &e_value)) 712 if (!webcrypto::Base64DecodeUrlSafe(value_string, &e_value))
712 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(e) failed"; 713 return ::testing::AssertionFailure() << "Base64DecodeUrlSafe(e) failed";
713 if (!LowerCaseEqualsASCII(base::HexEncode(e_value.data(), e_value.size()), 714 if (!base::LowerCaseEqualsASCII(
714 e_expected_hex.c_str())) { 715 base::HexEncode(e_value.data(), e_value.size()),
716 e_expected_hex.c_str())) {
715 return ::testing::AssertionFailure() << "Expected 'e' to be " 717 return ::testing::AssertionFailure() << "Expected 'e' to be "
716 << e_expected_hex 718 << e_expected_hex
717 << " but found something different"; 719 << " but found something different";
718 } 720 }
719 721
720 return VerifyJwk(dict, "RSA", alg_expected, use_mask_expected); 722 return VerifyJwk(dict, "RSA", alg_expected, use_mask_expected);
721 } 723 }
722 724
723 } // namespace 725 } // namespace
724 726
(...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after
4473 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); 4475 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki);
4474 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); 4476 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8);
4475 4477
4476 EXPECT_NE(public_key_spki, wrapped_public_key); 4478 EXPECT_NE(public_key_spki, wrapped_public_key);
4477 EXPECT_NE(private_key_pkcs8, wrapped_private_key); 4479 EXPECT_NE(private_key_pkcs8, wrapped_private_key);
4478 } 4480 }
4479 4481
4480 } // namespace webcrypto 4482 } // namespace webcrypto
4481 4483
4482 } // namespace content 4484 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_url_loader_impl.cc ('k') | content/common/android/address_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698