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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 }; | 160 }; |
161 | 161 |
162 class FakeSocket : public StreamSocket { | 162 class FakeSocket : public StreamSocket { |
163 public: | 163 public: |
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 ~FakeSocket() override {} |
171 } | |
172 | 171 |
173 virtual int Read(IOBuffer* buf, int buf_len, | 172 int Read(IOBuffer* buf, |
174 const CompletionCallback& callback) override { | 173 int buf_len, |
| 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 int Write(IOBuffer* buf, |
181 const CompletionCallback& callback) override { | 181 int buf_len, |
| 182 const CompletionCallback& callback) override { |
182 // Write random number of bytes. | 183 // Write random number of bytes. |
183 buf_len = rand() % buf_len + 1; | 184 buf_len = rand() % buf_len + 1; |
184 return outgoing_->Write(buf, buf_len, callback); | 185 return outgoing_->Write(buf, buf_len, callback); |
185 } | 186 } |
186 | 187 |
187 virtual int SetReceiveBufferSize(int32 size) override { | 188 int SetReceiveBufferSize(int32 size) override { return OK; } |
188 return OK; | |
189 } | |
190 | 189 |
191 virtual int SetSendBufferSize(int32 size) override { | 190 int SetSendBufferSize(int32 size) override { return OK; } |
192 return OK; | |
193 } | |
194 | 191 |
195 virtual int Connect(const CompletionCallback& callback) override { | 192 int Connect(const CompletionCallback& callback) override { return OK; } |
196 return OK; | |
197 } | |
198 | 193 |
199 virtual void Disconnect() override { | 194 void Disconnect() override { |
200 incoming_->Close(); | 195 incoming_->Close(); |
201 outgoing_->Close(); | 196 outgoing_->Close(); |
202 } | 197 } |
203 | 198 |
204 virtual bool IsConnected() const override { | 199 bool IsConnected() const override { return true; } |
205 return true; | |
206 } | |
207 | 200 |
208 virtual bool IsConnectedAndIdle() const override { | 201 bool IsConnectedAndIdle() const override { return true; } |
209 return true; | |
210 } | |
211 | 202 |
212 virtual int GetPeerAddress(IPEndPoint* address) const override { | 203 int GetPeerAddress(IPEndPoint* address) const override { |
213 IPAddressNumber ip_address(kIPv4AddressSize); | 204 IPAddressNumber ip_address(kIPv4AddressSize); |
214 *address = IPEndPoint(ip_address, 0 /*port*/); | 205 *address = IPEndPoint(ip_address, 0 /*port*/); |
215 return OK; | 206 return OK; |
216 } | 207 } |
217 | 208 |
218 virtual int GetLocalAddress(IPEndPoint* address) const override { | 209 int GetLocalAddress(IPEndPoint* address) const override { |
219 IPAddressNumber ip_address(4); | 210 IPAddressNumber ip_address(4); |
220 *address = IPEndPoint(ip_address, 0); | 211 *address = IPEndPoint(ip_address, 0); |
221 return OK; | 212 return OK; |
222 } | 213 } |
223 | 214 |
224 virtual const BoundNetLog& NetLog() const override { | 215 const BoundNetLog& NetLog() const override { return net_log_; } |
225 return net_log_; | |
226 } | |
227 | 216 |
228 virtual void SetSubresourceSpeculation() override {} | 217 void SetSubresourceSpeculation() override {} |
229 virtual void SetOmniboxSpeculation() override {} | 218 void SetOmniboxSpeculation() override {} |
230 | 219 |
231 virtual bool WasEverUsed() const override { | 220 bool WasEverUsed() const override { return true; } |
232 return true; | |
233 } | |
234 | 221 |
235 virtual bool UsingTCPFastOpen() const override { | 222 bool UsingTCPFastOpen() const override { return false; } |
236 return false; | |
237 } | |
238 | 223 |
| 224 bool WasNpnNegotiated() const override { return false; } |
239 | 225 |
240 virtual bool WasNpnNegotiated() const override { | 226 NextProto GetNegotiatedProtocol() const override { return kProtoUnknown; } |
241 return false; | |
242 } | |
243 | 227 |
244 virtual NextProto GetNegotiatedProtocol() const override { | 228 bool GetSSLInfo(SSLInfo* ssl_info) override { return false; } |
245 return kProtoUnknown; | |
246 } | |
247 | |
248 virtual bool GetSSLInfo(SSLInfo* ssl_info) override { | |
249 return false; | |
250 } | |
251 | 229 |
252 private: | 230 private: |
253 BoundNetLog net_log_; | 231 BoundNetLog net_log_; |
254 FakeDataChannel* incoming_; | 232 FakeDataChannel* incoming_; |
255 FakeDataChannel* outgoing_; | 233 FakeDataChannel* outgoing_; |
256 | 234 |
257 DISALLOW_COPY_AND_ASSIGN(FakeSocket); | 235 DISALLOW_COPY_AND_ASSIGN(FakeSocket); |
258 }; | 236 }; |
259 | 237 |
260 } // namespace | 238 } // namespace |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 const char* kKeyingLabelBad = "EXPERIMENTAL-server-socket-test-bad"; | 554 const char* kKeyingLabelBad = "EXPERIMENTAL-server-socket-test-bad"; |
577 unsigned char client_bad[kKeyingMaterialSize]; | 555 unsigned char client_bad[kKeyingMaterialSize]; |
578 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad, | 556 rv = client_socket_->ExportKeyingMaterial(kKeyingLabelBad, |
579 false, kKeyingContext, | 557 false, kKeyingContext, |
580 client_bad, sizeof(client_bad)); | 558 client_bad, sizeof(client_bad)); |
581 ASSERT_EQ(rv, OK); | 559 ASSERT_EQ(rv, OK); |
582 EXPECT_NE(0, memcmp(server_out, client_bad, sizeof(server_out))); | 560 EXPECT_NE(0, memcmp(server_out, client_bad, sizeof(server_out))); |
583 } | 561 } |
584 | 562 |
585 } // namespace net | 563 } // namespace net |
OLD | NEW |