diff options
author | Olof Johansson <olof.johansson@axis.com> | 2014-01-20 12:03:24 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-24 10:13:25 +0000 |
commit | 25faef3a047f9c7564089463d7c96f6910b640cb (patch) | |
tree | 2eb9b7f604f2fca724ced45cf85acdc4fb3d5458 /lib | |
parent | c2f27ae4271985b48f957747b6ea372c8699cb49 (diff) | |
download | bitbake-25faef3a047f9c7564089463d7c96f6910b640cb.tar.gz |
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.
Signed-off-by: Olof Johansson <olof.johansson@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bb/fetch2/__init__.py | 5 | ||||
-rw-r--r-- | lib/bb/tests/fetch.py | 14 |
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']) |