Changeset 84697 in webkit


Ignore:
Timestamp:
Apr 22, 2011 3:47:55 PM (13 years ago)
Author:
dbates@webkit.org
Message:

2011-04-22 Daniel Bates <dbates@webkit.org>

Reviewed by Csaba Osztrogonác.

webkit-patch land hangs if svn prompts for credentials
https://bugs.webkit.org/show_bug.cgi?id=31500

Make has_authorization_for_realm() return True only if there exists a credentials file
that contains either the word "password" or "passtype". We assume that these words don't
coincide with the actual credential data (e.g. a person's username is "password").

  • Scripts/webkitpy/common/checkout/scm.py:
  • Scripts/webkitpy/common/checkout/scm_unittest.py:
    • Added test cases: test_has_authorization_for_realm_using_credentials_with_passtype(), test_has_authorization_for_realm_using_credentials_with_password(), test_not_have_authorization_for_realm_with_credentials_missing_password_and_passtype()
    • Renamed test_not_have_authorization_for_realm() to test_not_have_authorization_for_realm_when_missing_credentials_file() to better describe what it's testing.
    • Repurposed test_has_authorization_for_realm() to take realm and credential data to use and return the result of calling has_authorization_for_realm() so that the caller can assert the result; Renamed to _test_has_authorization_for_realm_using_credentials() to better reflect its new purpose.
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r84692 r84697  
     12011-04-22  Daniel Bates  <dbates@webkit.org>
     2
     3        Reviewed by Csaba Osztrogonác.
     4
     5        webkit-patch land hangs if svn prompts for credentials
     6        https://bugs.webkit.org/show_bug.cgi?id=31500
     7
     8        Make has_authorization_for_realm() return True only if there exists a credentials file
     9        that contains either the word "password" or "passtype". We assume that these words don't
     10        coincide with the actual credential data (e.g. a person's username is "password").
     11
     12        * Scripts/webkitpy/common/checkout/scm.py:
     13        * Scripts/webkitpy/common/checkout/scm_unittest.py:
     14          - Added test cases:
     15            test_has_authorization_for_realm_using_credentials_with_passtype(),
     16            test_has_authorization_for_realm_using_credentials_with_password(),
     17            test_not_have_authorization_for_realm_with_credentials_missing_password_and_passtype()
     18          - Renamed test_not_have_authorization_for_realm() to test_not_have_authorization_for_realm_when_missing_credentials_file()
     19            to better describe what it's testing.
     20          - Repurposed test_has_authorization_for_realm() to take realm and credential data to use
     21            and return the result of calling has_authorization_for_realm() so that the caller can
     22            assert the result; Renamed to _test_has_authorization_for_realm_using_credentials() to
     23            better reflect its new purpose.
     24
    1252011-04-22  Adam Barth  <abarth@webkit.org>
    226
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm.py

    r84114 r84697  
    329329        find_args = ["find", ".subversion", "-type", "f", "-exec", "grep", "-q", realm, "{}", ";", "-print"]
    330330        find_output = self.run(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip()
    331         return find_output and os.path.isfile(os.path.join(home_directory, find_output))
     331        if not find_output or not os.path.isfile(os.path.join(home_directory, find_output)):
     332            return False
     333        # Subversion either stores the password in the credential file, indicated by the presence of the key "password",
     334        # or uses the system password store (e.g. Keychain on Mac OS X) as indicated by the presence of the key "passtype".
     335        # We assume that these keys will not coincide with the actual credential data (e.g. that a person's username
     336        # isn't "password") so that we can use grep.
     337        if self.run(["grep", "password", find_output], cwd=home_directory, return_exit_code=True) == 0:
     338            return True
     339        return self.run(["grep", "passtype", find_output], cwd=home_directory, return_exit_code=True) == 0
    332340
    333341
  • trunk/Tools/Scripts/webkitpy/common/checkout/scm_unittest.py

    r84114 r84697  
    11# Copyright (C) 2009 Google Inc. All rights reserved.
    22# Copyright (C) 2009 Apple Inc. All rights reserved.
     3# Copyright (C) 2011 Daniel Bates (dbates@intudata.com). All rights reserved.
    34#
    45# Redistribution and use in source and binary forms, with or without
     
    668669        self.assertRaises(AuthenticationError, self._shared_test_commit_with_message)
    669670
    670     def test_has_authorization_for_realm(self):
     671    def test_has_authorization_for_realm_using_credentials_with_passtype(self):
     672        credentials = """
     673K 8
     674passtype
     675V 8
     676keychain
     677K 15
     678svn:realmstring
     679V 39
     680<http://svn.webkit.org:80> Mac OS Forge
     681K 8
     682username
     683V 17
     684dbates@webkit.org
     685END
     686"""
     687        self.assertTrue(self._test_has_authorization_for_realm_using_credentials(SVN.svn_server_realm, credentials))
     688
     689    def test_has_authorization_for_realm_using_credentials_with_password(self):
     690        credentials = """
     691K 15
     692svn:realmstring
     693V 39
     694<http://svn.webkit.org:80> Mac OS Forge
     695K 8
     696username
     697V 17
     698dbates@webkit.org
     699K 8
     700password
     701V 4
     702blah
     703END
     704"""
     705        self.assertTrue(self._test_has_authorization_for_realm_using_credentials(SVN.svn_server_realm, credentials))
     706
     707    def _test_has_authorization_for_realm_using_credentials(self, realm, credentials):
    671708        scm = detect_scm_system(self.svn_checkout_path)
    672709        fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
     
    674711        os.mkdir(svn_config_dir_path)
    675712        fake_webkit_auth_file = os.path.join(svn_config_dir_path, "fake_webkit_auth_file")
    676         write_into_file_at_path(fake_webkit_auth_file, SVN.svn_server_realm)
    677         self.assertTrue(scm.has_authorization_for_realm(SVN.svn_server_realm, home_directory=fake_home_dir))
     713        write_into_file_at_path(fake_webkit_auth_file, credentials)
     714        result = scm.has_authorization_for_realm(realm, home_directory=fake_home_dir)
    678715        os.remove(fake_webkit_auth_file)
    679716        os.rmdir(svn_config_dir_path)
    680717        os.rmdir(fake_home_dir)
    681 
    682     def test_not_have_authorization_for_realm(self):
     718        return result
     719
     720    def test_not_have_authorization_for_realm_with_credentials_missing_password_and_passtype(self):
     721        credentials = """
     722K 15
     723svn:realmstring
     724V 39
     725<http://svn.webkit.org:80> Mac OS Forge
     726K 8
     727username
     728V 17
     729dbates@webkit.org
     730END
     731"""
     732        self.assertFalse(self._test_has_authorization_for_realm_using_credentials(SVN.svn_server_realm, credentials))
     733
     734    def test_not_have_authorization_for_realm_when_missing_credentials_file(self):
    683735        scm = detect_scm_system(self.svn_checkout_path)
    684736        fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
Note: See TracChangeset for help on using the changeset viewer.