| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/test/launcher/unit_test_launcher.h" | 9 #include "base/test/launcher/unit_test_launcher.h" |
| 10 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 " https://www.googleapis.com/auth/googletalk" | 33 " https://www.googleapis.com/auth/googletalk" |
| 34 " https://www.googleapis.com/auth/userinfo.email" | 34 " https://www.googleapis.com/auth/userinfo.email" |
| 35 " https://docs.google.com/feeds" | 35 " https://docs.google.com/feeds" |
| 36 " https://www.googleapis.com/auth/drive"; | 36 " https://www.googleapis.com/auth/drive"; |
| 37 | 37 |
| 38 std::string GetAuthorizationCodeUri() { | 38 std::string GetAuthorizationCodeUri() { |
| 39 // Replace space characters with a '+' sign when formatting. | 39 // Replace space characters with a '+' sign when formatting. |
| 40 bool use_plus = true; | 40 bool use_plus = true; |
| 41 return base::StringPrintf( | 41 return base::StringPrintf( |
| 42 "https://accounts.google.com/o/oauth2/auth" | 42 "https://accounts.google.com/o/oauth2/auth" |
| 43 "?scope=%s" | 43 "?scope=%s" |
| 44 "&redirect_uri=https://chromoting-oauth.talkgadget.google.com/" | 44 "&redirect_uri=https://chromoting-oauth.talkgadget.google.com/" |
| 45 "talkgadget/oauth/chrome-remote-desktop/dev" | 45 "talkgadget/oauth/chrome-remote-desktop/dev" |
| 46 "&response_type=code" | 46 "&response_type=code" |
| 47 "&client_id=%s" | 47 "&client_id=%s" |
| 48 "&access_type=offline" | 48 "&access_type=offline" |
| 49 "&approval_prompt=force", | 49 "&approval_prompt=force", |
| 50 net::EscapeUrlEncodedData(kAppRemotingAuthScopeValues, use_plus).c_str(), | 50 net::EscapeUrlEncodedData(kAppRemotingAuthScopeValues, use_plus).c_str(), |
| 51 net::EscapeUrlEncodedData(google_apis::GetOAuth2ClientID( | 51 net::EscapeUrlEncodedData( |
| 52 google_apis::CLIENT_REMOTING), use_plus).c_str()); | 52 google_apis::GetOAuth2ClientID(google_apis::CLIENT_REMOTING), |
| 53 use_plus).c_str()); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void PrintUsage() { | 56 void PrintUsage() { |
| 56 printf("\n**************************************\n"); | 57 printf("\n**************************************\n"); |
| 57 printf("*** App Remoting Test Driver Usage ***\n"); | 58 printf("*** App Remoting Test Driver Usage ***\n"); |
| 58 printf("**************************************\n"); | 59 printf("**************************************\n"); |
| 59 | 60 |
| 60 printf("\nUsage:\n"); | 61 printf("\nUsage:\n"); |
| 61 printf(" ar_test_driver --username=<example@gmail.com> [options]\n"); | 62 printf(" ar_test_driver --username=<example@gmail.com> [options]\n"); |
| 62 printf("\nRequired Parameters:\n"); | 63 printf("\nRequired Parameters:\n"); |
| 63 printf(" %s: Specifies which account to use when running tests\n", | 64 printf(" %s: Specifies which account to use when running tests\n", |
| 64 switches::kUserNameSwitchName); | 65 switches::kUserNameSwitchName); |
| 65 printf("\nOptional Parameters:\n"); | 66 printf("\nOptional Parameters:\n"); |
| 66 printf(" %s: Exchanged for a refresh and access token for authentication\n", | 67 printf(" %s: Exchanged for a refresh and access token for authentication\n", |
| 67 switches::kAuthCodeSwitchName); | 68 switches::kAuthCodeSwitchName); |
| 68 printf(" %s: Displays additional usage information\n", | 69 printf(" %s: Displays additional usage information\n", |
| 69 switches::kHelpSwitchName); | 70 switches::kHelpSwitchName); |
| 70 printf(" %s: Specifies the service api to use (dev|test) [default: dev]\n", | 71 printf(" %s: Specifies the service api to use (dev|test) [default: dev]\n", |
| 71 switches::kServiceEnvironmentSwitchName); | 72 switches::kServiceEnvironmentSwitchName); |
| 72 printf(" %s: Retrieves and displays the connection status for all known " | 73 printf( |
| 73 "hosts, no tests will be run\n", | 74 " %s: Retrieves and displays the connection status for all known " |
| 74 switches::kShowHostAvailabilitySwitchName); | 75 "hosts, no tests will be run\n", |
| 75 printf(" %s: Specifies the optional logging level of the tool (0-3)." | 76 switches::kShowHostAvailabilitySwitchName); |
| 76 " [default: off]\n", | 77 printf( |
| 77 switches::kLoggingLevelSwitchName); | 78 " %s: Specifies the optional logging level of the tool (0-3)." |
| 79 " [default: off]\n", |
| 80 switches::kLoggingLevelSwitchName); |
| 78 } | 81 } |
| 79 | 82 |
| 80 void PrintAuthCodeInfo() { | 83 void PrintAuthCodeInfo() { |
| 81 printf("\n*******************************\n"); | 84 printf("\n*******************************\n"); |
| 82 printf("*** Auth Code Example Usage ***\n"); | 85 printf("*** Auth Code Example Usage ***\n"); |
| 83 printf("*******************************\n\n"); | 86 printf("*******************************\n\n"); |
| 84 | 87 |
| 85 printf("If this is the first time you are running the tool,\n"); | 88 printf("If this is the first time you are running the tool,\n"); |
| 86 printf("you will need to provide an authorization code.\n"); | 89 printf("you will need to provide an authorization code.\n"); |
| 87 printf("This code will be exchanged for a long term refresh token which\n"); | 90 printf("This code will be exchanged for a long term refresh token which\n"); |
| 88 printf("will be stored locally and used to acquire a short lived access\n"); | 91 printf("will be stored locally and used to acquire a short lived access\n"); |
| 89 printf("token to connect to the remoting service apis and establish a\n"); | 92 printf("token to connect to the remoting service apis and establish a\n"); |
| 90 printf("remote host connection.\n\n"); | 93 printf("remote host connection.\n\n"); |
| 91 | 94 |
| 92 printf("Note: You may need to repeat this step if the stored refresh token"); | 95 printf("Note: You may need to repeat this step if the stored refresh token"); |
| 93 printf("\n has been revoked or expired.\n"); | 96 printf("\n has been revoked or expired.\n"); |
| 94 printf(" Passing in the same auth code twice will result in an error\n"); | 97 printf(" Passing in the same auth code twice will result in an error\n"); |
| 95 | 98 |
| 96 printf("\nFollow these steps to produce an auth code:\n" | 99 printf( |
| 97 " - Open the Authorization URL link shown below in your browser\n" | 100 "\nFollow these steps to produce an auth code:\n" |
| 98 " - Approve the requested permissions for the tool\n" | 101 " - Open the Authorization URL link shown below in your browser\n" |
| 99 " - Copy the 'code' value in the redirected URL\n" | 102 " - Approve the requested permissions for the tool\n" |
| 100 " - Run the tool and pass in copied auth code as a parameter\n"); | 103 " - Copy the 'code' value in the redirected URL\n" |
| 104 " - Run the tool and pass in copied auth code as a parameter\n"); |
| 101 | 105 |
| 102 printf("\nAuthorization URL:\n"); | 106 printf("\nAuthorization URL:\n"); |
| 103 printf("%s\n", GetAuthorizationCodeUri().c_str()); | 107 printf("%s\n", GetAuthorizationCodeUri().c_str()); |
| 104 | 108 |
| 105 printf("\nRedirected URL Example:\n"); | 109 printf("\nRedirected URL Example:\n"); |
| 106 printf("https://chromoting-oauth.talkgadget.google.com/talkgadget/oauth/" | 110 printf( |
| 107 "chrome-remote-desktop/dev?code=4/AKtf...\n"); | 111 "https://chromoting-oauth.talkgadget.google.com/talkgadget/oauth/" |
| 112 "chrome-remote-desktop/dev?code=4/AKtf...\n"); |
| 108 | 113 |
| 109 printf("\nTool usage example with the newly created auth code:\n"); | 114 printf("\nTool usage example with the newly created auth code:\n"); |
| 110 printf("ar_test_driver --%s=example@gmail.com --%s=4/AKtf...\n\n", | 115 printf("ar_test_driver --%s=example@gmail.com --%s=4/AKtf...\n\n", |
| 111 switches::kUserNameSwitchName, switches::kAuthCodeSwitchName); | 116 switches::kUserNameSwitchName, switches::kAuthCodeSwitchName); |
| 112 } | 117 } |
| 113 | 118 |
| 114 } // namespace | 119 } // namespace |
| 115 | 120 |
| 116 int main(int argc, char** argv) { | 121 int main(int argc, char** argv) { |
| 117 testing::InitGoogleTest(&argc, argv); | 122 testing::InitGoogleTest(&argc, argv); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // value to our global* and transfer ownership to the framework. | 223 // value to our global* and transfer ownership to the framework. |
| 219 remoting::test::AppRemotingSharedData = shared_data.release(); | 224 remoting::test::AppRemotingSharedData = shared_data.release(); |
| 220 testing::AddGlobalTestEnvironment(remoting::test::AppRemotingSharedData); | 225 testing::AddGlobalTestEnvironment(remoting::test::AppRemotingSharedData); |
| 221 | 226 |
| 222 // Because many tests may access the same remoting host(s), we need to run | 227 // Because many tests may access the same remoting host(s), we need to run |
| 223 // the tests sequentially so they do not interfere with each other. | 228 // the tests sequentially so they do not interfere with each other. |
| 224 return base::LaunchUnitTestsSerially( | 229 return base::LaunchUnitTestsSerially( |
| 225 argc, argv, | 230 argc, argv, |
| 226 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); | 231 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); |
| 227 } | 232 } |
| OLD | NEW |