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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 MockApiCallFlow(net::URLRequestContextGetter* context, | 86 MockApiCallFlow(net::URLRequestContextGetter* context, |
87 const std::string& refresh_token, | 87 const std::string& refresh_token, |
88 const std::string& access_token, | 88 const std::string& access_token, |
89 const std::vector<std::string>& scopes) | 89 const std::vector<std::string>& scopes) |
90 : OAuth2ApiCallFlow(context, refresh_token, access_token, scopes) {} | 90 : OAuth2ApiCallFlow(context, refresh_token, access_token, scopes) {} |
91 ~MockApiCallFlow() {} | 91 ~MockApiCallFlow() {} |
92 | 92 |
93 MOCK_METHOD0(CreateApiCallUrl, GURL ()); | 93 MOCK_METHOD0(CreateApiCallUrl, GURL ()); |
94 MOCK_METHOD0(CreateApiCallBody, std::string ()); | 94 MOCK_METHOD0(CreateApiCallBody, std::string ()); |
95 MOCK_METHOD1(ProcessApiCallSuccess, | 95 MOCK_METHOD1(ProcessApiCallSuccess, |
96 void (const content::URLFetcher* source)); | 96 void (const net::URLFetcher* source)); |
97 MOCK_METHOD1(ProcessApiCallFailure, | 97 MOCK_METHOD1(ProcessApiCallFailure, |
98 void (const content::URLFetcher* source)); | 98 void (const net::URLFetcher* source)); |
99 MOCK_METHOD1(ProcessNewAccessToken, | 99 MOCK_METHOD1(ProcessNewAccessToken, |
100 void (const std::string& access_token)); | 100 void (const std::string& access_token)); |
101 MOCK_METHOD1(ProcessMintAccessTokenFailure, | 101 MOCK_METHOD1(ProcessMintAccessTokenFailure, |
102 void (const GoogleServiceAuthError& error)); | 102 void (const GoogleServiceAuthError& error)); |
103 MOCK_METHOD0(CreateAccessTokenFetcher, OAuth2AccessTokenFetcher* ()); | 103 MOCK_METHOD0(CreateAccessTokenFetcher, OAuth2AccessTokenFetcher* ()); |
104 }; | 104 }; |
105 | 105 |
106 class OAuth2ApiCallFlowTest : public testing::Test { | 106 class OAuth2ApiCallFlowTest : public testing::Test { |
107 public: | 107 public: |
108 OAuth2ApiCallFlowTest() {} | 108 OAuth2ApiCallFlowTest() {} |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 scoped_ptr<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 |