Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: net/websockets/websocket_test_util.h

Issue 869073002: Add WebSocket cookie tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ 6 #define NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 26 matching lines...) Expand all
37 uint32 Generate(); 37 uint32 Generate();
38 38
39 private: 39 private:
40 uint64 current_; 40 uint64 current_;
41 }; 41 };
42 42
43 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing 43 // Alternate version of WebSocketStream::CreateAndConnectStream() for testing
44 // use only. The differences are the use of a |create_helper| argument in place 44 // use only. The differences are the use of a |create_helper| argument in place
45 // of |requested_subprotocols| and taking |timer| as the handshake timeout 45 // of |requested_subprotocols| and taking |timer| as the handshake timeout
46 // timer. Implemented in websocket_stream.cc. 46 // timer. Implemented in websocket_stream.cc.
47 NET_EXPORT_PRIVATE extern scoped_ptr<WebSocketStreamRequest> 47 NET_EXPORT_PRIVATE scoped_ptr<WebSocketStreamRequest>
48 CreateAndConnectStreamForTesting( 48 CreateAndConnectStreamForTesting(
49 const GURL& socket_url, 49 const GURL& socket_url,
50 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, 50 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper,
51 const url::Origin& origin, 51 const url::Origin& origin,
52 URLRequestContext* url_request_context, 52 URLRequestContext* url_request_context,
53 const BoundNetLog& net_log, 53 const BoundNetLog& net_log,
54 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate, 54 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate,
55 scoped_ptr<base::Timer> timer); 55 scoped_ptr<base::Timer> timer);
56 56
57 // Generates a standard WebSocket handshake request. The challenge key used is 57 // Generates a standard WebSocket handshake request. The challenge key used is
58 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated 58 // "dGhlIHNhbXBsZSBub25jZQ==". Each header in |extra_headers| must be terminated
59 // with "\r\n". 59 // with "\r\n".
60 extern std::string WebSocketStandardRequest(const std::string& path, 60 std::string WebSocketStandardRequest(const std::string& path,
61 const std::string& host, 61 const std::string& host,
62 const std::string& origin, 62 const std::string& origin,
63 const std::string& extra_headers); 63 const std::string& extra_headers);
64
65 // Generates a standard WebSocket handshake request. The challenge key used is
66 // "dGhlIHNhbXBsZSBub25jZQ==". |cookies| must be empty or terminated with
67 // "\r\n". Each header in |extra_headers| must be terminated with "\r\n".
68 std::string WebSocketStandardRequestWithCookies(
69 const std::string& path,
70 const std::string& host,
71 const std::string& origin,
72 const std::string& cookies,
73 const std::string& extra_headers);
64 74
65 // A response with the appropriate accept header to match the above challenge 75 // A response with the appropriate accept header to match the above challenge
66 // key. Each header in |extra_headers| must be terminated with "\r\n". 76 // key. Each header in |extra_headers| must be terminated with "\r\n".
67 extern std::string WebSocketStandardResponse(const std::string& extra_headers); 77 std::string WebSocketStandardResponse(const std::string& extra_headers);
68 78
69 // This class provides a convenient way to construct a 79 // This class provides a convenient way to construct a
70 // DeterministicMockClientSocketFactory for WebSocket tests. 80 // DeterministicMockClientSocketFactory for WebSocket tests.
71 class WebSocketDeterministicMockClientSocketFactoryMaker { 81 class WebSocketDeterministicMockClientSocketFactoryMaker {
72 public: 82 public:
73 WebSocketDeterministicMockClientSocketFactoryMaker(); 83 WebSocketDeterministicMockClientSocketFactoryMaker();
74 ~WebSocketDeterministicMockClientSocketFactoryMaker(); 84 ~WebSocketDeterministicMockClientSocketFactoryMaker();
75 85
76 // Tell the factory to create a socket which expects |expect_written| to be 86 // Tell the factory to create a socket which expects |expect_written| to be
77 // written, and responds with |return_to_read|. The test will fail if the 87 // written, and responds with |return_to_read|. The test will fail if the
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 TestURLRequestContext url_request_context_; 142 TestURLRequestContext url_request_context_;
133 TestNetworkDelegate network_delegate_; 143 TestNetworkDelegate network_delegate_;
134 bool url_request_context_initialized_; 144 bool url_request_context_initialized_;
135 145
136 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost); 146 DISALLOW_COPY_AND_ASSIGN(WebSocketTestURLRequestContextHost);
137 }; 147 };
138 148
139 } // namespace net 149 } // namespace net
140 150
141 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_ 151 #endif // NET_WEBSOCKETS_WEBSOCKET_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698