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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 MOCK_METHOD1(ProcessNewAccessToken, | 102 MOCK_METHOD1(ProcessNewAccessToken, |
103 void (const std::string& access_token)); | 103 void (const std::string& access_token)); |
104 MOCK_METHOD1(ProcessMintAccessTokenFailure, | 104 MOCK_METHOD1(ProcessMintAccessTokenFailure, |
105 void (const GoogleServiceAuthError& error)); | 105 void (const GoogleServiceAuthError& error)); |
106 MOCK_METHOD0(CreateAccessTokenFetcher, OAuth2AccessTokenFetcher* ()); | 106 MOCK_METHOD0(CreateAccessTokenFetcher, OAuth2AccessTokenFetcher* ()); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace | 109 } // namespace |
110 | 110 |
111 class OAuth2ApiCallFlowTest : public testing::Test { | 111 class OAuth2ApiCallFlowTest : public testing::Test { |
112 public: | |
113 OAuth2ApiCallFlowTest() {} | |
114 virtual ~OAuth2ApiCallFlowTest() {} | |
115 | |
116 protected: | 112 protected: |
117 void SetupAccessTokenFetcher( | 113 void SetupAccessTokenFetcher( |
118 const std::string& rt, const std::vector<std::string>& scopes) { | 114 const std::string& rt, const std::vector<std::string>& scopes) { |
119 EXPECT_CALL(*access_token_fetcher_, | 115 EXPECT_CALL(*access_token_fetcher_, |
120 Start(GaiaUrls::GetInstance()->oauth2_chrome_client_id(), | 116 Start(GaiaUrls::GetInstance()->oauth2_chrome_client_id(), |
121 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), | 117 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), |
122 rt, scopes)) | 118 rt, scopes)) |
123 .Times(1); | 119 .Times(1); |
124 EXPECT_CALL(*flow_, CreateAccessTokenFetcher()) | 120 EXPECT_CALL(*flow_, CreateAccessTokenFetcher()) |
125 .WillOnce(Return(access_token_fetcher_.release())); | 121 .WillOnce(Return(access_token_fetcher_.release())); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 scoped_ptr<TestURLFetcher> url_fetcher(SetupApiCall(true, net::HTTP_OK)); | 289 scoped_ptr<TestURLFetcher> url_fetcher(SetupApiCall(true, net::HTTP_OK)); |
294 flow_->CreateURLFetcher(); | 290 flow_->CreateURLFetcher(); |
295 HttpRequestHeaders headers; | 291 HttpRequestHeaders headers; |
296 url_fetcher->GetExtraRequestHeaders(&headers); | 292 url_fetcher->GetExtraRequestHeaders(&headers); |
297 std::string auth_header; | 293 std::string auth_header; |
298 EXPECT_TRUE(headers.GetHeader("Authorization", &auth_header)); | 294 EXPECT_TRUE(headers.GetHeader("Authorization", &auth_header)); |
299 EXPECT_EQ("Bearer access_token", auth_header); | 295 EXPECT_EQ("Bearer access_token", auth_header); |
300 EXPECT_EQ(url, url_fetcher->GetOriginalURL()); | 296 EXPECT_EQ(url, url_fetcher->GetOriginalURL()); |
301 EXPECT_EQ(body, url_fetcher->upload_data()); | 297 EXPECT_EQ(body, url_fetcher->upload_data()); |
302 } | 298 } |
OLD | NEW |