Rev 3419: merging 217650-auth-conf-robustness in http://code.launchpad.net/%7Evila/bzr/bzr.integration

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri May 9 16:56:36 BST 2008


At http://code.launchpad.net/%7Evila/bzr/bzr.integration

------------------------------------------------------------
revno: 3419
revision-id: v.ladeuil+lp at free.fr-20080509155614-fh29c44ifxke88xo
parent: pqm at pqm.ubuntu.com-20080508230313-knn3ibom6wt27w5k
parent: v.ladeuil+lp at free.fr-20080509083229-qkckif6lzloq3cau
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Fri 2008-05-09 17:56:14 +0200
message:
  merging 217650-auth-conf-robustness
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
    ------------------------------------------------------------
    revno: 3418.1.1
    revision-id: v.ladeuil+lp at free.fr-20080509083229-qkckif6lzloq3cau
    parent: pqm at pqm.ubuntu.com-20080508230313-knn3ibom6wt27w5k
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 217650-auth-conf-robustness
    timestamp: Fri 2008-05-09 10:32:29 +0200
    message:
      Fix #217650 by catching declarations outside sections.
      
      * bzrlib/tests/test_config.py:
      Split test_broken_config for a better defalt localization.
      (TestAuthenticationConfigFile.test_missing_auth_section_header):
      Test for declarations outside any section.
      
      * bzrlib/config.py:
      (AuthenticationConfig.get_credentials): Catch definitions outside
      sections.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
      bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-05-08 21:22:06 +0000
+++ b/NEWS	2008-05-09 08:32:29 +0000
@@ -42,6 +42,9 @@
     * ``bzr commit`` now works with Microsoft's FTP service.
       (Andreas Deininger)
 
+    * Catch definitions outside sections in authentication.conf.
+      (Vincent Ladeuil, #217650)
+
     * Conversion from non-rich-root to rich-root(-pack) updates inventory
       sha1s, even when bundles are used.  (Aaron Bentley, #181391)
 

=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2008-05-08 04:33:38 +0000
+++ b/bzrlib/config.py	2008-05-09 08:32:29 +0000
@@ -994,6 +994,9 @@
         """
         credentials = None
         for auth_def_name, auth_def in self._get_config().items():
+            if type(auth_def) is not configobj.Section:
+                raise ValueError("%s defined outside a section" % auth_def_name)
+
             a_scheme, a_host, a_user, a_path = map(
                 auth_def.get, ['scheme', 'host', 'user', 'path'])
 

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2008-05-01 04:09:39 +0000
+++ b/bzrlib/tests/test_config.py	2008-05-09 08:32:29 +0000
@@ -1195,10 +1195,15 @@
         self.assertEquals({}, conf._get_config())
         self._got_user_passwd(None, None, conf, 'http', 'foo.net')
 
-    def test_broken_config(self):
+    def test_missing_auth_section_header(self):
+        conf = config.AuthenticationConfig(_file=StringIO('foo = bar'))
+        self.assertRaises(ValueError, conf.get_credentials, 'ftp', 'foo.net')
+
+    def test_auth_section_header_not_closed(self):
         conf = config.AuthenticationConfig(_file=StringIO('[DEF'))
         self.assertRaises(errors.ParseConfigError, conf._get_config)
 
+    def test_auth_value_not_boolean(self):
         conf = config.AuthenticationConfig(_file=StringIO(
                 """[broken]
 scheme=ftp
@@ -1206,6 +1211,8 @@
 verify_certificates=askme # Error: Not a boolean
 """))
         self.assertRaises(ValueError, conf.get_credentials, 'ftp', 'foo.net')
+
+    def test_auth_value_not_int(self):
         conf = config.AuthenticationConfig(_file=StringIO(
                 """[broken]
 scheme=ftp



More information about the bazaar-commits mailing list