Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Unified Diff: components/autofill/content/browser/wallet/real_pan_wallet_client_unittest.cc

Issue 1034873003: Another couple tests for RealPanWalletClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/browser/wallet/real_pan_wallet_client_unittest.cc
diff --git a/components/autofill/content/browser/wallet/real_pan_wallet_client_unittest.cc b/components/autofill/content/browser/wallet/real_pan_wallet_client_unittest.cc
index 8ed271572b945bc9121d1d9b3f7d4ded8fd2c7f4..92defc007f0ab789d31cac7c87a1bf3b7a3eb575 100644
--- a/components/autofill/content/browser/wallet/real_pan_wallet_client_unittest.cc
+++ b/components/autofill/content/browser/wallet/real_pan_wallet_client_unittest.cc
@@ -123,9 +123,7 @@ TEST_F(RealPanWalletClientTest, RetryFailure) {
EXPECT_EQ("", real_pan_);
}
-// TODO(estade): enable when https://codereview.chromium.org/1028313006/
-// lands.
-TEST_F(RealPanWalletClientTest, DISABLED_PermanentFailure) {
+TEST_F(RealPanWalletClientTest, PermanentFailure) {
StartUnmasking();
IssueOAuthToken();
ReturnResponse(net::HTTP_OK,
@@ -134,6 +132,50 @@ TEST_F(RealPanWalletClientTest, DISABLED_PermanentFailure) {
EXPECT_EQ("", real_pan_);
}
+TEST_F(RealPanWalletClientTest, MalformedResponse) {
+ StartUnmasking();
+ IssueOAuthToken();
+ ReturnResponse(net::HTTP_OK,
+ "{ \"error_code\": \"WRONG_JSON_FORMAT\" }");
+ EXPECT_EQ(AutofillClient::PERMANENT_FAILURE, result_);
+ EXPECT_EQ("", real_pan_);
+}
+
+TEST_F(RealPanWalletClientTest, ReauthNeeded) {
+ {
+ StartUnmasking();
+ IssueOAuthToken();
+ ReturnResponse(net::HTTP_UNAUTHORIZED, "");
+ // No response yet.
+ EXPECT_EQ(AutofillClient::SUCCESS, result_);
+ EXPECT_EQ("", real_pan_);
+
+ // Second HTTP_UNAUTHORIZED causes permanent failure.
+ IssueOAuthToken();
+ ReturnResponse(net::HTTP_UNAUTHORIZED, "");
+ EXPECT_EQ(AutofillClient::PERMANENT_FAILURE, result_);
+ EXPECT_EQ("", real_pan_);
+ }
+
+ result_ = AutofillClient::SUCCESS;
+ real_pan_.clear();
+
+ {
+ StartUnmasking();
+ IssueOAuthToken();
+ ReturnResponse(net::HTTP_UNAUTHORIZED, "");
+ // No response yet.
+ EXPECT_EQ(AutofillClient::SUCCESS, result_);
+ EXPECT_EQ("", real_pan_);
+
+ // HTTP_OK after first HTTP_UNAUTHORIZED results in success.
+ IssueOAuthToken();
+ ReturnResponse(net::HTTP_OK, "{ \"pan\": \"1234\" }");
+ EXPECT_EQ(AutofillClient::SUCCESS, result_);
+ EXPECT_EQ("1234", real_pan_);
+ }
+}
+
TEST_F(RealPanWalletClientTest, NetworkError) {
StartUnmasking();
IssueOAuthToken();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698