OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SOCKET_SOCKET_TEST_UTIL_H_ | 5 #ifndef NET_SOCKET_SOCKET_TEST_UTIL_H_ |
6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_ | 6 #define NET_SOCKET_SOCKET_TEST_UTIL_H_ |
7 | 7 |
8 #include <cstring> | 8 #include <cstring> |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 protected: | 687 protected: |
688 virtual ~MockSOCKSClientSocketPool(); | 688 virtual ~MockSOCKSClientSocketPool(); |
689 | 689 |
690 private: | 690 private: |
691 const scoped_refptr<TCPClientSocketPool> tcp_pool_; | 691 const scoped_refptr<TCPClientSocketPool> tcp_pool_; |
692 | 692 |
693 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); | 693 DISALLOW_COPY_AND_ASSIGN(MockSOCKSClientSocketPool); |
694 }; | 694 }; |
695 | 695 |
696 struct MockHttpAuthControllerData { | 696 struct MockHttpAuthControllerData { |
697 MockHttpAuthControllerData(std::string header) : auth_header(header) {} | 697 MockHttpAuthControllerData(std::string header, |
| 698 std::string expected_username, |
| 699 std::string expected_password) |
| 700 : auth_header(header), |
| 701 username(expected_username), |
| 702 password(expected_password) {} |
698 | 703 |
699 std::string auth_header; | 704 std::string auth_header; |
| 705 std::string username; |
| 706 std::string password; |
700 }; | 707 }; |
701 | 708 |
702 class MockHttpAuthController : public HttpAuthController { | 709 class MockHttpAuthController : public HttpAuthController { |
703 public: | 710 public: |
704 MockHttpAuthController(); | 711 MockHttpAuthController(); |
| 712 virtual ~MockHttpAuthController() {} |
| 713 |
705 void SetMockAuthControllerData(struct MockHttpAuthControllerData* data, | 714 void SetMockAuthControllerData(struct MockHttpAuthControllerData* data, |
706 size_t data_length); | 715 size_t data_length); |
707 | 716 |
708 // HttpAuthController methods. | 717 // HttpAuthController methods. |
709 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, | 718 virtual int MaybeGenerateAuthToken(const HttpRequestInfo* request, |
710 CompletionCallback* callback, | 719 CompletionCallback* callback, |
711 const BoundNetLog& net_log); | 720 const BoundNetLog& net_log); |
712 virtual void AddAuthorizationHeader( | 721 virtual void AddAuthorizationHeader( |
713 HttpRequestHeaders* authorization_headers); | 722 HttpRequestHeaders* authorization_headers); |
714 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, | 723 virtual int HandleAuthChallenge(scoped_refptr<HttpResponseHeaders> headers, |
715 bool do_not_send_server_auth, | 724 bool do_not_send_server_auth, |
716 bool establishing_tunnel, | 725 bool establishing_tunnel, |
717 const BoundNetLog& net_log); | 726 const BoundNetLog& net_log); |
718 virtual void ResetAuth(const std::wstring& username, | 727 virtual void SetCredentials(const std::wstring& username, |
719 const std::wstring& password); | 728 const std::wstring& password); |
| 729 void PrepareForAuthRestart(); |
| 730 |
720 virtual bool HaveAuthHandler() const; | 731 virtual bool HaveAuthHandler() const; |
721 virtual bool HaveAuth() const; | 732 virtual bool HaveAuth() const; |
| 733 virtual HttpAuth::Identity AuthIdentity(); |
722 | 734 |
723 private: | 735 private: |
724 virtual ~MockHttpAuthController() {} | |
725 const struct MockHttpAuthControllerData& CurrentData() const { | 736 const struct MockHttpAuthControllerData& CurrentData() const { |
726 DCHECK(data_index_ < data_count_); | 737 DCHECK(data_index_ < data_count_); |
727 return data_[data_index_]; | 738 return data_[data_index_]; |
728 } | 739 } |
729 | 740 |
730 MockHttpAuthControllerData* data_; | 741 MockHttpAuthControllerData* data_; |
731 size_t data_index_; | 742 size_t data_index_; |
732 size_t data_count_; | 743 size_t data_count_; |
| 744 size_t next_index_; |
733 }; | 745 }; |
734 | 746 |
735 // Constants for a successful SOCKS v5 handshake. | 747 // Constants for a successful SOCKS v5 handshake. |
736 extern const char kSOCKS5GreetRequest[]; | 748 extern const char kSOCKS5GreetRequest[]; |
737 extern const int kSOCKS5GreetRequestLength; | 749 extern const int kSOCKS5GreetRequestLength; |
738 | 750 |
739 extern const char kSOCKS5GreetResponse[]; | 751 extern const char kSOCKS5GreetResponse[]; |
740 extern const int kSOCKS5GreetResponseLength; | 752 extern const int kSOCKS5GreetResponseLength; |
741 | 753 |
742 extern const char kSOCKS5OkRequest[]; | 754 extern const char kSOCKS5OkRequest[]; |
743 extern const int kSOCKS5OkRequestLength; | 755 extern const int kSOCKS5OkRequestLength; |
744 | 756 |
745 extern const char kSOCKS5OkResponse[]; | 757 extern const char kSOCKS5OkResponse[]; |
746 extern const int kSOCKS5OkResponseLength; | 758 extern const int kSOCKS5OkResponseLength; |
747 | 759 |
748 } // namespace net | 760 } // namespace net |
749 | 761 |
750 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ | 762 #endif // NET_SOCKET_SOCKET_TEST_UTIL_H_ |
OLD | NEW |