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

Side by Side Diff: net/http/http_mac_signature_unittest.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "net/http/http_mac_signature.h" 6 #include "net/http/http_mac_signature.h"
7 7
8 namespace net { 8 namespace net {
9 9
10 TEST(HttpMacSignatureTest, BogusAddStateInfo) { 10 TEST(HttpMacSignatureTest, BogusAddStateInfo) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 "eXaMple.com", 52 "eXaMple.com",
53 80)); 53 80));
54 54
55 std::string age = "239034"; 55 std::string age = "239034";
56 std::string nonce = "mn4302j0n+32r2/f3r="; 56 std::string nonce = "mn4302j0n+32r2/f3r=";
57 57
58 std::string header_string; 58 std::string header_string;
59 EXPECT_TRUE(signature.GenerateHeaderString(age, nonce, &header_string)); 59 EXPECT_TRUE(signature.GenerateHeaderString(age, nonce, &header_string));
60 EXPECT_EQ("MAC id=\"dfoi30j0qnf\", " 60 EXPECT_EQ("MAC id=\"dfoi30j0qnf\", "
61 "nonce=\"239034:mn4302j0n+32r2/f3r=\", " 61 "nonce=\"239034:mn4302j0n+32r2/f3r=\", "
62 "mac=\"GrkHtPKzB1m1dCHfa7OCWOw6EQ==\"", 62 "mac=\"GrkHtPKzB1m1dCHfa7OCWOw6Ecw=\"",
63 header_string); 63 header_string);
64 } 64 }
65 65
66 66
67 TEST(HttpMacSignatureTest, GenerateNormalizedRequest) { 67 TEST(HttpMacSignatureTest, GenerateNormalizedRequest) {
68 HttpMacSignature signature; 68 HttpMacSignature signature;
69 EXPECT_TRUE(signature.AddStateInfo("dfoi30j0qnf", 69 EXPECT_TRUE(signature.AddStateInfo("dfoi30j0qnf",
70 base::Time::Now(), 70 base::Time::Now(),
71 "adiMf03j0f3nOenc003r", 71 "adiMf03j0f3nOenc003r",
72 "hmac-sha-1")); 72 "hmac-sha-1"));
(...skipping 24 matching lines...) Expand all
97 EXPECT_TRUE(signature.AddHttpInfo("GeT", 97 EXPECT_TRUE(signature.AddHttpInfo("GeT",
98 "/pAth?to=%22enlightenment%22&dest=magic", 98 "/pAth?to=%22enlightenment%22&dest=magic",
99 "eXaMple.com", 99 "eXaMple.com",
100 80)); 100 80));
101 101
102 std::string age = "239034"; 102 std::string age = "239034";
103 std::string nonce = "mn4302j0n+32r2/f3r="; 103 std::string nonce = "mn4302j0n+32r2/f3r=";
104 104
105 std::string mac; 105 std::string mac;
106 EXPECT_TRUE(signature.GenerateMAC(age, nonce, &mac)); 106 EXPECT_TRUE(signature.GenerateMAC(age, nonce, &mac));
107 EXPECT_EQ("GrkHtPKzB1m1dCHfa7OCWOw6EQ==", mac); 107 EXPECT_EQ("GrkHtPKzB1m1dCHfa7OCWOw6Ecw=", mac);
108 } 108 }
109 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698