Rev 4150: Provides all request parameters to authentication providers in http://bazaar.launchpad.net/%7Evila/bzr/bzr.integration
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Mar 16 12:36:43 GMT 2009
At http://bazaar.launchpad.net/%7Evila/bzr/bzr.integration
------------------------------------------------------------
revno: 4150
revision-id: v.ladeuil+lp at free.fr-20090316123531-9r9dk2awewft7efi
parent: pqm at pqm.ubuntu.com-20090316082629-xuzqut3b3ur5bn3b
parent: v.ladeuil+lp at free.fr-20090313041051-ese5rdqlno7ybped
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: bzr.integration
timestamp: Mon 2009-03-16 13:35:31 +0100
message:
Provides all request parameters to authentication providers
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
------------------------------------------------------------
revno: 4107.1.12
revision-id: v.ladeuil+lp at free.fr-20090313041051-ese5rdqlno7ybped
parent: jeanfrancois at apple.com-20090313030033-sznp7sfhpc869php
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: authconfig-provider
timestamp: Fri 2009-03-13 14:10:51 +1000
message:
Easier patched than said :)
* bzrlib/plugins/netrc_credential_store/tests/test_netrc.py:
Fix cStringIO import.
(TestNetrcCS.test_get_netrc_credentials_via_auth_config): Create
the AuthenticationConfig locally.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4107.1.11
revision-id: jeanfrancois at apple.com-20090313030033-sznp7sfhpc869php
parent: jeanfrancois at apple.com-20090313030028-whrbh7zc4657owyx
parent: jeanfrancois at apple.com-20090313025946-m9yr79l1bdlawb3w
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Thu 2009-03-12 20:00:33 -0700
message:
Merge from netrc AuthenticationConfig test branch.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4137.2.2
revision-id: jeanfrancois at apple.com-20090313025946-m9yr79l1bdlawb3w
parent: jeanfrancois at apple.com-20090313025837-r0e28h6xczqvr9ny
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: netrc-tests-fix
timestamp: Thu 2009-03-12 19:59:46 -0700
message:
Use assertEquals, not assertIs in test_get_credentials.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4107.1.10
revision-id: jeanfrancois at apple.com-20090313030028-whrbh7zc4657owyx
parent: jeanfrancois at apple.com-20090313024549-izyvizmriham3g30
parent: jeanfrancois at apple.com-20090313025837-r0e28h6xczqvr9ny
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Thu 2009-03-12 20:00:28 -0700
message:
Merge from netrc AuthenticationConfig test branch.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4137.2.1
revision-id: jeanfrancois at apple.com-20090313025837-r0e28h6xczqvr9ny
parent: pqm at pqm.ubuntu.com-20090312152735-08tf1fguf6b7mpaw
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: netrc-tests-fix
timestamp: Thu 2009-03-12 19:58:37 -0700
message:
Added new netrc crendential store plug-in test to verify its usage through get_credentials.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4107.1.9
revision-id: jeanfrancois at apple.com-20090313024549-izyvizmriham3g30
parent: jeanfrancois at apple.com-20090313024046-80qx69ppgqbhhzoq
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Thu 2009-03-12 19:45:49 -0700
message:
Reverted the chages made to the netrc tests for this patch.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4107.1.8
revision-id: jeanfrancois at apple.com-20090313024046-80qx69ppgqbhhzoq
parent: jeanfrancois at apple.com-20090313022839-e9t39iby5sln5s1m
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Thu 2009-03-12 19:40:46 -0700
message:
Updated test_config to account for the new credentials keys.
modified:
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
------------------------------------------------------------
revno: 4107.1.7
revision-id: jeanfrancois at apple.com-20090313022839-e9t39iby5sln5s1m
parent: jeanfrancois at apple.com-20090313020921-p43tex9isioqnrm3
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Thu 2009-03-12 19:28:39 -0700
message:
No longer deleting the extra credentials keys in get_credentials.
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
------------------------------------------------------------
revno: 4107.1.6
revision-id: jeanfrancois at apple.com-20090313020921-p43tex9isioqnrm3
parent: jeanfrancois at apple.com-20090311171127-1r7957lprlaxwi4e
parent: pqm at pqm.ubuntu.com-20090312152735-08tf1fguf6b7mpaw
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Thu 2009-03-12 19:09:21 -0700
message:
Merged in bzr.dev.
removed:
bzrlib/help_topics/en/hooks.txt hooks.txt-20070830033044-xxu2rced13f72dka-1
added:
tools/check-newsbugs.py checknewsbugs.py-20090128204947-lsdwd8nlswm1yrwv-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzr bzr.py-20050313053754-5485f144c7006fa6
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/bugtracker.py bugtracker.py-20070410073305-vu1vu1qosjurg8kb-1
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/commands.py bzr.py-20050309040720-d10f4714595cf8c3
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
bzrlib/hooks.py hooks.py-20070325015548-ix4np2q0kd8452au-1
bzrlib/inventory.py inventory.py-20050309040759-6648b84ca2005b37
bzrlib/knit.py knit.py-20051212171256-f056ac8f0fbe1bd9
bzrlib/lock.py lock.py-20050527050856-ec090bb51bc03349
bzrlib/lockable_files.py control_files.py-20051111201905-bb88546e799d669f
bzrlib/lockdir.py lockdir.py-20060220222025-98258adf27fbdda3
bzrlib/log.py log.py-20050505065812-c40ce11702fe5fb1
bzrlib/mail_client.py mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
bzrlib/msgeditor.py msgeditor.py-20050901111708-ef6d8de98f5d8f2f
bzrlib/mutabletree.py mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
bzrlib/push.py push.py-20080606021927-5fe39050e8xne9un-1
bzrlib/reconcile.py reweave_inventory.py-20051108164726-1e5e0934febac06e
bzrlib/registry.py lazy_factory.py-20060809213415-2gfvqadtvdn0phtg-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/revision.py revision.py-20050309040759-e77802c08f3999d5
bzrlib/shelf.py prepare_shelf.py-20081005181341-n74qe6gu1e65ad4v-1
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
bzrlib/smart/client.py client.py-20061116014825-2k6ada6xgulslami-1
bzrlib/smart/server.py server.py-20061110062051-chzu10y32vx8gvur-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_cat.py test_cat.py-20051201162916-f0937e4e19ea24b3
bzrlib/tests/blackbox/test_hooks.py test_hooks.py-20080308163236-xljgf9j41hik1x21-1
bzrlib/tests/blackbox/test_log.py test_log.py-20060112090212-78f6ea560c868e24
bzrlib/tests/blackbox/test_shelve.py test_ls_shelf.py-20081202053526-thlo8yt0pi1cgor1-1
bzrlib/tests/branch_implementations/test_revision_history.py test_revision_histor-20070326062311-v7co92liyuchb80w-1
bzrlib/tests/branch_implementations/test_sprout.py test_sprout.py-20070521151739-b8t8p7axw1h966ws-1
bzrlib/tests/interrepository_implementations/test_fetch.py test_fetch.py-20080425213627-j60cjh782ufm83ry-1
bzrlib/tests/inventory_implementations/basics.py basics.py-20070903044446-kdjwbiu1p1zi9phs-1
bzrlib/tests/per_repository/test_fileid_involved.py test_file_involved.py-20051215205901-728a172d1014daaa
bzrlib/tests/test_branch.py test_branch.py-20060116013032-97819aa07b8ab3b5
bzrlib/tests/test_bugtracker.py test_bugtracker.py-20070410073305-vu1vu1qosjurg8kb-2
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
bzrlib/tests/test_fetch.py testfetch.py-20050825090644-f73e07e7dfb1765a
bzrlib/tests/test_help.py test_help.py-20070419045354-6q6rq15j9e2n5fna-1
bzrlib/tests/test_hooks.py test_hooks.py-20070628030849-89rtsbe5dmer5npz-1
bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
bzrlib/tests/test_mutabletree.py test_mutabletree.py-20080405014429-2v0cdi3re320p8db-1
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
bzrlib/tests/test_revision.py testrevision.py-20050804210559-46f5e1eb67b01289
bzrlib/tests/test_shelf.py test_prepare_shelf.p-20081005181341-n74qe6gu1e65ad4v-2
bzrlib/tests/test_shelf_ui.py test_shelf_ui.py-20081027155203-wtcuazg85wp9u4fv-1
bzrlib/tests/test_source.py test_source.py-20051207061333-a58dea6abecc030d
bzrlib/tests/test_versionedfile.py test_versionedfile.py-20060222045249-db45c9ed14a1c2e5
bzrlib/tests/tree_implementations/test_path_content_summary.py test_path_content_su-20070904100855-3vrwedz6akn34kl5-1
bzrlib/tests/workingtree_implementations/test_parents.py test_set_parents.py-20060807231740-yicmnlci1mj8smu1-1
bzrlib/transform.py transform.py-20060105172343-dd99e54394d91687
bzrlib/transport/sftp.py sftp.py-20051019050329-ab48ce71b7e32dfe
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
bzrlib/versionedfile.py versionedfile.py-20060222045106-5039c71ee3b65490
bzrlib/weave.py knit.py-20050627021749-759c29984154256b
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
doc/developers/releasing.txt releasing.txt-20080502015919-fnrcav8fwy8ccibu-1
------------------------------------------------------------
revno: 4107.1.5
revision-id: jeanfrancois at apple.com-20090311171127-1r7957lprlaxwi4e
parent: jeanfrancois at apple.com-20090310182355-rz00psthdhtbllsi
parent: pqm at pqm.ubuntu.com-20090311110102-y233cktxicmatxjc
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Wed 2009-03-11 10:11:27 -0700
message:
Merged in bzr.dev.
added:
bzrlib/tests/per_repository_reference/test_default_stacking.py test_default_stackin-20090311055345-9ajahgm58oq3wh6h-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/_dirstate_helpers_c.pyx dirstate_helpers.pyx-20070503201057-u425eni465q4idwn-3
bzrlib/bugtracker.py bugtracker.py-20070410073305-vu1vu1qosjurg8kb-1
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/dirstate.py dirstate.py-20060728012006-d6mvoihjb3je9peu-1
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/lock.py lock.py-20050527050856-ec090bb51bc03349
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/smart/medium.py medium.py-20061103051856-rgu2huy59fkz902q-1
bzrlib/tests/blackbox/test_commit.py test_commit.py-20060212094538-ae88fc861d969db0
bzrlib/tests/branch_implementations/__init__.py __init__.py-20060123013057-b12a52c3f361daf4
bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
bzrlib/tests/intertree_implementations/test_compare.py test_compare.py-20060724101752-09ysswo1a92uqyoz-2
bzrlib/tests/per_repository_reference/__init__.py __init__.py-20080220025549-nnm2s80it1lvcwnc-2
bzrlib/tests/test__dirstate_helpers.py test_dirstate_helper-20070504035751-jsbn00xodv0y1eve-2
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_remote.py test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
bzrlib/tests/test_urlutils.py test_urlutils.py-20060502192900-46b1f9579987cf9c
bzrlib/tests/test_workingtree_4.py test_workingtree_4.p-20070223025758-531n3tznl3zacv2o-1
bzrlib/tests/workingtree_implementations/test_mkdir.py test_mkdir.py-20060907214856-4omn6hf1u7fvrart-3
bzrlib/tests/workingtree_implementations/test_nested_specifics.py test_nested_specific-20070306004443-qut978c488jr11sg-1
bzrlib/tests/workingtree_implementations/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
bzrlib/urlutils.py urlutils.py-20060502195429-e8a161ecf8fac004
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 4107.1.4
revision-id: jeanfrancois at apple.com-20090310182355-rz00psthdhtbllsi
parent: jeanfrancois at apple.com-20090310182120-s8hydao03ze9x6fh
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Tue 2009-03-10 11:23:55 -0700
message:
Rephrased the NEWS entry.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 4107.1.3
revision-id: jeanfrancois at apple.com-20090310182120-s8hydao03ze9x6fh
parent: jeanfrancois at apple.com-20090310181339-l1sz361kcxdu5kb0
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Tue 2009-03-10 11:21:20 -0700
message:
Updated the test_default_password_without_user to access the netrc credential store directly.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4107.1.2
revision-id: jeanfrancois at apple.com-20090310181339-l1sz361kcxdu5kb0
parent: jeanfrancois at apple.com-20090310172317-o0s7ns2ccidyhhfb
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Tue 2009-03-10 11:13:39 -0700
message:
Modified the netrc credential store plug-in to use an AuthenticationConfig object.
modified:
bzrlib/plugins/netrc_credential_store/tests/test_netrc.py test_netrc.py-20081006090414-vm3or4tz6c9wk2oi-1
------------------------------------------------------------
revno: 4107.1.1
revision-id: jeanfrancois at apple.com-20090310172317-o0s7ns2ccidyhhfb
parent: pqm at pqm.ubuntu.com-20090310095511-627bx4kwirxdx12y
parent: jeanfrancois at apple.com-20090305182858-nrej0ki105629d3u
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: authconfig-provider-fix
timestamp: Tue 2009-03-10 10:23:17 -0700
message:
Merged patch with bzr.dev.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
------------------------------------------------------------
revno: 4081.1.2
revision-id: jeanfrancois at apple.com-20090305182858-nrej0ki105629d3u
parent: jeanfrancois at apple.com-20090305181554-0uw591glkcd9evv2
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: bzr.dev
timestamp: Thu 2009-03-05 10:28:58 -0800
message:
Updated the NEWS file with notes about the fixes to AuthenticationConfig.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 4081.1.1
revision-id: jeanfrancois at apple.com-20090305181554-0uw591glkcd9evv2
parent: pqm at pqm.ubuntu.com-20090305091217-h813qd8f83wghtpr
committer: Jean-Francois Roy <jeanfrancois at apple.com>
branch nick: bzr.dev
timestamp: Thu 2009-03-05 10:15:54 -0800
message:
A 'realm' optional argument was added to the get_credentials and set_credentials
methods of the AuthenticationConfig class to provide that information to
credential providers which may require it. In addition, additional keys
are included in the credentials dictionary passed to credential
providers to match the expectations of credential providers
as determined by existing tests.
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2009-03-16 08:26:29 +0000
+++ b/NEWS 2009-03-16 12:35:31 +0000
@@ -41,6 +41,11 @@
BUG FIXES:
+ * Authentication plugins now receive all the parameters from the request
+ itself (aka host, port, realm, path, etc). Previously, only the
+ authentication section name, username and encoded password were
+ provided. (Jean-Francois Roy)
+
* Fix "is not a stackable format" error when pushing a
stackable-format branch with an unstackable-format repository to a
destination with a default stacking policy. (Andrew Bennetts)
@@ -75,6 +80,10 @@
sorts optimally for use with groupcompress compressors. (John Arbash
Meinel, Robert Collins)
+ * The ``get_credentials`` and ``set_credentials`` methods of
+ ``AuthenticationConfig`` now accept an optional realm argument.
+ (Jean-Francois Roy)
+
* The ``pb`` argument to ``fetch()`` is deprecated.
(Martin Pool)
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2009-01-17 01:30:58 +0000
+++ b/bzrlib/config.py 2009-03-13 02:28:39 +0000
@@ -993,7 +993,8 @@
section[option_name] = value
self._save()
- def get_credentials(self, scheme, host, port=None, user=None, path=None):
+ def get_credentials(self, scheme, host, port=None, user=None, path=None,
+ realm=None):
"""Returns the matching credentials from authentication.conf file.
:param scheme: protocol
@@ -1005,12 +1006,19 @@
:param user: login (optional)
:param path: the absolute path on the server (optional)
+
+ :param realm: the http authentication realm (optional)
:return: A dict containing the matching credentials or None.
This includes:
- name: the section name of the credentials in the
authentication.conf file,
- - user: can't de different from the provided user if any,
+ - user: can't be different from the provided user if any,
+ - scheme: the server protocol,
+ - host: the server address,
+ - port: the server port (can be None),
+ - path: the absolute server path (can be None),
+ - realm: the http specific authentication realm (can be None),
- password: the decoded password, could be None if the credential
defines only the user
- verify_certificates: https specific, True if the server
@@ -1057,10 +1065,18 @@
if a_user is None:
# Can't find a user
continue
+ # Prepare a credentials dictionary with additional keys
+ # for the credential providers
credentials = dict(name=auth_def_name,
user=a_user,
+ scheme=a_scheme,
+ host=host,
+ port=port,
+ path=path,
+ realm=realm,
password=auth_def.get('password', None),
verify_certificates=a_verify_certificates)
+ # Decode the password in the credentials (or get one)
self.decode_password(credentials,
auth_def.get('password_encoding', None))
if 'auth' in debug.debug_flags:
@@ -1070,7 +1086,8 @@
return credentials
def set_credentials(self, name, host, user, scheme=None, password=None,
- port=None, path=None, verify_certificates=None):
+ port=None, path=None, verify_certificates=None,
+ realm=None):
"""Set authentication credentials for a host.
Any existing credentials with matching scheme, host, port and path
@@ -1087,6 +1104,7 @@
apply to.
:param verify_certificates: On https, verify server certificates if
True.
+ :param realm: The http authentication realm (optional).
"""
values = {'host': host, 'user': user}
if password is not None:
@@ -1099,10 +1117,12 @@
values['path'] = path
if verify_certificates is not None:
values['verify_certificates'] = str(verify_certificates)
+ if realm is not None:
+ values['realm'] = realm
config = self._get_config()
for_deletion = []
for section, existing_values in config.items():
- for key in ('scheme', 'host', 'port', 'path'):
+ for key in ('scheme', 'host', 'port', 'path', 'realm'):
if existing_values.get(key) != values.get(key):
break
else:
@@ -1127,7 +1147,7 @@
:return: The found user.
"""
credentials = self.get_credentials(scheme, host, port, user=None,
- path=path)
+ path=path, realm=realm)
if credentials is not None:
user = credentials['user']
else:
@@ -1152,7 +1172,8 @@
:return: The found password or the one entered by the user.
"""
- credentials = self.get_credentials(scheme, host, port, user, path)
+ credentials = self.get_credentials(scheme, host, port, user, path,
+ realm)
if credentials is not None:
password = credentials['password']
if password is not None and scheme is 'ssh':
=== modified file 'bzrlib/plugins/netrc_credential_store/tests/test_netrc.py'
--- a/bzrlib/plugins/netrc_credential_store/tests/test_netrc.py 2008-10-06 10:06:53 +0000
+++ b/bzrlib/plugins/netrc_credential_store/tests/test_netrc.py 2009-03-13 04:10:51 +0000
@@ -14,6 +14,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+from cStringIO import StringIO
+
from bzrlib import (
config,
errors,
@@ -69,3 +71,16 @@
cs = self._get_netrc_cs()
password = cs.decode_password(dict(host='other'))
self.assertIs(None, password)
+
+ def test_get_netrc_credentials_via_auth_config(self):
+ # Create a test AuthenticationConfig object
+ ac_content = """
+[host1]
+host = host
+user = joe
+password_encoding = netrc
+"""
+ conf = config.AuthenticationConfig(_file=StringIO(ac_content))
+ credentials = conf.get_credentials('scheme', 'host', user='joe')
+ self.assertIsNot(None, credentials)
+ self.assertEquals('secret', credentials.get('password', None))
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2009-01-17 01:30:58 +0000
+++ b/bzrlib/tests/test_config.py 2009-03-13 02:40:46 +0000
@@ -1427,14 +1427,17 @@
def test_set_credentials(self):
conf = config.AuthenticationConfig()
conf.set_credentials('name', 'host', 'user', 'scheme', 'password',
- 99, path='/foo', verify_certificates=False)
+ 99, path='/foo', verify_certificates=False, realm='realm')
credentials = conf.get_credentials(host='host', scheme='scheme',
- port=99, path='/foo')
+ port=99, path='/foo',
+ realm='realm')
CREDENTIALS = {'name': 'name', 'user': 'user', 'password': 'password',
- 'verify_certificates': False,}
+ 'verify_certificates': False, 'scheme': 'scheme',
+ 'host': 'host', 'port': 99, 'path': '/foo',
+ 'realm': 'realm'}
self.assertEqual(CREDENTIALS, credentials)
credentials_from_disk = config.AuthenticationConfig().get_credentials(
- host='host', scheme='scheme', port=99, path='/foo')
+ host='host', scheme='scheme', port=99, path='/foo', realm='realm')
self.assertEqual(CREDENTIALS, credentials_from_disk)
def test_reset_credentials_different_name(self):
@@ -1444,7 +1447,9 @@
self.assertIs(None, conf._get_config().get('name'))
credentials = conf.get_credentials(host='host', scheme='scheme')
CREDENTIALS = {'name': 'name2', 'user': 'user2', 'password':
- 'password', 'verify_certificates': True}
+ 'password', 'verify_certificates': True,
+ 'scheme': 'scheme', 'host': 'host', 'port': None,
+ 'path': None, 'realm': None}
self.assertEqual(CREDENTIALS, credentials)
More information about the bazaar-commits
mailing list