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 #include <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 } | 794 } |
795 | 795 |
796 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 796 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
797 NonInteractiveMintFailure) { | 797 NonInteractiveMintFailure) { |
798 SignIn("primary@example.com"); | 798 SignIn("primary@example.com"); |
799 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 799 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
800 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 800 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
801 func->set_mint_token_result(TestOAuth2MintTokenFlow::MINT_TOKEN_FAILURE); | 801 func->set_mint_token_result(TestOAuth2MintTokenFlow::MINT_TOKEN_FAILURE); |
802 std::string error = | 802 std::string error = |
803 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); | 803 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); |
804 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 804 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 805 base::CompareCase::INSENSITIVE_ASCII)); |
805 EXPECT_FALSE(func->login_ui_shown()); | 806 EXPECT_FALSE(func->login_ui_shown()); |
806 EXPECT_FALSE(func->scope_ui_shown()); | 807 EXPECT_FALSE(func->scope_ui_shown()); |
807 } | 808 } |
808 | 809 |
809 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 810 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
810 NonInteractiveLoginAccessTokenFailure) { | 811 NonInteractiveLoginAccessTokenFailure) { |
811 SignIn("primary@example.com"); | 812 SignIn("primary@example.com"); |
812 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 813 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
813 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 814 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
814 func->set_login_access_token_result(false); | 815 func->set_login_access_token_result(false); |
815 std::string error = utils::RunFunctionAndReturnError( | 816 std::string error = utils::RunFunctionAndReturnError( |
816 func.get(), "[{}]", browser()); | 817 func.get(), "[{}]", browser()); |
817 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 818 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 819 base::CompareCase::INSENSITIVE_ASCII)); |
818 } | 820 } |
819 | 821 |
820 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 822 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
821 NonInteractiveMintAdviceSuccess) { | 823 NonInteractiveMintAdviceSuccess) { |
822 SignIn("primary@example.com"); | 824 SignIn("primary@example.com"); |
823 scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); | 825 scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); |
824 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 826 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
825 func->set_extension(extension.get()); | 827 func->set_extension(extension.get()); |
826 func->set_mint_token_result(TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS); | 828 func->set_mint_token_result(TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS); |
827 std::string error = | 829 std::string error = |
828 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); | 830 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); |
829 EXPECT_EQ(std::string(errors::kNoGrant), error); | 831 EXPECT_EQ(std::string(errors::kNoGrant), error); |
830 EXPECT_FALSE(func->login_ui_shown()); | 832 EXPECT_FALSE(func->login_ui_shown()); |
831 EXPECT_FALSE(func->scope_ui_shown()); | 833 EXPECT_FALSE(func->scope_ui_shown()); |
832 | 834 |
833 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_ADVICE, | 835 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_ADVICE, |
834 GetCachedToken(std::string()).status()); | 836 GetCachedToken(std::string()).status()); |
835 } | 837 } |
836 | 838 |
837 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 839 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
838 NonInteractiveMintBadCredentials) { | 840 NonInteractiveMintBadCredentials) { |
839 SignIn("primary@example.com"); | 841 SignIn("primary@example.com"); |
840 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 842 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
841 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 843 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
842 func->set_mint_token_result( | 844 func->set_mint_token_result( |
843 TestOAuth2MintTokenFlow::MINT_TOKEN_BAD_CREDENTIALS); | 845 TestOAuth2MintTokenFlow::MINT_TOKEN_BAD_CREDENTIALS); |
844 std::string error = | 846 std::string error = |
845 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); | 847 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); |
846 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 848 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 849 base::CompareCase::INSENSITIVE_ASCII)); |
847 EXPECT_FALSE(func->login_ui_shown()); | 850 EXPECT_FALSE(func->login_ui_shown()); |
848 EXPECT_FALSE(func->scope_ui_shown()); | 851 EXPECT_FALSE(func->scope_ui_shown()); |
849 } | 852 } |
850 | 853 |
851 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 854 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
852 NonInteractiveMintServiceError) { | 855 NonInteractiveMintServiceError) { |
853 SignIn("primary@example.com"); | 856 SignIn("primary@example.com"); |
854 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 857 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
855 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 858 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
856 func->set_mint_token_result( | 859 func->set_mint_token_result( |
857 TestOAuth2MintTokenFlow::MINT_TOKEN_SERVICE_ERROR); | 860 TestOAuth2MintTokenFlow::MINT_TOKEN_SERVICE_ERROR); |
858 std::string error = | 861 std::string error = |
859 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); | 862 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); |
860 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 863 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 864 base::CompareCase::INSENSITIVE_ASCII)); |
861 EXPECT_FALSE(func->login_ui_shown()); | 865 EXPECT_FALSE(func->login_ui_shown()); |
862 EXPECT_FALSE(func->scope_ui_shown()); | 866 EXPECT_FALSE(func->scope_ui_shown()); |
863 } | 867 } |
864 | 868 |
865 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 869 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
866 NoOptionsSuccess) { | 870 NoOptionsSuccess) { |
867 SignIn("primary@example.com"); | 871 SignIn("primary@example.com"); |
868 #if defined(OS_WIN) && defined(USE_ASH) | 872 #if defined(OS_WIN) && defined(USE_ASH) |
869 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 873 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
870 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 874 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 } | 956 } |
953 | 957 |
954 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 958 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
955 InteractiveLoginSuccessMintFailure) { | 959 InteractiveLoginSuccessMintFailure) { |
956 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 960 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
957 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 961 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
958 func->set_login_ui_result(true); | 962 func->set_login_ui_result(true); |
959 func->set_mint_token_result(TestOAuth2MintTokenFlow::MINT_TOKEN_FAILURE); | 963 func->set_mint_token_result(TestOAuth2MintTokenFlow::MINT_TOKEN_FAILURE); |
960 std::string error = utils::RunFunctionAndReturnError( | 964 std::string error = utils::RunFunctionAndReturnError( |
961 func.get(), "[{\"interactive\": true}]", browser()); | 965 func.get(), "[{\"interactive\": true}]", browser()); |
962 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 966 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 967 base::CompareCase::INSENSITIVE_ASCII)); |
963 EXPECT_TRUE(func->login_ui_shown()); | 968 EXPECT_TRUE(func->login_ui_shown()); |
964 EXPECT_FALSE(func->scope_ui_shown()); | 969 EXPECT_FALSE(func->scope_ui_shown()); |
965 } | 970 } |
966 | 971 |
967 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 972 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
968 InteractiveLoginSuccessLoginAccessTokenFailure) { | 973 InteractiveLoginSuccessLoginAccessTokenFailure) { |
969 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 974 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
970 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 975 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
971 func->set_login_ui_result(true); | 976 func->set_login_ui_result(true); |
972 func->set_login_access_token_result(false); | 977 func->set_login_access_token_result(false); |
973 std::string error = utils::RunFunctionAndReturnError( | 978 std::string error = utils::RunFunctionAndReturnError( |
974 func.get(), "[{\"interactive\": true}]", browser()); | 979 func.get(), "[{\"interactive\": true}]", browser()); |
975 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 980 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 981 base::CompareCase::INSENSITIVE_ASCII)); |
976 EXPECT_TRUE(func->login_ui_shown()); | 982 EXPECT_TRUE(func->login_ui_shown()); |
977 EXPECT_FALSE(func->scope_ui_shown()); | 983 EXPECT_FALSE(func->scope_ui_shown()); |
978 } | 984 } |
979 | 985 |
980 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 986 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
981 InteractiveLoginSuccessMintSuccess) { | 987 InteractiveLoginSuccessMintSuccess) { |
982 // TODO(courage): verify that account_id in token service requests | 988 // TODO(courage): verify that account_id in token service requests |
983 // is correct once manual token minting for tests is implemented. | 989 // is correct once manual token minting for tests is implemented. |
984 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 990 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
985 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 991 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 | 1075 |
1070 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 1076 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
1071 InteractiveApprovalConnectionFailure) { | 1077 InteractiveApprovalConnectionFailure) { |
1072 SignIn("primary@example.com"); | 1078 SignIn("primary@example.com"); |
1073 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 1079 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
1074 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 1080 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
1075 func->set_mint_token_result(TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS); | 1081 func->set_mint_token_result(TestOAuth2MintTokenFlow::ISSUE_ADVICE_SUCCESS); |
1076 func->set_scope_ui_failure(GaiaWebAuthFlow::SERVICE_AUTH_ERROR); | 1082 func->set_scope_ui_failure(GaiaWebAuthFlow::SERVICE_AUTH_ERROR); |
1077 std::string error = utils::RunFunctionAndReturnError( | 1083 std::string error = utils::RunFunctionAndReturnError( |
1078 func.get(), "[{\"interactive\": true}]", browser()); | 1084 func.get(), "[{\"interactive\": true}]", browser()); |
1079 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 1085 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 1086 base::CompareCase::INSENSITIVE_ASCII)); |
1080 EXPECT_FALSE(func->login_ui_shown()); | 1087 EXPECT_FALSE(func->login_ui_shown()); |
1081 EXPECT_TRUE(func->scope_ui_shown()); | 1088 EXPECT_TRUE(func->scope_ui_shown()); |
1082 } | 1089 } |
1083 | 1090 |
1084 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 1091 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
1085 InteractiveApprovalOAuthErrors) { | 1092 InteractiveApprovalOAuthErrors) { |
1086 SignIn("primary@example.com"); | 1093 SignIn("primary@example.com"); |
1087 scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); | 1094 scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); |
1088 | 1095 |
1089 std::map<std::string, std::string> error_map; | 1096 std::map<std::string, std::string> error_map; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 SignIn("primary@example.com"); | 1498 SignIn("primary@example.com"); |
1492 IssueLoginRefreshTokenForAccount("secondary@example.com"); | 1499 IssueLoginRefreshTokenForAccount("secondary@example.com"); |
1493 SetAccountState(CreateIds("primary@example.com", "1"), true); | 1500 SetAccountState(CreateIds("primary@example.com", "1"), true); |
1494 SetAccountState(CreateIds("secondary@example.com", "2"), true); | 1501 SetAccountState(CreateIds("secondary@example.com", "2"), true); |
1495 | 1502 |
1496 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 1503 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
1497 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 1504 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
1498 func->set_mint_token_result(TestOAuth2MintTokenFlow::MINT_TOKEN_FAILURE); | 1505 func->set_mint_token_result(TestOAuth2MintTokenFlow::MINT_TOKEN_FAILURE); |
1499 std::string error = utils::RunFunctionAndReturnError( | 1506 std::string error = utils::RunFunctionAndReturnError( |
1500 func.get(), "[{\"account\": { \"id\": \"2\" } }]", browser()); | 1507 func.get(), "[{\"account\": { \"id\": \"2\" } }]", browser()); |
1501 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 1508 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 1509 base::CompareCase::INSENSITIVE_ASCII)); |
1502 EXPECT_FALSE(func->login_ui_shown()); | 1510 EXPECT_FALSE(func->login_ui_shown()); |
1503 EXPECT_FALSE(func->scope_ui_shown()); | 1511 EXPECT_FALSE(func->scope_ui_shown()); |
1504 } | 1512 } |
1505 | 1513 |
1506 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 1514 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
1507 MultiSecondaryNonInteractiveLoginAccessTokenFailure) { | 1515 MultiSecondaryNonInteractiveLoginAccessTokenFailure) { |
1508 SignIn("primary@example.com"); | 1516 SignIn("primary@example.com"); |
1509 IssueLoginRefreshTokenForAccount("secondary@example.com"); | 1517 IssueLoginRefreshTokenForAccount("secondary@example.com"); |
1510 SetAccountState(CreateIds("primary@example.com", "1"), true); | 1518 SetAccountState(CreateIds("primary@example.com", "1"), true); |
1511 SetAccountState(CreateIds("secondary@example.com", "2"), true); | 1519 SetAccountState(CreateIds("secondary@example.com", "2"), true); |
1512 | 1520 |
1513 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 1521 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
1514 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); | 1522 func->set_extension(CreateExtension(CLIENT_ID | SCOPES)); |
1515 func->set_login_access_token_result(false); | 1523 func->set_login_access_token_result(false); |
1516 std::string error = utils::RunFunctionAndReturnError( | 1524 std::string error = utils::RunFunctionAndReturnError( |
1517 func.get(), "[{\"account\": { \"id\": \"2\" } }]", browser()); | 1525 func.get(), "[{\"account\": { \"id\": \"2\" } }]", browser()); |
1518 EXPECT_TRUE(base::StartsWithASCII(error, errors::kAuthFailure, false)); | 1526 EXPECT_TRUE(base::StartsWith(error, errors::kAuthFailure, |
| 1527 base::CompareCase::INSENSITIVE_ASCII)); |
1519 } | 1528 } |
1520 | 1529 |
1521 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 1530 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
1522 MultiSecondaryInteractiveApprovalAborted) { | 1531 MultiSecondaryInteractiveApprovalAborted) { |
1523 SignIn("primary@example.com"); | 1532 SignIn("primary@example.com"); |
1524 IssueLoginRefreshTokenForAccount("secondary@example.com"); | 1533 IssueLoginRefreshTokenForAccount("secondary@example.com"); |
1525 SetAccountState(CreateIds("primary@example.com", "1"), true); | 1534 SetAccountState(CreateIds("primary@example.com", "1"), true); |
1526 SetAccountState(CreateIds("secondary@example.com", "2"), true); | 1535 SetAccountState(CreateIds("secondary@example.com", "2"), true); |
1527 | 1536 |
1528 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 1537 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1835 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1827 url); | 1836 url); |
1828 } | 1837 } |
1829 | 1838 |
1830 } // namespace extensions | 1839 } // namespace extensions |
1831 | 1840 |
1832 // Tests the chrome.identity API implemented by custom JS bindings . | 1841 // Tests the chrome.identity API implemented by custom JS bindings . |
1833 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1842 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1834 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1843 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1835 } | 1844 } |
OLD | NEW |