| 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 "net/spdy/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
| 6 | 6 |
| 7 #include "crypto/ec_private_key.h" | 7 #include "crypto/ec_private_key.h" |
| 8 #include "crypto/ec_signature_creator.h" | 8 #include "crypto/ec_signature_creator.h" |
| 9 #include "crypto/signature_creator.h" | 9 #include "crypto/signature_creator.h" |
| 10 #include "net/base/asn1_util.h" | 10 #include "net/base/asn1_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class SpdyHttpStreamSpdy2Test : public testing::Test { | 22 class SpdyHttpStreamSpdy2Test : public testing::Test { |
| 23 public: | 23 public: |
| 24 OrderedSocketData* data() { return data_.get(); } | 24 OrderedSocketData* data() { return data_.get(); } |
| 25 protected: | 25 protected: |
| 26 SpdyHttpStreamSpdy2Test() {} | 26 SpdyHttpStreamSpdy2Test() {} |
| 27 | 27 |
| 28 void EnableCompression(bool enabled) { | 28 void EnableCompression(bool enabled) { |
| 29 spdy::SpdyFramer::set_enable_compression_default(enabled); | 29 spdy::SpdyFramer::set_enable_compression_default(enabled); |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void SetUp() { |
| 33 SpdySession::set_default_protocol(SSLClientSocket::kProtoSPDY2); |
| 34 } |
| 35 |
| 32 virtual void TearDown() { | 36 virtual void TearDown() { |
| 33 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); | 37 crypto::ECSignatureCreator::SetFactoryForTesting(NULL); |
| 34 MessageLoop::current()->RunAllPending(); | 38 MessageLoop::current()->RunAllPending(); |
| 35 } | 39 } |
| 40 |
| 36 int InitSession(MockRead* reads, size_t reads_count, | 41 int InitSession(MockRead* reads, size_t reads_count, |
| 37 MockWrite* writes, size_t writes_count, | 42 MockWrite* writes, size_t writes_count, |
| 38 HostPortPair& host_port_pair) { | 43 HostPortPair& host_port_pair) { |
| 39 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); | 44 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| 40 data_.reset(new OrderedSocketData(reads, reads_count, | 45 data_.reset(new OrderedSocketData(reads, reads_count, |
| 41 writes, writes_count)); | 46 writes, writes_count)); |
| 42 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); | 47 session_deps_.socket_factory->AddSocketDataProvider(data_.get()); |
| 43 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 48 http_session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 44 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); | 49 session_ = http_session_->spdy_session_pool()->Get(pair, BoundNetLog()); |
| 45 transport_params_ = new TransportSocketParams(host_port_pair, | 50 transport_params_ = new TransportSocketParams(host_port_pair, |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 virtual ~MockECSignatureCreatorFactory() {} | 445 virtual ~MockECSignatureCreatorFactory() {} |
| 441 | 446 |
| 442 virtual crypto::ECSignatureCreator* Create( | 447 virtual crypto::ECSignatureCreator* Create( |
| 443 crypto::ECPrivateKey* key) OVERRIDE { | 448 crypto::ECPrivateKey* key) OVERRIDE { |
| 444 return new MockECSignatureCreator(key); | 449 return new MockECSignatureCreator(key); |
| 445 } | 450 } |
| 446 private: | 451 private: |
| 447 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreatorFactory); | 452 DISALLOW_COPY_AND_ASSIGN(MockECSignatureCreatorFactory); |
| 448 }; | 453 }; |
| 449 | 454 |
| 450 TEST_F(SpdyHttpStreamSpdy2Test, SendCredentialsEC) { | |
| 451 scoped_ptr<crypto::ECSignatureCreatorFactory> ec_signature_creator_factory( | |
| 452 new MockECSignatureCreatorFactory()); | |
| 453 crypto::ECSignatureCreator::SetFactoryForTesting( | |
| 454 ec_signature_creator_factory.get()); | |
| 455 | |
| 456 scoped_ptr<OriginBoundCertService> obc_service( | |
| 457 new OriginBoundCertService(new DefaultOriginBoundCertStore(NULL))); | |
| 458 std::string cert; | |
| 459 std::string proof; | |
| 460 GetECOriginBoundCertAndProof("http://www.gmail.com/", obc_service.get(), | |
| 461 &cert, &proof); | |
| 462 | |
| 463 TestSendCredentials(obc_service.get(), cert, proof, CLIENT_CERT_ECDSA_SIGN); | |
| 464 } | |
| 465 | |
| 466 #endif // !defined(USE_OPENSSL) | 455 #endif // !defined(USE_OPENSSL) |
| 467 | 456 |
| 468 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 457 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
| 469 // methods. | 458 // methods. |
| 470 | 459 |
| 471 } // namespace net | 460 } // namespace net |
| OLD | NEW |