summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof.johansson@axis.com>2014-01-20 12:03:24 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-24 17:54:46 +0000
commit7dd4bf6310c61828dc2ac7777f5adf1004349715 (patch)
treefbc030576a80f9427d3c4488d0aa4e553c72818e
parent57484d68dff378e4f3bd0d3e40b9db02b029feb4 (diff)
downloadpoky-7dd4bf6310c61828dc2ac7777f5adf1004349715.tar.gz
bitbake: fetch2.URI: Set username/password should not change the other
When setting the username after already having set the password, the password was unexpectedly reset. This change fixes this issue and introduces unit tests to make sure it doesn't happen again. (Bitbake rev: 25faef3a047f9c7564089463d7c96f6910b640cb) Signed-off-by: Olof Johansson <olof.johansson@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py5
-rw-r--r--bitbake/lib/bb/tests/fetch.py14
2 files changed, 17 insertions, 2 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 05999607b9..4335e7a0d8 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -321,9 +321,10 @@ class URI(object):
321 321
322 @username.setter 322 @username.setter
323 def username(self, username): 323 def username(self, username):
324 password = self.password
324 self.userinfo = username 325 self.userinfo = username
325 if self.password: 326 if password:
326 self.userinfo += ":%s" % self.password 327 self.userinfo += ":%s" % password
327 328
328 @property 329 @property
329 def password(self): 330 def password(self):
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 4fb2178595..4be5a07bec 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -274,6 +274,20 @@ class URITest(unittest.TestCase):
274 self.assertEqual(uri.username, test['username']) 274 self.assertEqual(uri.username, test['username'])
275 self.assertEqual(uri.password, test['password']) 275 self.assertEqual(uri.password, test['password'])
276 276
277 # make sure changing the values doesn't do anything unexpected
278 uri.username = 'changeme'
279 self.assertEqual(uri.username, 'changeme')
280 self.assertEqual(uri.password, test['password'])
281 uri.password = 'insecure'
282 self.assertEqual(uri.username, 'changeme')
283 self.assertEqual(uri.password, 'insecure')
284
285 # reset back after our trickery
286 uri.userinfo = test['userinfo']
287 self.assertEqual(uri.userinfo, test['userinfo'])
288 self.assertEqual(uri.username, test['username'])
289 self.assertEqual(uri.password, test['password'])
290
277 uri.hostname = test['hostname'] 291 uri.hostname = test['hostname']
278 self.assertEqual(uri.hostname, test['hostname']) 292 self.assertEqual(uri.hostname, test['hostname'])
279 self.assertEqual(uri.hostport, test['hostname']) 293 self.assertEqual(uri.hostport, test['hostname'])