Skip to content

Commit da8cbcc

Browse files
committed
feat(commands/reset_password): signout user from active sessions
1 parent 6c70ebc commit da8cbcc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

compiler_admin/commands/reset_password.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from argparse import Namespace
22

33
from compiler_admin.commands import RESULT_SUCCESS, RESULT_FAILURE
4+
from compiler_admin.commands.signout import signout
45
from compiler_admin.services.google import USER_HELLO, CallGAMCommand, user_account_name, user_exists
56

67

@@ -34,5 +35,6 @@ def reset_password(args: Namespace) -> int:
3435
print(f"User exists, resetting password: {account}")
3536

3637
res = CallGAMCommand(command)
38+
res += signout(args)
3739

3840
return RESULT_SUCCESS if res == RESULT_SUCCESS else RESULT_FAILURE

tests/commands/test_reset_password.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def mock_google_user_exists(mock_google_user_exists):
1111
return mock_google_user_exists(MODULE)
1212

1313

14+
@pytest.fixture
15+
def mock_commands_signout(mock_commands_signout):
16+
return mock_commands_signout(MODULE)
17+
18+
1419
@pytest.fixture
1520
def mock_google_CallGAMCommand(mock_google_CallGAMCommand):
1621
return mock_google_CallGAMCommand(MODULE)
@@ -32,7 +37,7 @@ def test_reset_password_user_does_not_exist(mock_google_user_exists):
3237
assert res == RESULT_FAILURE
3338

3439

35-
def test_reset_password_user_exists(mock_google_user_exists, mock_google_CallGAMCommand):
40+
def test_reset_password_user_exists(mock_google_user_exists, mock_google_CallGAMCommand, mock_commands_signout):
3641
mock_google_user_exists.return_value = True
3742

3843
args = Namespace(username="username")
@@ -45,8 +50,10 @@ def test_reset_password_user_exists(mock_google_user_exists, mock_google_CallGAM
4550
assert "update user" in call_args
4651
assert "password random changepassword" in call_args
4752

53+
mock_commands_signout.assert_called_once_with(args)
4854

49-
def test_reset_password_notify(mock_google_user_exists, mock_google_CallGAMCommand):
55+
56+
def test_reset_password_notify(mock_google_user_exists, mock_google_CallGAMCommand, mock_commands_signout):
5057
mock_google_user_exists.return_value = True
5158

5259
args = Namespace(username="username", notify="[email protected]")
@@ -59,3 +66,5 @@ def test_reset_password_notify(mock_google_user_exists, mock_google_CallGAMComma
5966
assert "update user" in call_args
6067
assert "password random changepassword" in call_args
6168
assert f"notify [email protected] from {USER_HELLO}" in call_args
69+
70+
mock_commands_signout.assert_called_once_with(args)

0 commit comments

Comments
 (0)