Skip to content

Commit

Permalink
Replace get_username with builtin function
Browse files Browse the repository at this point in the history
The implementation for `get_username` only tried some environment
variables which are undefined in our CI environment.
  • Loading branch information
WhyNotHugo committed Jul 22, 2024
1 parent db98fe6 commit 0e1d9f6
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,6 @@ def delay(arg):
return d


def get_username():
uname = os.environ.get('USERNAME', None)

if uname is None:
uname = os.environ.get('LOGNAME', None)

return uname.encode('ascii')


class AuthTestProtocol(protocol.Protocol):
_buffer = b''
_sent_null = False
Expand Down Expand Up @@ -573,7 +564,7 @@ def recv1(msg):
self.send(
b'AUTH DBUS_COOKIE_SHA1 '
+ binascii.hexlify(
get_username()))
getpass.getuser()))
self.assertTrue(msg.startswith(b'REJECTED'))
self.gotMessage = recv2

Expand All @@ -583,7 +574,7 @@ def recv1(msg):
def test_cancel(self):
d = self.failOnExit()

self.send(b'AUTH DBUS_COOKIE_SHA1 ' + binascii.hexlify(get_username()))
self.send(b'AUTH DBUS_COOKIE_SHA1 ' + binascii.hexlify(getpass.getuser()))

def recv2(msg):
self.assertTrue(msg.startswith(b'REJECTED'))
Expand Down

0 comments on commit 0e1d9f6

Please sign in to comment.