Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from fastapi import HTTPException, status
from sqlalchemy import func, select
from werkzeug.security import generate_password_hash

from airflow.providers.fab.auth_manager.api_fastapi.datamodels.roles import Role
from airflow.providers.fab.auth_manager.api_fastapi.datamodels.users import (
Expand Down Expand Up @@ -188,7 +187,7 @@ def update_user(cls, username: str, body: UserPatchBody, update_mask: str | None

password_changed = False
if "password" in fields_to_update and body.password is not None:
user.password = generate_password_hash(body.password.get_secret_value())
user.password = security_manager._hash_password(body.password.get_secret_value())
password_changed = True

if "username" in fields_to_update and body.username is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,12 @@ def test_update_user_with_password(self, get_fab_auth_manager, fab_auth_manager,
password=password_mock,
)

with patch(
"airflow.providers.fab.auth_manager.api_fastapi.services.users.generate_password_hash"
) as mock_hash:
mock_hash.return_value = "hashed_password"
FABAuthManagerUsers.update_user("alice", patch_body, update_mask="password")
security_manager._hash_password.return_value = "hashed_password"
FABAuthManagerUsers.update_user("alice", patch_body, update_mask="password")

password_mock.get_secret_value.assert_called_once()
mock_hash.assert_called_once_with("newpassword")
security_manager._hash_password.assert_called_once_with("newpassword")
assert user_obj.password == "hashed_password"

# delete_user tests

Expand Down