Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / net / quic / test_tools / mock_crypto_client_stream.cc
index a5ff173..6710dcd 100644 (file)
@@ -4,20 +4,21 @@
 
 #include "net/quic/test_tools/mock_crypto_client_stream.h"
 
+#include "net/quic/crypto/quic_decrypter.h"
 #include "net/quic/quic_client_session_base.h"
-#include "net/quic/quic_session_key.h"
+#include "net/quic/quic_server_id.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace net {
 
 MockCryptoClientStream::MockCryptoClientStream(
-    const QuicSessionKey& server_key,
+    const QuicServerId& server_id,
     QuicClientSessionBase* session,
     ProofVerifyContext* verify_context,
     QuicCryptoClientConfig* crypto_config,
     HandshakeMode handshake_mode,
     const ProofVerifyDetails* proof_verify_details)
-    : QuicCryptoClientStream(server_key, session, verify_context,
+    : QuicCryptoClientStream(server_id, session, verify_context,
                              crypto_config),
       handshake_mode_(handshake_mode),
       proof_verify_details_(proof_verify_details) {
@@ -36,6 +37,8 @@ bool MockCryptoClientStream::CryptoConnect() {
     case ZERO_RTT: {
       encryption_established_ = true;
       handshake_confirmed_ = false;
+      session()->connection()->SetDecrypter(QuicDecrypter::Create(kNULL),
+                                            ENCRYPTION_INITIAL);
       session()->OnCryptoHandshakeEvent(
           QuicSession::ENCRYPTION_FIRST_ESTABLISHED);
       break;
@@ -44,10 +47,14 @@ bool MockCryptoClientStream::CryptoConnect() {
     case CONFIRM_HANDSHAKE: {
       encryption_established_ = true;
       handshake_confirmed_ = true;
+      crypto_negotiated_params_.key_exchange = kC255;
+      crypto_negotiated_params_.aead = kAESG;
       if (proof_verify_details_) {
         client_session()->OnProofVerifyDetailsAvailable(*proof_verify_details_);
       }
       SetConfigNegotiated();
+      session()->connection()->SetDecrypter(QuicDecrypter::Create(kNULL),
+                                            ENCRYPTION_FORWARD_SECURE);
       session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
       break;
     }
@@ -87,7 +94,7 @@ void MockCryptoClientStream::SetConfigNegotiated() {
   session()->config()->ToHandshakeMessage(&msg);
   string error_details;
   const QuicErrorCode error =
-      session()->config()->ProcessClientHello(msg, &error_details);
+      session()->config()->ProcessPeerHello(msg, CLIENT, &error_details);
   ASSERT_EQ(QUIC_NO_ERROR, error);
   ASSERT_TRUE(session()->config()->negotiated());
 }