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 23, 2024
1 parent e1fd37b commit 9673658
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 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 @@ -572,8 +563,8 @@ def recv2(msg):
def recv1(msg):
self.send(
b'AUTH DBUS_COOKIE_SHA1 '
+ binascii.hexlify(
get_username()))
+ binascii.hexlify(getpass.getuser().encode())
)
self.assertTrue(msg.startswith(b'REJECTED'))
self.gotMessage = recv2

Expand All @@ -583,7 +574,10 @@ 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().encode())
)

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

0 comments on commit 9673658

Please sign in to comment.