| 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 "remoting/host/token_validator_factory_impl.h" | 7 #include "remoting/host/token_validator_factory_impl.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 std::string headers_; | 55 std::string headers_; |
| 56 std::string response_; | 56 std::string response_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class SetResponseURLRequestContext: public net::TestURLRequestContext { | 59 class SetResponseURLRequestContext: public net::TestURLRequestContext { |
| 60 public: | 60 public: |
| 61 void SetResponse(const std::string& headers, const std::string& response) { | 61 void SetResponse(const std::string& headers, const std::string& response) { |
| 62 std::unique_ptr<net::URLRequestJobFactoryImpl> factory = | 62 std::unique_ptr<net::URLRequestJobFactoryImpl> factory = |
| 63 base::WrapUnique(new net::URLRequestJobFactoryImpl()); | 63 base::MakeUnique<net::URLRequestJobFactoryImpl>(); |
| 64 factory->SetProtocolHandler( | 64 factory->SetProtocolHandler( |
| 65 "https", base::WrapUnique(new FakeProtocolHandler(headers, response))); | 65 "https", base::MakeUnique<FakeProtocolHandler>(headers, response)); |
| 66 context_storage_.set_job_factory(std::move(factory)); | 66 context_storage_.set_job_factory(std::move(factory)); |
| 67 } | 67 } |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 namespace remoting { | 72 namespace remoting { |
| 73 | 73 |
| 74 class TokenValidatorFactoryImplTest : public testing::Test { | 74 class TokenValidatorFactoryImplTest : public testing::Test { |
| 75 public: | 75 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 89 EXPECT_TRUE(shared_secret.empty()); | 89 EXPECT_TRUE(shared_secret.empty()); |
| 90 token_validator_.reset(); | 90 token_validator_.reset(); |
| 91 message_loop_.QuitWhenIdle(); | 91 message_loop_.QuitWhenIdle(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 protected: | 94 protected: |
| 95 void SetUp() override { | 95 void SetUp() override { |
| 96 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); | 96 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); |
| 97 request_context_getter_ = new net::TestURLRequestContextGetter( | 97 request_context_getter_ = new net::TestURLRequestContextGetter( |
| 98 message_loop_.task_runner(), | 98 message_loop_.task_runner(), |
| 99 base::WrapUnique(new SetResponseURLRequestContext())); | 99 base::MakeUnique<SetResponseURLRequestContext>()); |
| 100 ThirdPartyAuthConfig config; | 100 ThirdPartyAuthConfig config; |
| 101 config.token_url = GURL(kTokenUrl); | 101 config.token_url = GURL(kTokenUrl); |
| 102 config.token_validation_url = GURL(kTokenValidationUrl); | 102 config.token_validation_url = GURL(kTokenValidationUrl); |
| 103 config.token_validation_cert_issuer = kTokenValidationCertIssuer; | 103 config.token_validation_cert_issuer = kTokenValidationCertIssuer; |
| 104 token_validator_factory_ = new TokenValidatorFactoryImpl( | 104 token_validator_factory_ = new TokenValidatorFactoryImpl( |
| 105 config, key_pair_, request_context_getter_); | 105 config, key_pair_, request_context_getter_); |
| 106 } | 106 } |
| 107 | 107 |
| 108 static std::string CreateResponse(const std::string& scope) { | 108 static std::string CreateResponse(const std::string& scope) { |
| 109 base::DictionaryValue response_dict; | 109 base::DictionaryValue response_dict; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); | 183 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); |
| 184 | 184 |
| 185 token_validator_->ValidateThirdPartyToken( | 185 token_validator_->ValidateThirdPartyToken( |
| 186 kToken, base::Bind( | 186 kToken, base::Bind( |
| 187 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, | 187 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, |
| 188 base::Unretained(this))); | 188 base::Unretained(this))); |
| 189 base::RunLoop().Run(); | 189 base::RunLoop().Run(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 } // namespace remoting | 192 } // namespace remoting |
| OLD | NEW |