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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 token_validator_factory_.reset(new TokenValidatorFactoryImpl( | 101 token_validator_factory_.reset(new TokenValidatorFactoryImpl( |
102 config, key_pair_, request_context_getter_)); | 102 config, key_pair_, request_context_getter_)); |
103 } | 103 } |
104 | 104 |
105 static std::string CreateResponse(const std::string& scope) { | 105 static std::string CreateResponse(const std::string& scope) { |
106 base::DictionaryValue response_dict; | 106 base::DictionaryValue response_dict; |
107 response_dict.SetString("access_token", kSharedSecret); | 107 response_dict.SetString("access_token", kSharedSecret); |
108 response_dict.SetString("token_type", "shared_secret"); | 108 response_dict.SetString("token_type", "shared_secret"); |
109 response_dict.SetString("scope", scope); | 109 response_dict.SetString("scope", scope); |
110 std::string response; | 110 std::string response; |
111 base::JSONWriter::Write(&response_dict, &response); | 111 base::JSONWriter::Write(response_dict, &response); |
112 return response; | 112 return response; |
113 } | 113 } |
114 | 114 |
115 static std::string CreateErrorResponse(const std::string& error) { | 115 static std::string CreateErrorResponse(const std::string& error) { |
116 base::DictionaryValue response_dict; | 116 base::DictionaryValue response_dict; |
117 response_dict.SetString("error", error); | 117 response_dict.SetString("error", error); |
118 std::string response; | 118 std::string response; |
119 base::JSONWriter::Write(&response_dict, &response); | 119 base::JSONWriter::Write(response_dict, &response); |
120 return response; | 120 return response; |
121 } | 121 } |
122 | 122 |
123 | 123 |
124 void SetResponse(const std::string& headers, const std::string& response) { | 124 void SetResponse(const std::string& headers, const std::string& response) { |
125 SetResponseURLRequestContext* context = | 125 SetResponseURLRequestContext* context = |
126 static_cast<SetResponseURLRequestContext*>( | 126 static_cast<SetResponseURLRequestContext*>( |
127 request_context_getter_->GetURLRequestContext()); | 127 request_context_getter_->GetURLRequestContext()); |
128 context->SetResponse(headers, response); | 128 context->SetResponse(headers, response); |
129 } | 129 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); | 180 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); |
181 | 181 |
182 token_validator_->ValidateThirdPartyToken( | 182 token_validator_->ValidateThirdPartyToken( |
183 kToken, base::Bind( | 183 kToken, base::Bind( |
184 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, | 184 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, |
185 base::Unretained(this))); | 185 base::Unretained(this))); |
186 message_loop_.Run(); | 186 message_loop_.Run(); |
187 } | 187 } |
188 | 188 |
189 } // namespace remoting | 189 } // namespace remoting |
OLD | NEW |