aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/bb/fetch2/__init__.py5
-rw-r--r--lib/bb/tests/fetch.py14
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 05999607b..4335e7a0d 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -321,9 +321,10 @@ class URI(object):
@username.setter
def username(self, username):
+ password = self.password
self.userinfo = username
- if self.password:
- self.userinfo += ":%s" % self.password
+ if password:
+ self.userinfo += ":%s" % password
@property
def password(self):
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 4fb217859..4be5a07be 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -274,6 +274,20 @@ class URITest(unittest.TestCase):
self.assertEqual(uri.username, test['username'])
self.assertEqual(uri.password, test['password'])
+ # make sure changing the values doesn't do anything unexpected
+ uri.username = 'changeme'
+ self.assertEqual(uri.username, 'changeme')
+ self.assertEqual(uri.password, test['password'])
+ uri.password = 'insecure'
+ self.assertEqual(uri.username, 'changeme')
+ self.assertEqual(uri.password, 'insecure')
+
+ # reset back after our trickery
+ uri.userinfo = test['userinfo']
+ self.assertEqual(uri.userinfo, test['userinfo'])
+ self.assertEqual(uri.username, test['username'])
+ self.assertEqual(uri.password, test['password'])
+
uri.hostname = test['hostname']
self.assertEqual(uri.hostname, test['hostname'])
self.assertEqual(uri.hostport, test['hostname'])