bito-code-review[bot] commented on code in PR #40695:
URL: https://github.com/apache/superset/pull/40695#discussion_r3358841531
##########
superset/security/manager.py:
##########
@@ -633,6 +633,12 @@ def create_login_manager(self, app: Flask) -> LoginManager:
return lm
def on_user_login(self, user: Any) -> None:
+ # pylint: disable=import-outside-toplevel
+ from superset.security.session_invalidation import stamp_login_time
+
+ # Record the authentication time so outstanding sessions can be
+ # invalidated when the account is later disabled.
+ stamp_login_time()
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Test coverage gap for session stamping</b></div>
<div id="fix">
In `test_on_user_login_logs_event`, add a mock for `stamp_login_time` and
assert it’s called. For example:
```python
@patch('superset.security.manager.stamp_login_time')
@patch('superset.security.manager._log_audit_event')
def test_on_user_login_logs_event(mock_log, mock_stamp_login_time):
sm = SupersetSecurityManager.__new__(SupersetSecurityManager)
user = MagicMock(spec=User)
user.username = 'testuser'
user.id = 7
sm.on_user_login(user)
mock_stamp_login_time.assert_called_once()
mock_log.assert_called_once_with(
'UserLoggedIn', {'username': 'testuser', 'user_id': 7}
)
```
</div>
</div>
<small><i>Code Review Run #c3b63e</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]