| Index: webrtc/api/webrtcsession_unittest.cc
|
| diff --git a/webrtc/api/webrtcsession_unittest.cc b/webrtc/api/webrtcsession_unittest.cc
|
| index ee1d19b23adaee4cf899e28666b294dafc0aa127..940cf46ee84f0c3174b92455200a5fedca135c58 100644
|
| --- a/webrtc/api/webrtcsession_unittest.cc
|
| +++ b/webrtc/api/webrtcsession_unittest.cc
|
| @@ -455,6 +455,14 @@ class WebRtcSessionTest
|
| Init();
|
| }
|
|
|
| + void InitWithGcm() {
|
| + rtc::CryptoOptions crypto_options;
|
| + crypto_options.enable_gcm_crypto_suites = true;
|
| + channel_manager_->SetCryptoOptions(crypto_options);
|
| + with_gcm_ = true;
|
| + Init();
|
| + }
|
| +
|
| void SendAudioVideoStream1() {
|
| send_stream_1_ = true;
|
| send_stream_2_ = false;
|
| @@ -545,6 +553,10 @@ class WebRtcSessionTest
|
| if (session_->data_channel_type() == cricket::DCT_SCTP && data_channel_) {
|
| session_options->data_channel_type = cricket::DCT_SCTP;
|
| }
|
| +
|
| + if (with_gcm_) {
|
| + session_options->crypto_options.enable_gcm_crypto_suites = true;
|
| + }
|
| }
|
|
|
| void GetOptionsForAnswer(cricket::MediaSessionOptions* session_options) {
|
| @@ -560,6 +572,10 @@ class WebRtcSessionTest
|
| if (session_->data_channel_type() == cricket::DCT_SCTP) {
|
| session_options->data_channel_type = cricket::DCT_SCTP;
|
| }
|
| +
|
| + if (with_gcm_) {
|
| + session_options->crypto_options.enable_gcm_crypto_suites = true;
|
| + }
|
| }
|
|
|
| // Creates a local offer and applies it. Starts ICE.
|
| @@ -622,7 +638,8 @@ class WebRtcSessionTest
|
| session_->video_channel() != NULL);
|
| }
|
|
|
| - void VerifyCryptoParams(const cricket::SessionDescription* sdp) {
|
| + void VerifyCryptoParams(const cricket::SessionDescription* sdp,
|
| + bool gcm_enabled = false) {
|
| ASSERT_TRUE(session_.get() != NULL);
|
| const cricket::ContentInfo* content = cricket::GetFirstAudioContent(sdp);
|
| ASSERT_TRUE(content != NULL);
|
| @@ -630,12 +647,24 @@ class WebRtcSessionTest
|
| static_cast<const cricket::AudioContentDescription*>(
|
| content->description);
|
| ASSERT_TRUE(audio_content != NULL);
|
| - ASSERT_EQ(1U, audio_content->cryptos().size());
|
| - ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size());
|
| - ASSERT_EQ("AES_CM_128_HMAC_SHA1_80",
|
| - audio_content->cryptos()[0].cipher_suite);
|
| - EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
|
| - audio_content->protocol());
|
| + if (!gcm_enabled) {
|
| + ASSERT_EQ(1U, audio_content->cryptos().size());
|
| + ASSERT_EQ(47U, audio_content->cryptos()[0].key_params.size());
|
| + ASSERT_EQ("AES_CM_128_HMAC_SHA1_80",
|
| + audio_content->cryptos()[0].cipher_suite);
|
| + EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
|
| + audio_content->protocol());
|
| + } else {
|
| + // The offer contains 3 possible crypto suites, the answer 1.
|
| + EXPECT_LE(1U, audio_content->cryptos().size());
|
| + EXPECT_NE(2U, audio_content->cryptos().size());
|
| + EXPECT_GE(3U, audio_content->cryptos().size());
|
| + ASSERT_EQ(67U, audio_content->cryptos()[0].key_params.size());
|
| + ASSERT_EQ("AEAD_AES_256_GCM",
|
| + audio_content->cryptos()[0].cipher_suite);
|
| + EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
|
| + audio_content->protocol());
|
| + }
|
|
|
| content = cricket::GetFirstVideoContent(sdp);
|
| ASSERT_TRUE(content != NULL);
|
| @@ -643,12 +672,24 @@ class WebRtcSessionTest
|
| static_cast<const cricket::VideoContentDescription*>(
|
| content->description);
|
| ASSERT_TRUE(video_content != NULL);
|
| - ASSERT_EQ(1U, video_content->cryptos().size());
|
| - ASSERT_EQ("AES_CM_128_HMAC_SHA1_80",
|
| - video_content->cryptos()[0].cipher_suite);
|
| - ASSERT_EQ(47U, video_content->cryptos()[0].key_params.size());
|
| - EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
|
| - video_content->protocol());
|
| + if (!gcm_enabled) {
|
| + ASSERT_EQ(1U, video_content->cryptos().size());
|
| + ASSERT_EQ("AES_CM_128_HMAC_SHA1_80",
|
| + video_content->cryptos()[0].cipher_suite);
|
| + ASSERT_EQ(47U, video_content->cryptos()[0].key_params.size());
|
| + EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
|
| + video_content->protocol());
|
| + } else {
|
| + // The offer contains 3 possible crypto suites, the answer 1.
|
| + EXPECT_LE(1U, video_content->cryptos().size());
|
| + EXPECT_NE(2U, video_content->cryptos().size());
|
| + EXPECT_GE(3U, video_content->cryptos().size());
|
| + ASSERT_EQ("AEAD_AES_256_GCM",
|
| + video_content->cryptos()[0].cipher_suite);
|
| + ASSERT_EQ(67U, video_content->cryptos()[0].key_params.size());
|
| + EXPECT_EQ(std::string(cricket::kMediaProtocolSavpf),
|
| + video_content->protocol());
|
| + }
|
| }
|
|
|
| void VerifyNoCryptoParams(const cricket::SessionDescription* sdp, bool dtls) {
|
| @@ -1464,6 +1505,7 @@ class WebRtcSessionTest
|
| std::string last_data_channel_label_;
|
| InternalDataChannelInit last_data_channel_config_;
|
| bool session_destroyed_ = false;
|
| + bool with_gcm_ = false;
|
| };
|
|
|
| TEST_P(WebRtcSessionTest, TestInitializeWithDtls) {
|
| @@ -2762,6 +2804,16 @@ TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDP) {
|
| VerifyCryptoParams(answer->description());
|
| }
|
|
|
| +TEST_F(WebRtcSessionTest, VerifyCryptoParamsInSDPGcm) {
|
| + InitWithGcm();
|
| + SendAudioVideoStream1();
|
| + std::unique_ptr<SessionDescriptionInterface> offer(CreateOffer());
|
| + VerifyCryptoParams(offer->description(), true);
|
| + SetRemoteDescriptionWithoutError(offer.release());
|
| + std::unique_ptr<SessionDescriptionInterface> answer(CreateAnswer());
|
| + VerifyCryptoParams(answer->description(), true);
|
| +}
|
| +
|
| TEST_F(WebRtcSessionTest, VerifyNoCryptoParamsInSDP) {
|
| options_.disable_encryption = true;
|
| Init();
|
| @@ -3387,6 +3439,12 @@ TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) {
|
| SetLocalDescriptionWithoutError(offer);
|
| }
|
|
|
| +TEST_F(WebRtcSessionTest, SetSetupGcm) {
|
| + InitWithGcm();
|
| + SendAudioVideoStream1();
|
| + CreateAndSetRemoteOfferAndLocalAnswer();
|
| +}
|
| +
|
| TEST_F(WebRtcSessionTest, CanNotInsertDtmf) {
|
| TestCanInsertDtmf(false);
|
| }
|
|
|