OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 complete set of unit tests for OAuth2MintTokenFlow. | 5 // A complete set of unit tests for OAuth2MintTokenFlow. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 270 } |
271 | 271 |
272 TEST_F(OAuth2ApiCallFlowTest, CreateURLFetcher) { | 272 TEST_F(OAuth2ApiCallFlowTest, CreateURLFetcher) { |
273 std::string rt = "refresh_token"; | 273 std::string rt = "refresh_token"; |
274 std::string at = "access_token"; | 274 std::string at = "access_token"; |
275 std::vector<std::string> scopes(CreateTestScopes()); | 275 std::vector<std::string> scopes(CreateTestScopes()); |
276 std::string body = CreateBody(); | 276 std::string body = CreateBody(); |
277 GURL url(CreateApiUrl()); | 277 GURL url(CreateApiUrl()); |
278 | 278 |
279 CreateFlow(rt, at, scopes); | 279 CreateFlow(rt, at, scopes); |
280 TestURLFetcher* url_fetcher = SetupApiCall(true, net::HTTP_OK); | 280 scoped_ptr<TestURLFetcher> url_fetcher(SetupApiCall(true, net::HTTP_OK)); |
281 flow_->CreateURLFetcher(); | 281 flow_->CreateURLFetcher(); |
282 HttpRequestHeaders headers; | 282 HttpRequestHeaders headers; |
283 url_fetcher->GetExtraRequestHeaders(&headers); | 283 url_fetcher->GetExtraRequestHeaders(&headers); |
284 std::string auth_header; | 284 std::string auth_header; |
285 EXPECT_TRUE(headers.GetHeader("Authorization", &auth_header)); | 285 EXPECT_TRUE(headers.GetHeader("Authorization", &auth_header)); |
286 EXPECT_EQ("Bearer access_token", auth_header); | 286 EXPECT_EQ("Bearer access_token", auth_header); |
287 EXPECT_EQ(url, url_fetcher->GetOriginalURL()); | 287 EXPECT_EQ(url, url_fetcher->GetOriginalURL()); |
288 EXPECT_EQ(body, url_fetcher->upload_data()); | 288 EXPECT_EQ(body, url_fetcher->upload_data()); |
289 } | 289 } |
OLD | NEW |