diff options
Diffstat (limited to 'net/quic/quic_crypto_client_stream_test.cc')
-rw-r--r-- | net/quic/quic_crypto_client_stream_test.cc | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/net/quic/quic_crypto_client_stream_test.cc b/net/quic/quic_crypto_client_stream_test.cc index 160aaf9..90b9122 100644 --- a/net/quic/quic_crypto_client_stream_test.cc +++ b/net/quic/quic_crypto_client_stream_test.cc @@ -5,7 +5,7 @@ #include "net/quic/quic_crypto_client_stream.h" #include "base/memory/scoped_ptr.h" -#include "net/quic/crypto/aes_128_gcm_12_encrypter.h" +#include "net/quic/crypto/aes_128_gcm_encrypter.h" #include "net/quic/crypto/quic_decrypter.h" #include "net/quic/crypto/quic_encrypter.h" #include "net/quic/quic_protocol.h" @@ -19,7 +19,7 @@ namespace net { namespace test { namespace { -const char kServerHostname[] = "example.com"; +const char kServerHostname[] = "localhost"; class TestQuicVisitor : public NoOpFramerVisitor { public: @@ -52,16 +52,15 @@ class QuicCryptoClientStreamTest : public ::testing::Test { : addr_(), connection_(new PacketSavingConnection(1, addr_, true)), session_(connection_, QuicConfig(), true), - stream_(new QuicCryptoClientStream(kServerHostname, &session_, - &crypto_config_)) { - session_.SetCryptoStream(stream_.get()); + stream_(kServerHostname, &session_, &crypto_config_) { + session_.SetCryptoStream(&stream_); session_.config()->SetDefaults(); crypto_config_.SetDefaults(); } void CompleteCryptoHandshake() { - EXPECT_TRUE(stream_->CryptoConnect()); - CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); + EXPECT_TRUE(stream_.CryptoConnect()); + CryptoTestUtils::HandshakeWithFakeServer(connection_, &stream_); } void ConstructHandshakeMessage() { @@ -72,35 +71,35 @@ class QuicCryptoClientStreamTest : public ::testing::Test { IPEndPoint addr_; PacketSavingConnection* connection_; TestSession session_; - scoped_ptr<QuicCryptoClientStream> stream_; + QuicCryptoClientStream stream_; CryptoHandshakeMessage message_; scoped_ptr<QuicData> message_data_; QuicCryptoClientConfig crypto_config_; }; TEST_F(QuicCryptoClientStreamTest, NotInitiallyConected) { - if (!Aes128Gcm12Encrypter::IsSupported()) { + if (!Aes128GcmEncrypter::IsSupported()) { LOG(INFO) << "AES GCM not supported. Test skipped."; return; } - EXPECT_FALSE(stream_->encryption_established()); - EXPECT_FALSE(stream_->handshake_confirmed()); + EXPECT_FALSE(stream_.encryption_established()); + EXPECT_FALSE(stream_.handshake_confirmed()); } TEST_F(QuicCryptoClientStreamTest, ConnectedAfterSHLO) { - if (!Aes128Gcm12Encrypter::IsSupported()) { + if (!Aes128GcmEncrypter::IsSupported()) { LOG(INFO) << "AES GCM not supported. Test skipped."; return; } CompleteCryptoHandshake(); - EXPECT_TRUE(stream_->encryption_established()); - EXPECT_TRUE(stream_->handshake_confirmed()); + EXPECT_TRUE(stream_.encryption_established()); + EXPECT_TRUE(stream_.handshake_confirmed()); } TEST_F(QuicCryptoClientStreamTest, MessageAfterHandshake) { - if (!Aes128Gcm12Encrypter::IsSupported()) { + if (!Aes128GcmEncrypter::IsSupported()) { LOG(INFO) << "AES GCM not supported. Test skipped."; return; } @@ -111,27 +110,27 @@ TEST_F(QuicCryptoClientStreamTest, MessageAfterHandshake) { QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE)); message_.set_tag(kCHLO); ConstructHandshakeMessage(); - stream_->ProcessData(message_data_->data(), message_data_->length()); + stream_.ProcessData(message_data_->data(), message_data_->length()); } TEST_F(QuicCryptoClientStreamTest, BadMessageType) { - if (!Aes128Gcm12Encrypter::IsSupported()) { + if (!Aes128GcmEncrypter::IsSupported()) { LOG(INFO) << "AES GCM not supported. Test skipped."; return; } - EXPECT_TRUE(stream_->CryptoConnect()); + EXPECT_TRUE(stream_.CryptoConnect()); message_.set_tag(kCHLO); ConstructHandshakeMessage(); EXPECT_CALL(*connection_, SendConnectionCloseWithDetails( QUIC_INVALID_CRYPTO_MESSAGE_TYPE, "Expected REJ")); - stream_->ProcessData(message_data_->data(), message_data_->length()); + stream_.ProcessData(message_data_->data(), message_data_->length()); } TEST_F(QuicCryptoClientStreamTest, NegotiatedParameters) { - if (!Aes128Gcm12Encrypter::IsSupported()) { + if (!Aes128GcmEncrypter::IsSupported()) { LOG(INFO) << "AES GCM not supported. Test skipped."; return; } @@ -147,26 +146,11 @@ TEST_F(QuicCryptoClientStreamTest, NegotiatedParameters) { EXPECT_EQ(0, config->keepalive_timeout().ToSeconds()); const QuicCryptoNegotiatedParameters& crypto_params( - stream_->crypto_negotiated_params()); + stream_.crypto_negotiated_params()); EXPECT_EQ(kAESG, crypto_params.aead); EXPECT_EQ(kC255, crypto_params.key_exchange); } -TEST_F(QuicCryptoClientStreamTest, InvalidHostname) { - if (!Aes128Gcm12Encrypter::IsSupported()) { - LOG(INFO) << "AES GCM not supported. Test skipped."; - return; - } - - stream_.reset(new QuicCryptoClientStream("invalid", &session_, - &crypto_config_)); - session_.SetCryptoStream(stream_.get()); - - CompleteCryptoHandshake(); - EXPECT_TRUE(stream_->encryption_established()); - EXPECT_TRUE(stream_->handshake_confirmed()); -} - } // namespace } // namespace test } // namespace net |