| OLD | NEW |
| 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 // A set of unit tests for TokenValidatorFactoryImpl | 5 // A set of unit tests for TokenValidatorFactoryImpl |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "net/http/http_status_code.h" | 12 #include "net/http/http_status_code.h" |
| 12 #include "net/url_request/url_request_job_factory.h" | 13 #include "net/url_request/url_request_job_factory.h" |
| 13 #include "net/url_request/url_request_job_factory_impl.h" | 14 #include "net/url_request/url_request_job_factory_impl.h" |
| 14 #include "net/url_request/url_request_status.h" | 15 #include "net/url_request/url_request_status.h" |
| 15 #include "net/url_request/url_request_test_job.h" | 16 #include "net/url_request/url_request_test_job.h" |
| 16 #include "net/url_request/url_request_test_util.h" | 17 #include "net/url_request/url_request_test_util.h" |
| 17 #include "remoting/base/rsa_key_pair.h" | 18 #include "remoting/base/rsa_key_pair.h" |
| 18 #include "remoting/base/test_rsa_key_pair.h" | 19 #include "remoting/base/test_rsa_key_pair.h" |
| 19 #include "remoting/host/token_validator_factory_impl.h" | 20 #include "remoting/host/token_validator_factory_impl.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 } | 49 } |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 std::string headers_; | 52 std::string headers_; |
| 52 std::string response_; | 53 std::string response_; |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 class SetResponseURLRequestContext: public net::TestURLRequestContext { | 56 class SetResponseURLRequestContext: public net::TestURLRequestContext { |
| 56 public: | 57 public: |
| 57 void SetResponse(const std::string& headers, const std::string& response) { | 58 void SetResponse(const std::string& headers, const std::string& response) { |
| 58 net::URLRequestJobFactoryImpl* factory = | 59 scoped_ptr<net::URLRequestJobFactoryImpl> factory = |
| 59 new net::URLRequestJobFactoryImpl(); | 60 make_scoped_ptr(new net::URLRequestJobFactoryImpl()); |
| 60 factory->SetProtocolHandler( | 61 factory->SetProtocolHandler( |
| 61 "https", make_scoped_ptr(new FakeProtocolHandler(headers, response))); | 62 "https", make_scoped_ptr(new FakeProtocolHandler(headers, response))); |
| 62 context_storage_.set_job_factory(factory); | 63 context_storage_.set_job_factory(factory.Pass()); |
| 63 } | 64 } |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 } // namespace | 67 } // namespace |
| 67 | 68 |
| 68 namespace remoting { | 69 namespace remoting { |
| 69 | 70 |
| 70 class TokenValidatorFactoryImplTest : public testing::Test { | 71 class TokenValidatorFactoryImplTest : public testing::Test { |
| 71 public: | 72 public: |
| 72 TokenValidatorFactoryImplTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 73 TokenValidatorFactoryImplTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); | 181 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); |
| 181 | 182 |
| 182 token_validator_->ValidateThirdPartyToken( | 183 token_validator_->ValidateThirdPartyToken( |
| 183 kToken, base::Bind( | 184 kToken, base::Bind( |
| 184 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, | 185 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, |
| 185 base::Unretained(this))); | 186 base::Unretained(this))); |
| 186 message_loop_.Run(); | 187 message_loop_.Run(); |
| 187 } | 188 } |
| 188 | 189 |
| 189 } // namespace remoting | 190 } // namespace remoting |
| OLD | NEW |