|
OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "testing/gtest/include/gtest/gtest.h" | |
6 #include "net/http/http_mac_signature.h" | |
7 | |
8 namespace net { | |
9 | |
10 TEST(HttpMacSignatureTest, BogusAddStateInfo) { | |
cbentzel
2011/04/29 14:44:49
Add other tests, such as empty string.
abarth-chromium
2011/04/29 18:16:01
Done.
| |
11 HttpMacSignature signature; | |
12 EXPECT_FALSE(signature.AddStateInfo("exciting-id", | |
13 "the-mac-key", | |
14 "bogus-mac-algorithm", | |
15 "the-issuer")); | |
16 } | |
17 | |
18 TEST(HttpMacSignatureTest, BogusAddHttpInfo) { | |
19 HttpMacSignature signature; | |
20 EXPECT_FALSE(signature.AddHttpInfo("GET", | |
21 "/requested", | |
22 "example.com", | |
23 0)); | |
24 } | |
25 | |
26 TEST(HttpMacSignatureTest, GenerateNormalizedRequest) { | |
27 HttpMacSignature signature; | |
28 EXPECT_TRUE(signature.AddStateInfo("dfoi30j0qnf", | |
29 "adiMf03j0f3nOenc003r", | |
30 "hmac-sha-1", | |
31 "login.eXampLe.com:443")); | |
32 EXPECT_TRUE(signature.AddHttpInfo("GeT", | |
33 "/pAth?to=%22enlightenment%22&dest=magic", | |
cbentzel
2011/04/29 14:44:49
Nit: line these up
abarth-chromium
2011/04/29 18:16:01
Done.
| |
34 "eXaMple.com", | |
35 80)); | |
36 | |
37 std::string timestame = "239034"; | |
cbentzel
2011/04/29 14:44:49
timestamp, not timestame
abarth-chromium
2011/04/29 18:16:01
Done.
| |
38 std::string nonce = "mn4302j0n+32r2/f3r="; | |
39 | |
40 EXPECT_EQ("dfoi30j0qnf\n" | |
41 "login.eXampLe.com:443\n" | |
42 "239034\n" | |
43 "mn4302j0n+32r2/f3r=\n" | |
44 "GET\n" | |
45 "/pAth?to=%22enlightenment%22&dest=magic\n" | |
46 "example.com\n" | |
47 "80\n", | |
48 signature.GenerateNormalizedRequest(timestame, nonce)); | |
49 } | |
50 | |
51 TEST(HttpMacSignatureTest, GenerateMAC) { | |
52 HttpMacSignature signature; | |
53 EXPECT_TRUE(signature.AddStateInfo("dfoi30j0qnf", | |
54 "adiMf03j0f3nOenc003r", | |
55 "hmac-sha-1", | |
56 "login.eXampLe.com:443")); | |
57 EXPECT_TRUE(signature.AddHttpInfo("GeT", | |
58 "/pAth?to=%22enlightenment%22&dest=magic", | |
59 "eXaMple.com", | |
60 80)); | |
61 | |
62 std::string timestame = "239034"; | |
63 std::string nonce = "mn4302j0n+32r2/f3r="; | |
64 | |
65 EXPECT_EQ("zQWLNI5eHOfY5/wCJ6yzZ8bXDw==", | |
66 signature.GenerateMAC(timestame, nonce)); | |
67 } | |
cbentzel
2011/04/29 14:44:49
Add a test for GenerateAuthorizationHeader. You'd
abarth-chromium
2011/04/29 18:16:01
Yeah, that's why I did things this way. I can spl
| |
68 } | |
OLD | NEW |