Commit 9ae5b3b9 authored by rch's avatar rch Committed by Commit bot

Make QUIC tests use certs which are valid for the hosts they connect to.

BUG=

Review URL: https://codereview.chromium.org/1680243005

Cr-Commit-Position: refs/heads/master@{#374803}
parent 12a05276
......@@ -60,7 +60,7 @@ namespace test {
namespace {
const char kUploadData[] = "Really nifty data!";
const char kDefaultServerHostName[] = "www.google.com";
const char kDefaultServerHostName[] = "www.example.org";
const uint16_t kDefaultServerPort = 80;
class TestQuicConnection : public QuicConnection {
......@@ -379,7 +379,7 @@ TEST_P(QuicHttpStreamTest, GetRequest) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -428,7 +428,7 @@ TEST_P(QuicHttpStreamTest, GetRequestLargeResponse) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -478,7 +478,7 @@ TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -498,7 +498,7 @@ TEST_P(QuicHttpStreamTest, GetSSLInfoAfterSessionClosed) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -525,7 +525,7 @@ TEST_P(QuicHttpStreamTest, LogGranularQuicConnectionError) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -555,7 +555,7 @@ TEST_P(QuicHttpStreamTest, DoNotLogGranularQuicErrorIfHandshakeNotConfirmed) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -589,7 +589,7 @@ TEST_P(QuicHttpStreamTest, SessionClosedBeforeReadResponseHeaders) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -623,7 +623,7 @@ TEST_P(QuicHttpStreamTest, SendPostRequest) {
new UploadBytesElementReader(kUploadData, strlen(kUploadData))));
ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0);
request_.method = "POST";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
request_.upload_data_stream = &upload_data_stream;
ASSERT_EQ(OK, request_.upload_data_stream->Init(CompletionCallback()));
......@@ -685,7 +685,7 @@ TEST_P(QuicHttpStreamTest, SendChunkedPostRequest) {
upload_data_stream.AppendData(kUploadData, chunk_size, false);
request_.method = "POST";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
request_.upload_data_stream = &upload_data_stream;
ASSERT_EQ(OK, request_.upload_data_stream->Init(
TestCompletionCallback().callback()));
......@@ -752,7 +752,7 @@ TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithFinalEmptyDataPacket) {
upload_data_stream.AppendData(kUploadData, chunk_size, false);
request_.method = "POST";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
request_.upload_data_stream = &upload_data_stream;
ASSERT_EQ(OK, request_.upload_data_stream->Init(
TestCompletionCallback().callback()));
......@@ -814,7 +814,7 @@ TEST_P(QuicHttpStreamTest, SendChunkedPostRequestWithOneEmptyDataPacket) {
ChunkedUploadDataStream upload_data_stream(0);
request_.method = "POST";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
request_.upload_data_stream = &upload_data_stream;
ASSERT_EQ(OK, request_.upload_data_stream->Init(
TestCompletionCallback().callback()));
......@@ -874,7 +874,7 @@ TEST_P(QuicHttpStreamTest, DestroyedEarly) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, net_log_,
callback_.callback()));
......@@ -912,7 +912,7 @@ TEST_P(QuicHttpStreamTest, Priority) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_,
callback_.callback()));
......@@ -961,7 +961,7 @@ TEST_P(QuicHttpStreamTest, CheckPriorityWithNoDelegate) {
Initialize();
request_.method = "GET";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_,
callback_.callback()));
......@@ -992,7 +992,7 @@ TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendHeadersComplete) {
ChunkedUploadDataStream upload_data_stream(0);
request_.method = "POST";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
request_.upload_data_stream = &upload_data_stream;
ASSERT_EQ(OK, request_.upload_data_stream->Init(
TestCompletionCallback().callback()));
......@@ -1016,7 +1016,7 @@ TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendBodyComplete) {
upload_data_stream.AppendData(kUploadData, chunk_size, false);
request_.method = "POST";
request_.url = GURL("http://www.google.com/");
request_.url = GURL("http://www.example.org/");
request_.upload_data_stream = &upload_data_stream;
ASSERT_EQ(OK, request_.upload_data_stream->Init(
TestCompletionCallback().callback()));
......
......@@ -20,13 +20,14 @@ MockCryptoClientStream::MockCryptoClientStream(
ProofVerifyContext* verify_context,
QuicCryptoClientConfig* crypto_config,
HandshakeMode handshake_mode,
const ProofVerifyDetails* proof_verify_details)
const ProofVerifyDetailsChromium* proof_verify_details)
: QuicCryptoClientStream(server_id,
session,
verify_context,
crypto_config,
session),
handshake_mode_(handshake_mode),
server_id_(server_id),
proof_verify_details_(proof_verify_details) {}
MockCryptoClientStream::~MockCryptoClientStream() {}
......@@ -38,6 +39,17 @@ void MockCryptoClientStream::OnHandshakeMessage(
}
void MockCryptoClientStream::CryptoConnect() {
if (proof_verify_details_) {
bool unused = false;
if (!proof_verify_details_->cert_verify_result.verified_cert
->VerifyNameMatch(server_id_.host(), &unused)) {
handshake_confirmed_ = false;
encryption_established_ = false;
session()->connection()->CloseConnection(QUIC_PROOF_INVALID, false);
return;
}
}
switch (handshake_mode_) {
case ZERO_RTT: {
encryption_established_ = true;
......
......@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "net/quic/crypto/crypto_handshake.h"
#include "net/quic/crypto/crypto_protocol.h"
#include "net/quic/crypto/proof_verifier_chromium.h"
#include "net/quic/quic_client_session_base.h"
#include "net/quic/quic_crypto_client_stream.h"
#include "net/quic/quic_session.h"
......@@ -37,12 +38,13 @@ class MockCryptoClientStream : public QuicCryptoClientStream {
COLD_START,
};
MockCryptoClientStream(const QuicServerId& server_id,
QuicClientSessionBase* session,
ProofVerifyContext* verify_context,
QuicCryptoClientConfig* crypto_config,
HandshakeMode handshake_mode,
const ProofVerifyDetails* proof_verify_details_);
MockCryptoClientStream(
const QuicServerId& server_id,
QuicClientSessionBase* session,
ProofVerifyContext* verify_context,
QuicCryptoClientConfig* crypto_config,
HandshakeMode handshake_mode,
const ProofVerifyDetailsChromium* proof_verify_details_);
~MockCryptoClientStream() override;
// CryptoFramerVisitorInterface implementation.
......@@ -60,7 +62,8 @@ class MockCryptoClientStream : public QuicCryptoClientStream {
private:
void SetConfigNegotiated();
const ProofVerifyDetails* proof_verify_details_;
const QuicServerId server_id_;
const ProofVerifyDetailsChromium* proof_verify_details_;
DISALLOW_COPY_AND_ASSIGN(MockCryptoClientStream);
};
......
......@@ -25,7 +25,7 @@ MockCryptoClientStreamFactory::CreateQuicCryptoClientStream(
QuicChromiumClientSession* session,
scoped_ptr<ProofVerifyContext> /*proof_verify_context*/,
QuicCryptoClientConfig* crypto_config) {
const ProofVerifyDetails* proof_verify_details = nullptr;
const ProofVerifyDetailsChromium* proof_verify_details = nullptr;
if (!proof_verify_details_queue_.empty()) {
proof_verify_details = proof_verify_details_queue_.front();
proof_verify_details_queue_.pop();
......
......@@ -9,6 +9,7 @@
#include <string>
#include "base/macros.h"
#include "net/quic/crypto/proof_verifier_chromium.h"
#include "net/quic/quic_crypto_client_stream.h"
#include "net/quic/quic_crypto_client_stream_factory.h"
#include "net/quic/test_tools/mock_crypto_client_stream.h"
......@@ -34,7 +35,8 @@ class MockCryptoClientStreamFactory : public QuicCryptoClientStreamFactory {
}
// The caller keeps ownership of |proof_verify_details|.
void AddProofVerifyDetails(const ProofVerifyDetails* proof_verify_details) {
void AddProofVerifyDetails(
const ProofVerifyDetailsChromium* proof_verify_details) {
proof_verify_details_queue_.push(proof_verify_details);
}
......@@ -43,7 +45,7 @@ class MockCryptoClientStreamFactory : public QuicCryptoClientStreamFactory {
private:
MockCryptoClientStream::HandshakeMode handshake_mode_;
MockCryptoClientStream* last_stream_;
std::queue<const ProofVerifyDetails*> proof_verify_details_queue_;
std::queue<const ProofVerifyDetailsChromium*> proof_verify_details_queue_;
DISALLOW_COPY_AND_ASSIGN(MockCryptoClientStreamFactory);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment