From 19f3fe60b25a7e7e6efa0f2159143f45c3878a61 Mon Sep 17 00:00:00 2001 From: "vadimsh@chromium.org" Date: Mon, 20 Apr 2015 17:03:10 +0000 Subject: [PATCH] Enable OAuth2 by default. ClientLogin will be supposedly turned off on Apr 20. R=maruel@chromium.org BUG=356813 Review URL: https://codereview.chromium.org/1095033002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294899 0039d316-1c4b-4281-b951-d872f2087c98 --- .gitignore | 4 ---- auth.py | 10 +--------- tests/abandon.sh | 2 +- tests/basic.sh | 6 +++--- tests/git_cl_test.py | 3 +-- tests/owners.sh | 6 +++--- tests/patch.sh | 4 ++-- tests/post-dcommit-hook-test.sh | 2 +- tests/push-basic.sh | 6 +++--- tests/push-from-logs.sh | 8 ++++---- tests/rename.sh | 2 +- tests/save-description-on-failure.sh | 3 ++- tests/submit-from-new-dir.sh | 4 ++-- tests/submodule-merge-test.sh | 2 +- tests/upload-local-tracking-branch.sh | 2 +- tests/upload-stale.sh | 2 +- 16 files changed, 27 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 5061e26a7..4db19bfbb 100644 --- a/.gitignore +++ b/.gitignore @@ -46,7 +46,3 @@ /tests/subversion_config/servers /tests/svn/ /tests/svnrepo/ - -# Ignore "flag file" used by auth.py. -# TODO(vadimsh): Remove this once OAuth2 is default. -/USE_OAUTH2 diff --git a/auth.py b/auth.py index 15fc15deb..cc1b82b69 100644 --- a/auth.py +++ b/auth.py @@ -111,7 +111,7 @@ def make_auth_config( """ default = lambda val, d: val if val is not None else d return AuthConfig( - default(use_oauth2, _should_use_oauth2()), + default(use_oauth2, True), default(save_cookies, True), default(use_local_webserver, not _is_headless()), default(webserver_port, 8090), @@ -481,14 +481,6 @@ class Authenticator(object): ## Private functions. -def _should_use_oauth2(): - """Default value for use_oauth2 config option. - - Used to selectively enable OAuth2 by default. - """ - return os.path.exists(os.path.join(DEPOT_TOOLS_DIR, 'USE_OAUTH2')) - - def _is_headless(): """True if machine doesn't seem to have a display.""" return sys.platform == 'linux2' and not os.environ.get('DISPLAY') diff --git a/tests/abandon.sh b/tests/abandon.sh index da4cf7fb0..314f556b5 100755 --- a/tests/abandon.sh +++ b/tests/abandon.sh @@ -24,7 +24,7 @@ setup_gitsvn git add test; git commit -q -m "branch work" export GIT_EDITOR=$(which true) test_expect_success "upload succeeds" \ - "$GIT_CL upload -m test master | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test master | grep -q 'Issue created'" # Switch back to master, delete the branch. git checkout master diff --git a/tests/basic.sh b/tests/basic.sh index 85dedaee8..224d09792 100755 --- a/tests/basic.sh +++ b/tests/basic.sh @@ -21,7 +21,7 @@ setup_gitsvn git add test; git commit -q -m "branch work" test_expect_success "git-cl upload wants a server" \ - "$GIT_CL upload 2>&1 | grep -q 'You must configure'" + "$GIT_CL upload --no-oauth2 2>&1 | grep -q 'You must configure'" git config rietveld.server localhost:10000 @@ -32,7 +32,7 @@ setup_gitsvn export GIT_EDITOR=$(which true) test_expect_success "upload succeeds (needs a server running on localhost)" \ - "$GIT_CL upload -m test master | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test master | grep -q 'Issue created'" test_expect_success "git-cl status now knows the issue" \ "$GIT_CL_STATUS | grep -q 'Issue number'" @@ -46,7 +46,7 @@ setup_gitsvn $URL/edit test_expect_success "git-cl dcommits ok" \ - "$GIT_CL dcommit -f" + "$GIT_CL dcommit -f --no-oauth2" git checkout -q master git svn -q rebase >/dev/null 2>&1 diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 68be49f79..ed1d7a563 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -96,7 +96,6 @@ class TestGitCl(TestCase): self.mock(git_cl.upload, 'RealMain', self.fail) self.mock(git_cl.watchlists, 'Watchlists', WatchlistsMock) self.mock(git_cl.auth, 'get_authenticator_for_host', AuthenticatorMock) - self.mock(git_cl.auth, '_should_use_oauth2', lambda: False) # It's important to reset settings to not have inter-tests interference. git_cl.settings = None @@ -171,13 +170,13 @@ class TestGitCl(TestCase): ((['get_or_create_merge_base', 'master', 'master'],), 'fake_ancestor_sha'), ((['git', 'config', 'gerrit.host'],), ''), + ((['git', 'config', 'branch.master.rietveldissue'],), ''), ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ ((['git', 'rev-parse', '--show-cdup'],), ''), ((['git', 'rev-parse', 'HEAD'],), '12345'), ((['git', 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', '.'],), 'M\t.gitignore\n'), - ((['git', 'config', 'branch.master.rietveldissue'],), ''), ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), ((['git', 'log', '--pretty=format:%s%n%n%b', diff --git a/tests/owners.sh b/tests/owners.sh index 853fcf7f0..afe181082 100755 --- a/tests/owners.sh +++ b/tests/owners.sh @@ -30,16 +30,16 @@ END git add OWNERS PRESUBMIT.py ; git commit -q -m "add OWNERS" test_expect_success "upload succeeds (needs a server running on localhost)" \ - "$GIT_CL upload -m test master | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test master | grep -q 'Issue created'" test_expect_success "git-cl status has a suggested reviewer" \ "$GIT_CL_STATUS | grep -q 'R=ben@chromium.org'" test_expect_failure "git-cl dcommit fails w/ missing LGTM" \ - "$GIT_CL dcommit -f" + "$GIT_CL dcommit -f --no-oauth2" test_expect_success "git-cl dcommit --tbr succeeds" \ - "$GIT_CL dcommit --tbr -f | grep -q -- '--tbr was specified'" + "$GIT_CL dcommit --tbr -f --no-oauth2 | grep -q -- '--tbr was specified'" ) SUCCESS=$? diff --git a/tests/patch.sh b/tests/patch.sh index 22f6c211c..4306c02c7 100755 --- a/tests/patch.sh +++ b/tests/patch.sh @@ -24,7 +24,7 @@ setup_gitsvn export GIT_EDITOR=$(which true) test_expect_success "upload succeeds (needs a server running on localhost)" \ - "$GIT_CL upload -m test master | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test master | grep -q 'Issue created'" test_expect_success "git-cl status now knows the issue" \ "$GIT_CL_STATUS | grep -q 'Issue number'" @@ -33,7 +33,7 @@ setup_gitsvn git checkout -q -b test2 master - test_expect_success "$GIT_CL patch $ISSUE" + test_expect_success "$GIT_CL patch $ISSUE --no-oauth2" ) SUCCESS=$? diff --git a/tests/post-dcommit-hook-test.sh b/tests/post-dcommit-hook-test.sh index ec4e4d0ec..5ecb653fe 100755 --- a/tests/post-dcommit-hook-test.sh +++ b/tests/post-dcommit-hook-test.sh @@ -28,7 +28,7 @@ _EOF TBR=foo" test_expect_success "dcommitted code" \ - "$GIT_CL dcommit -f --bypass-hooks -m 'dcommit'" + "$GIT_CL dcommit --no-oauth2 -f --bypass-hooks -m 'dcommit'" test_expect_success "post-cl-dcommit hook executed" \ "git symbolic-ref HEAD | grep -q COMMITTED" diff --git a/tests/push-basic.sh b/tests/push-basic.sh index b68f8045b..e98d58fc4 100755 --- a/tests/push-basic.sh +++ b/tests/push-basic.sh @@ -21,7 +21,7 @@ setup_gitgit git add test; git commit -q -m "branch work" test_expect_success "git-cl upload wants a server" \ - "$GIT_CL upload 2>&1 | grep -q 'You must configure'" + "$GIT_CL upload --no-oauth2 2>&1 | grep -q 'You must configure'" git config rietveld.server localhost:10000 @@ -31,7 +31,7 @@ setup_gitgit # Prevent the editor from coming up when you upload. export GIT_EDITOR=$(which true) test_expect_success "upload succeeds (needs a server running on localhost)" \ - "$GIT_CL upload -m test master | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test master | grep -q 'Issue created'" test_expect_success "git-cl status now knows the issue" \ "$GIT_CL_STATUS | grep -q 'Issue number'" @@ -48,7 +48,7 @@ setup_gitgit "curl -s $($GIT_CL_STATUS --field=url) | grep 'URL:[[:space:]]*[^<]' | grep -q '@master'" test_expect_success "git-cl land ok" \ - "$GIT_CL land -f" + "$GIT_CL land -f --no-oauth2" git checkout -q master > /dev/null 2>&1 git pull -q > /dev/null 2>&1 diff --git a/tests/push-from-logs.sh b/tests/push-from-logs.sh index 0fef2a7d2..f835c778b 100755 --- a/tests/push-from-logs.sh +++ b/tests/push-from-logs.sh @@ -21,7 +21,7 @@ setup_gitgit git add test; git commit -q -m "branch work" test_expect_success "git-cl upload wants a server" \ - "$GIT_CL upload 2>&1 | grep -q 'You must configure'" + "$GIT_CL upload --no-oauth2 2>&1 | grep -q 'You must configure'" git config rietveld.server localhost:10000 @@ -31,7 +31,7 @@ setup_gitgit # Prevent the editor from coming up when you upload. export EDITOR=$(which true) test_expect_success "upload succeeds (needs a server running on localhost)" \ - "$GIT_CL upload -m test master | \ + "$GIT_CL upload --no-oauth2 -m test master | \ grep -q 'Issue created'" test_expect_success "git-cl status now knows the issue" \ @@ -41,13 +41,13 @@ setup_gitgit # Should contain 'branch work' x 2. test_expect_success "git-cl status has the right description for the log" \ "$GIT_CL_STATUS --field desc | [ $( egrep -q '^branch work$' -c ) -eq 2 ] - + test_expect_success "git-cl status has the right subject from message" \ "$GIT_CL_STATUS --field desc | \ [ $( egrep -q '^test$' --byte-offset) | grep '^0:' ] test_expect_success "git-cl push ok" \ - "$GIT_CL push -f" + "$GIT_CL push -f --no-oauth2" git checkout -q master > /dev/null 2>&1 git pull -q > /dev/null 2>&1 diff --git a/tests/rename.sh b/tests/rename.sh index b16bea104..9b5d6dd07 100755 --- a/tests/rename.sh +++ b/tests/rename.sh @@ -24,7 +24,7 @@ setup_gitsvn git commit -q -m "renamed" export GIT_EDITOR=$(which true) test_expect_success "upload succeeds" \ - "$GIT_CL upload -m test master | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test master | grep -q 'Issue created'" # Look at the uploaded patch and verify it is a rename patch. echo "Rename test not fully implemented yet. :(" diff --git a/tests/save-description-on-failure.sh b/tests/save-description-on-failure.sh index 35846885a..1297fa02c 100755 --- a/tests/save-description-on-failure.sh +++ b/tests/save-description-on-failure.sh @@ -34,7 +34,8 @@ setup_gitgit # Try to upload the change to an unresolvable hostname; git-cl should fail. export GIT_EDITOR=$(which true) git config rietveld.server bogus.example.com:80 - test_expect_failure "uploading to bogus server" "$GIT_CL upload 2>/dev/null" + test_expect_failure "uploading to bogus server" \ + "$GIT_CL upload --no-oauth2 2>/dev/null" # Check that the change's description was saved. test_expect_success "description was backed up" \ diff --git a/tests/submit-from-new-dir.sh b/tests/submit-from-new-dir.sh index f04d9dc22..063568a22 100755 --- a/tests/submit-from-new-dir.sh +++ b/tests/submit-from-new-dir.sh @@ -28,9 +28,9 @@ setup_gitsvn git add test; git commit -q -m "branch work" export GIT_EDITOR=$(which true) test_expect_success "upload succeeds" \ - "$GIT_CL upload -m test master | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test master | grep -q 'Issue created'" test_expect_success "git-cl dcommits ok" \ - "$GIT_CL dcommit -f" + "$GIT_CL dcommit -f --no-oauth2" ) SUCCESS=$? diff --git a/tests/submodule-merge-test.sh b/tests/submodule-merge-test.sh index 2dc49ea23..a703958f4 100755 --- a/tests/submodule-merge-test.sh +++ b/tests/submodule-merge-test.sh @@ -27,7 +27,7 @@ TBR=foo" git_diff=`git diff HEAD^ | sed -n '/^@@/,$p' | xargs` test_expect_success "dcommitted code" \ - "$GIT_CL dcommit -f --bypass-hooks -m 'dcommit'" + "$GIT_CL dcommit --no-oauth2 -f --bypass-hooks -m 'dcommit'" cd .. diff --git a/tests/upload-local-tracking-branch.sh b/tests/upload-local-tracking-branch.sh index 0efd6e0e4..8c2e6fb80 100755 --- a/tests/upload-local-tracking-branch.sh +++ b/tests/upload-local-tracking-branch.sh @@ -24,7 +24,7 @@ setup_gitgit # Prevent the editor from coming up when you upload. export GIT_EDITOR=$(which true) test_expect_success "upload succeeds (needs a server running on localhost)" \ - "$GIT_CL upload -m test | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test | grep -q 'Issue created'" ) SUCCESS=$? diff --git a/tests/upload-stale.sh b/tests/upload-stale.sh index 72d1ad3fa..3ce6141dc 100755 --- a/tests/upload-stale.sh +++ b/tests/upload-stale.sh @@ -23,7 +23,7 @@ setup_gitgit # Prevent the editor from coming up when you upload. export GIT_EDITOR=$(which true) test_expect_success "upload succeeds (needs a server running on localhost)" \ - "$GIT_CL upload -m test | grep -q 'Issue created'" + "$GIT_CL upload --no-oauth2 -m test | grep -q 'Issue created'" test_expect_failure "description shouldn't contain unrelated commits" \ "$GIT_CL_STATUS | grep -q 'second commit'"