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/values.h" | 10 #include "base/values.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 static std::string CreateErrorResponse(const std::string& error) { | 76 static std::string CreateErrorResponse(const std::string& error) { |
77 DictionaryValue response_dict; | 77 DictionaryValue response_dict; |
78 response_dict.SetString("error", error); | 78 response_dict.SetString("error", error); |
79 std::string response; | 79 std::string response; |
80 base::JSONWriter::Write(&response_dict, &response); | 80 base::JSONWriter::Write(&response_dict, &response); |
81 return response; | 81 return response; |
82 } | 82 } |
83 | 83 |
84 MessageLoop message_loop_; | 84 base::MessageLoop message_loop_; |
85 scoped_refptr<RsaKeyPair> key_pair_; | 85 scoped_refptr<RsaKeyPair> key_pair_; |
86 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 86 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
87 scoped_ptr<TokenValidatorFactoryImpl> token_validator_factory_; | 87 scoped_ptr<TokenValidatorFactoryImpl> token_validator_factory_; |
88 scoped_ptr<protocol::ThirdPartyHostAuthenticator::TokenValidator> | 88 scoped_ptr<protocol::ThirdPartyHostAuthenticator::TokenValidator> |
89 token_validator_; | 89 token_validator_; |
90 }; | 90 }; |
91 | 91 |
92 TEST_F(TokenValidatorFactoryImplTest, Success) { | 92 TEST_F(TokenValidatorFactoryImplTest, Success) { |
93 net::FakeURLFetcherFactory factory(NULL); | 93 net::FakeURLFetcherFactory factory(NULL); |
94 token_validator_ = token_validator_factory_->CreateTokenValidator( | 94 token_validator_ = token_validator_factory_->CreateTokenValidator( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 kLocalJid, kRemoteJid); | 129 kLocalJid, kRemoteJid); |
130 factory.SetFakeResponse(kTokenValidationUrl, std::string(), false); | 130 factory.SetFakeResponse(kTokenValidationUrl, std::string(), false); |
131 token_validator_->ValidateThirdPartyToken( | 131 token_validator_->ValidateThirdPartyToken( |
132 kToken, base::Bind( | 132 kToken, base::Bind( |
133 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, | 133 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, |
134 base::Unretained(this))); | 134 base::Unretained(this))); |
135 message_loop_.Run(); | 135 message_loop_.Run(); |
136 } | 136 } |
137 | 137 |
138 } // namespace remoting | 138 } // namespace remoting |
OLD | NEW |