| OLD | NEW |
| 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/protocol/jingle_messages.h" | 5 #include "remoting/protocol/jingle_messages.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 JingleMessage message; | 335 JingleMessage message; |
| 336 ParseJingleMessageFromXml(kTestSessionAcceptMessage, &message); | 336 ParseJingleMessageFromXml(kTestSessionAcceptMessage, &message); |
| 337 | 337 |
| 338 EXPECT_EQ(message.action, JingleMessage::SESSION_ACCEPT); | 338 EXPECT_EQ(message.action, JingleMessage::SESSION_ACCEPT); |
| 339 EXPECT_FALSE(message.description->config()->ice_supported()); | 339 EXPECT_FALSE(message.description->config()->ice_supported()); |
| 340 EXPECT_FALSE(message.description->config()->webrtc_supported()); | 340 EXPECT_FALSE(message.description->config()->webrtc_supported()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 TEST(JingleMessageTest, IceTransportInfo) { | 343 TEST(JingleMessageTest, IceTransportInfo) { |
| 344 const char* kTestIceTransportInfoMessage = | 344 const char* kTestIceTransportInfoMessage = |
| 345 "<cli:iq to='user@gmail.com/chromoting016DBB07' type='set' " | 345 "<cli:iq to='user@gmail.com/chromoting016DBB07' " |
| 346 "xmlns:cli='jabber:client'>" | 346 " from='foo@bar.com/resource' " |
| 347 "<jingle xmlns='urn:xmpp:jingle:1' action='transport-info' " | 347 " type='set' xmlns:cli='jabber:client'>" |
| 348 "sid='2227053353'>" | 348 " <jingle xmlns='urn:xmpp:jingle:1' action='transport-info' " |
| 349 "<content name='chromoting' creator='initiator'>" | 349 " sid='2227053353'>" |
| 350 "<transport xmlns='google:remoting:ice'>" | 350 " <content name='chromoting' creator='initiator'>" |
| 351 "<credentials channel='event' ufrag='tPUyEAmQrEw3y7hi' " | 351 " <transport xmlns='google:remoting:ice'>" |
| 352 "password='2iRdhLfawKZC5ydJ'/>" | 352 " <credentials channel='event' ufrag='tPUyEAmQrEw3y7hi' " |
| 353 "<credentials channel='video' ufrag='EPK3CXo5sTLJSez0' " | 353 " password='2iRdhLfawKZC5ydJ'/>" |
| 354 "password='eM0VUfUkZ+1Pyi0M'/>" | 354 " <credentials channel='video' ufrag='EPK3CXo5sTLJSez0' " |
| 355 "<candidate name='event' foundation='725747215' " | 355 " password='eM0VUfUkZ+1Pyi0M'/>" |
| 356 "address='172.23.164.186' port='59089' type='local' " | 356 " <candidate name='event' foundation='725747215' " |
| 357 "protocol='udp' priority='2122194688' generation='0'/>" | 357 " address='172.23.164.186' port='59089' type='local' " |
| 358 "<candidate name='video' foundation='3623806809' " | 358 " protocol='udp' priority='2122194688' generation='0'/>" |
| 359 "address='172.23.164.186' port='57040' type='local' " | 359 " <candidate name='video' foundation='3623806809' " |
| 360 "protocol='udp' priority='2122194688' generation='0'/>" | 360 " address='172.23.164.186' port='57040' type='local' " |
| 361 "</transport>" | 361 " protocol='udp' priority='2122194688' generation='0'/>" |
| 362 "</content>" | 362 " </transport>" |
| 363 "</jingle>" | 363 " </content>" |
| 364 " </jingle>" |
| 364 "</cli:iq>"; | 365 "</cli:iq>"; |
| 365 | 366 |
| 366 JingleMessage message; | 367 JingleMessage message; |
| 367 ParseFormatAndCompare(kTestIceTransportInfoMessage, &message); | 368 ParseFormatAndCompare(kTestIceTransportInfoMessage, &message); |
| 368 | 369 |
| 369 EXPECT_EQ(message.action, JingleMessage::TRANSPORT_INFO); | 370 EXPECT_EQ(message.action, JingleMessage::TRANSPORT_INFO); |
| 370 | 371 |
| 371 IceTransportInfo transport_info; | 372 IceTransportInfo transport_info; |
| 372 EXPECT_TRUE(transport_info.ParseXml(message.transport_info.get())); | 373 EXPECT_TRUE(transport_info.ParseXml(message.transport_info.get())); |
| 373 EXPECT_EQ(transport_info.ice_credentials.size(), 2U); | 374 EXPECT_EQ(transport_info.ice_credentials.size(), 2U); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 397 | 398 |
| 398 JingleMessage message; | 399 JingleMessage message; |
| 399 ParseFormatAndCompare(kTestSessionInfoMessage, &message); | 400 ParseFormatAndCompare(kTestSessionInfoMessage, &message); |
| 400 | 401 |
| 401 EXPECT_EQ(message.action, JingleMessage::SESSION_INFO); | 402 EXPECT_EQ(message.action, JingleMessage::SESSION_INFO); |
| 402 ASSERT_TRUE(message.info.get() != nullptr); | 403 ASSERT_TRUE(message.info.get() != nullptr); |
| 403 EXPECT_TRUE(message.info->Name() == | 404 EXPECT_TRUE(message.info->Name() == |
| 404 buzz::QName("urn:xmpp:jingle:1", "test-info")); | 405 buzz::QName("urn:xmpp:jingle:1", "test-info")); |
| 405 } | 406 } |
| 406 | 407 |
| 407 TEST(JingleMessageTest, ParseAddress) { | |
| 408 const char* kTestSessionInfoMessage = | |
| 409 "<cli:iq from='remoting@bot.talk.google.com' " | |
| 410 "to='user@gmail.com/chromiumsy5C6A652D' type='set' " | |
| 411 "xmlns:cli='jabber:client'>" | |
| 412 "<jingle action='session-info' " | |
| 413 "sid='2227053353' xmlns='urn:xmpp:jingle:1' " | |
| 414 "from-channel='lcs' " | |
| 415 "from-endpoint-id='user@gmail.com/xBrnereror='>" | |
| 416 "<test-info>TestMessage</test-info>" | |
| 417 "</jingle>" | |
| 418 "</cli:iq>"; | |
| 419 | |
| 420 JingleMessage message; | |
| 421 ParseFormatAndCompare(kTestSessionInfoMessage, &message); | |
| 422 EXPECT_EQ(message.from.jid(), "remoting@bot.talk.google.com"); | |
| 423 EXPECT_EQ(message.from.channel(), SignalingAddress::Channel::LCS); | |
| 424 EXPECT_EQ(message.from.endpoint_id(), "user@gmail.com/xBrnereror="); | |
| 425 EXPECT_EQ(message.from.id(), "user@gmail.com/xBrnereror="); | |
| 426 | |
| 427 EXPECT_EQ(message.to.jid(), "user@gmail.com/chromiumsy5C6A652D"); | |
| 428 EXPECT_EQ(message.to.channel(), SignalingAddress::Channel::XMPP); | |
| 429 EXPECT_EQ(message.to.endpoint_id(), ""); | |
| 430 EXPECT_EQ(message.to.id(), "user@gmail.com/chromiumsy5C6A652D"); | |
| 431 | |
| 432 EXPECT_EQ(message.action, JingleMessage::SESSION_INFO); | |
| 433 } | |
| 434 | |
| 435 | |
| 436 TEST(JingleMessageTest, IgnoreInvalidAddress) { | 408 TEST(JingleMessageTest, IgnoreInvalidAddress) { |
| 437 const char* kInvalidFromField = | 409 const char* kInvalidFromField = |
| 438 "<cli:iq from='evil@gmail.com' " | 410 "<cli:iq from='evil@gmail.com' " |
| 439 "to='victim@gmail.com/chromiumsy5C6A652D' type='set' " | 411 "to='victim@gmail.com/chromiumsy5C6A652D' type='set' " |
| 440 "xmlns:cli='jabber:client'>" | 412 "xmlns:cli='jabber:client'>" |
| 441 "<jingle action='session-info' " | 413 "<jingle action='session-info' " |
| 442 "sid='2227053353' xmlns='urn:xmpp:jingle:1' " | 414 "sid='2227053353' xmlns='urn:xmpp:jingle:1' " |
| 443 "from-channel='lcs' " | 415 "from-channel='lcs' " |
| 444 "from-endpoint-id='victim@gmail.com/evilAddress'>" | 416 "from-endpoint-id='victim@gmail.com/evilAddress'>" |
| 445 "<test-info>TestMessage</test-info>" | 417 "<test-info>TestMessage</test-info>" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 expected.AddElement(new XmlElement(QName("google:remoting", "sometag"))); | 656 expected.AddElement(new XmlElement(QName("google:remoting", "sometag"))); |
| 685 expected.FirstElement()->SetBodyText("some-message"); | 657 expected.FirstElement()->SetBodyText("some-message"); |
| 686 std::string error; | 658 std::string error; |
| 687 EXPECT_TRUE(VerifyXml(&expected, message.attachments.get(), &error)) | 659 EXPECT_TRUE(VerifyXml(&expected, message.attachments.get(), &error)) |
| 688 << error; | 660 << error; |
| 689 } | 661 } |
| 690 } | 662 } |
| 691 | 663 |
| 692 } // namespace protocol | 664 } // namespace protocol |
| 693 } // namespace remoting | 665 } // namespace remoting |
| OLD | NEW |