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

Side by Side Diff: remoting/host/register_support_host_request_unittest.cc

Issue 1131653002: Use lower-case JIDs when generating signatures for messages sent to CRD bot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « remoting/host/register_support_host_request.cc ('k') | remoting/remoting_srcs.gypi » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/register_support_host_request.h" 5 #include "remoting/host/register_support_host_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
(...skipping 15 matching lines...) Expand all
26 using testing::_; 26 using testing::_;
27 using testing::Invoke; 27 using testing::Invoke;
28 using testing::NotNull; 28 using testing::NotNull;
29 using testing::Return; 29 using testing::Return;
30 using testing::SaveArg; 30 using testing::SaveArg;
31 31
32 namespace remoting { 32 namespace remoting {
33 33
34 namespace { 34 namespace {
35 const char kTestBotJid[] = "remotingunittest@bot.talk.google.com"; 35 const char kTestBotJid[] = "remotingunittest@bot.talk.google.com";
36 const char kTestJid[] = "user@gmail.com/chromoting123"; 36 const char kTestJid[] = "User@gmail.com/chromotingABC123";
37 const char kTestJidNormalized[] = "user@gmail.com/chromotingABC123";
37 const char kSupportId[] = "AB4RF3"; 38 const char kSupportId[] = "AB4RF3";
38 const char kSupportIdLifetime[] = "300"; 39 const char kSupportIdLifetime[] = "300";
39 const char kStanzaId[] = "123"; 40 const char kStanzaId[] = "123";
40 41
41 ACTION_P(AddListener, list) { 42 ACTION_P(AddListener, list) {
42 list->AddObserver(arg0); 43 list->AddObserver(arg0);
43 } 44 }
44 ACTION_P(RemoveListener, list) { 45 ACTION_P(RemoveListener, list) {
45 list->RemoveObserver(arg0); 46 list->RemoveObserver(arg0);
46 } 47 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 int64 time; 116 int64 time;
116 EXPECT_TRUE(base::StringToInt64(time_str, &time)); 117 EXPECT_TRUE(base::StringToInt64(time_str, &time));
117 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT()); 118 int64 now = static_cast<int64>(base::Time::Now().ToDoubleT());
118 EXPECT_LE(start_time, time); 119 EXPECT_LE(start_time, time);
119 EXPECT_GE(now, time); 120 EXPECT_GE(now, time);
120 121
121 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair); 122 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(kTestRsaKeyPair);
122 ASSERT_TRUE(key_pair.get()); 123 ASSERT_TRUE(key_pair.get());
123 124
124 std::string expected_signature = 125 std::string expected_signature =
125 key_pair->SignMessage(std::string(kTestJid) + ' ' + time_str); 126 key_pair->SignMessage(std::string(kTestJidNormalized) + ' ' + time_str);
126 EXPECT_EQ(expected_signature, signature->BodyText()); 127 EXPECT_EQ(expected_signature, signature->BodyText());
127 128
128 // Generate response and verify that callback is called. 129 // Generate response and verify that callback is called.
129 EXPECT_CALL(callback_, OnResponse(true, kSupportId, 130 EXPECT_CALL(callback_, OnResponse(true, kSupportId,
130 base::TimeDelta::FromSeconds(300))); 131 base::TimeDelta::FromSeconds(300)));
131 132
132 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ)); 133 scoped_ptr<XmlElement> response(new XmlElement(buzz::QN_IQ));
133 response->AddAttr(QName(std::string(), "from"), kTestBotJid); 134 response->AddAttr(QName(std::string(), "from"), kTestBotJid);
134 response->AddAttr(QName(std::string(), "type"), "result"); 135 response->AddAttr(QName(std::string(), "type"), "result");
135 response->AddAttr(QName(std::string(), "id"), kStanzaId); 136 response->AddAttr(QName(std::string(), "id"), kStanzaId);
(...skipping 19 matching lines...) Expand all
155 while ((listener = it.GetNext()) != nullptr) { 156 while ((listener = it.GetNext()) != nullptr) {
156 if (listener->OnSignalStrategyIncomingStanza(response.get())) 157 if (listener->OnSignalStrategyIncomingStanza(response.get()))
157 consumed++; 158 consumed++;
158 } 159 }
159 EXPECT_EQ(1, consumed); 160 EXPECT_EQ(1, consumed);
160 161
161 base::RunLoop().RunUntilIdle(); 162 base::RunLoop().RunUntilIdle();
162 } 163 }
163 164
164 } // namespace remoting 165 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/register_support_host_request.cc ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698