OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |