Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion firebase_admin/_user_mgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

MAX_LIST_USERS_RESULTS = 1000
MAX_IMPORT_USERS_SIZE = 1000
B64_REDACTED = base64.b64encode(b'REDACTED')
B64_REDACTED = base64.b64encode(b'REDACTED').decode()


class Sentinel:
Expand Down
18 changes: 17 additions & 1 deletion tests/test_user_mgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_exported_record_empty_password(self):
def test_redacted_passwords_cleared(self):
user = auth.ExportedUserRecord({
'localId': 'user',
'passwordHash': base64.b64encode(b'REDACTED'),
'passwordHash': base64.b64encode(b'REDACTED').decode(),
})
assert user.password_hash is None

Expand Down Expand Up @@ -947,6 +947,22 @@ def test_list_users_no_users_response(self, user_mgt_app):
users = list(user for user in page.iterate_all())
assert len(users) == 0

def test_list_users_redacted_password_hash(self, user_mgt_app):
response = {'users': [
{
'localId': 'redacted',
'passwordHash': base64.b64encode(b'REDACTED').decode(),
'salt': 'passwordSalt',
},
{'localId': 'user', 'passwordHash': 'passwordHash', 'salt': 'passwordSalt'},
]}
_instrument_user_manager(user_mgt_app, 200, json.dumps(response))
page = auth.list_users(app=user_mgt_app)
assert len(page.users) == 2
redacted, user = page.users
assert redacted.password_hash is None
assert user.password_hash == 'passwordHash'

def test_list_users_with_max_results(self, user_mgt_app):
_, recorder = _instrument_user_manager(user_mgt_app, 200, MOCK_LIST_USERS_RESPONSE)
page = auth.list_users(max_results=500, app=user_mgt_app)
Expand Down
Loading