| 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 // This test suite uses SSLClientSocket to test the implementation of | 5 // This test suite uses SSLClientSocket to test the implementation of |
| 6 // SSLServerSocket. In order to establish connections between the sockets | 6 // SSLServerSocket. In order to establish connections between the sockets |
| 7 // we need two additional classes: | 7 // we need two additional classes: |
| 8 // 1. FakeSocket | 8 // 1. FakeSocket |
| 9 // Connects SSL socket to FakeDataChannel. This class is just a stub. | 9 // Connects SSL socket to FakeDataChannel. This class is just a stub. |
| 10 // | 10 // |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 FakeSocket(FakeDataChannel* incoming_channel, | 164 FakeSocket(FakeDataChannel* incoming_channel, |
| 165 FakeDataChannel* outgoing_channel) | 165 FakeDataChannel* outgoing_channel) |
| 166 : incoming_(incoming_channel), | 166 : incoming_(incoming_channel), |
| 167 outgoing_(outgoing_channel) { | 167 outgoing_(outgoing_channel) { |
| 168 } | 168 } |
| 169 | 169 |
| 170 virtual ~FakeSocket() { | 170 virtual ~FakeSocket() { |
| 171 } | 171 } |
| 172 | 172 |
| 173 virtual int Read(IOBuffer* buf, int buf_len, | 173 virtual int Read(IOBuffer* buf, int buf_len, |
| 174 const CompletionCallback& callback) OVERRIDE { | 174 const CompletionCallback& callback) override { |
| 175 // Read random number of bytes. | 175 // Read random number of bytes. |
| 176 buf_len = rand() % buf_len + 1; | 176 buf_len = rand() % buf_len + 1; |
| 177 return incoming_->Read(buf, buf_len, callback); | 177 return incoming_->Read(buf, buf_len, callback); |
| 178 } | 178 } |
| 179 | 179 |
| 180 virtual int Write(IOBuffer* buf, int buf_len, | 180 virtual int Write(IOBuffer* buf, int buf_len, |
| 181 const CompletionCallback& callback) OVERRIDE { | 181 const CompletionCallback& callback) override { |
| 182 // Write random number of bytes. | 182 // Write random number of bytes. |
| 183 buf_len = rand() % buf_len + 1; | 183 buf_len = rand() % buf_len + 1; |
| 184 return outgoing_->Write(buf, buf_len, callback); | 184 return outgoing_->Write(buf, buf_len, callback); |
| 185 } | 185 } |
| 186 | 186 |
| 187 virtual int SetReceiveBufferSize(int32 size) OVERRIDE { | 187 virtual int SetReceiveBufferSize(int32 size) override { |
| 188 return OK; | 188 return OK; |
| 189 } | 189 } |
| 190 | 190 |
| 191 virtual int SetSendBufferSize(int32 size) OVERRIDE { | 191 virtual int SetSendBufferSize(int32 size) override { |
| 192 return OK; | 192 return OK; |
| 193 } | 193 } |
| 194 | 194 |
| 195 virtual int Connect(const CompletionCallback& callback) OVERRIDE { | 195 virtual int Connect(const CompletionCallback& callback) override { |
| 196 return OK; | 196 return OK; |
| 197 } | 197 } |
| 198 | 198 |
| 199 virtual void Disconnect() OVERRIDE { | 199 virtual void Disconnect() override { |
| 200 incoming_->Close(); | 200 incoming_->Close(); |
| 201 outgoing_->Close(); | 201 outgoing_->Close(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 virtual bool IsConnected() const OVERRIDE { | 204 virtual bool IsConnected() const override { |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| 207 | 207 |
| 208 virtual bool IsConnectedAndIdle() const OVERRIDE { | 208 virtual bool IsConnectedAndIdle() const override { |
| 209 return true; | 209 return true; |
| 210 } | 210 } |
| 211 | 211 |
| 212 virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE { | 212 virtual int GetPeerAddress(IPEndPoint* address) const override { |
| 213 IPAddressNumber ip_address(kIPv4AddressSize); | 213 IPAddressNumber ip_address(kIPv4AddressSize); |
| 214 *address = IPEndPoint(ip_address, 0 /*port*/); | 214 *address = IPEndPoint(ip_address, 0 /*port*/); |
| 215 return OK; | 215 return OK; |
| 216 } | 216 } |
| 217 | 217 |
| 218 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE { | 218 virtual int GetLocalAddress(IPEndPoint* address) const override { |
| 219 IPAddressNumber ip_address(4); | 219 IPAddressNumber ip_address(4); |
| 220 *address = IPEndPoint(ip_address, 0); | 220 *address = IPEndPoint(ip_address, 0); |
| 221 return OK; | 221 return OK; |
| 222 } | 222 } |
| 223 | 223 |
| 224 virtual const BoundNetLog& NetLog() const OVERRIDE { | 224 virtual const BoundNetLog& NetLog() const override { |
| 225 return net_log_; | 225 return net_log_; |
| 226 } | 226 } |
| 227 | 227 |
| 228 virtual void SetSubresourceSpeculation() OVERRIDE {} | 228 virtual void SetSubresourceSpeculation() override {} |
| 229 virtual void SetOmniboxSpeculation() OVERRIDE {} | 229 virtual void SetOmniboxSpeculation() override {} |
| 230 | 230 |
| 231 virtual bool WasEverUsed() const OVERRIDE { | 231 virtual bool WasEverUsed() const override { |
| 232 return true; | 232 return true; |
| 233 } | 233 } |
| 234 | 234 |
| 235 virtual bool UsingTCPFastOpen() const OVERRIDE { | 235 virtual bool UsingTCPFastOpen() const override { |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 | 238 |
| 239 | 239 |
| 240 virtual bool WasNpnNegotiated() const OVERRIDE { | 240 virtual bool WasNpnNegotiated() const override { |
| 241 return false; | 241 return false; |
| 242 } | 242 } |
| 243 | 243 |
| 244 virtual NextProto GetNegotiatedProtocol() const OVERRIDE { | 244 virtual NextProto GetNegotiatedProtocol() const override { |
| 245 return kProtoUnknown; | 245 return kProtoUnknown; |
| 246 } | 246 } |
| 247 | 247 |
| 248 virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE { | 248 virtual bool GetSSLInfo(SSLInfo* ssl_info) override { |
| 249 return false; | 249 return false; |
| 250 } | 250 } |
| 251 | 251 |
| 252 private: | 252 private: |
| 253 BoundNetLog net_log_; | 253 BoundNetLog net_log_; |
| 254 FakeDataChannel* incoming_; | 254 FakeDataChannel* incoming_; |
| 255 FakeDataChannel* outgoing_; | 255 FakeDataChannel* outgoing_; |
| 256 | 256 |
| 257 DISALLOW_COPY_AND_ASSIGN(FakeSocket); | 257 DISALLOW_COPY_AND_ASSIGN(FakeSocket); |
| 258 }; | 258 }; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 const char* kKeyingLabelBad = "EXPERIMENTAL-server-socket-test-bad"; | 576 const char* kKeyingLabelBad = "EXPERIMENTAL-server-socket-test-bad"; |
| 577 unsigned char client_bad[kKeyingMaterialSize]; | 577 unsigned char client_bad[kKeyingMaterialSize]; |
| 578 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad, | 578 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad, |
| 579 false, kKeyingContext, | 579 false, kKeyingContext, |
| 580 client_bad, sizeof(client_bad)); | 580 client_bad, sizeof(client_bad)); |
| 581 ASSERT_EQ(rv, OK); | 581 ASSERT_EQ(rv, OK); |
| 582 EXPECT_NE(0, memcmp(server_out, client_bad, sizeof(server_out))); | 582 EXPECT_NE(0, memcmp(server_out, client_bad, sizeof(server_out))); |
| 583 } | 583 } |
| 584 | 584 |
| 585 } // namespace net | 585 } // namespace net |
| OLD | NEW |