Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 authored Sep 4, 2024
2 parents 1d12a2e + 4647e06 commit c004759
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions nc_py_api/talk_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class TalkBotMessage:
def __init__(self, raw_data: dict):
self._raw_data = raw_data

@property
def message_type(self) -> str:
"""The type of message like Join, Leave, Create, Activity, etc."""
return self._raw_data["type"]

@property
def actor_id(self) -> str:
"""One of the attendee types followed by the ``/`` character and a unique identifier within the given type.
Expand Down
11 changes: 7 additions & 4 deletions tests/actual_tests/z_special_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@pytest.mark.skipif("NC_AUTH_USER" not in environ or "NC_AUTH_PASS" not in environ, reason="Needs login & paasword.")
@pytest.mark.skipif(environ.get("CI", None) is None, reason="run only on GitHub")
def test_password_confirmation(nc_client):
patch_path, cwd_path = _test_password_confirmation()
patch_path, cwd_path = _test_password_confirmation(nc_client.srv_version["major"])
nc_client.update_server_info()
old_adapter = nc_client._session.adapter
with contextlib.suppress(NextcloudException):
Expand All @@ -27,7 +27,7 @@ def test_password_confirmation(nc_client):
@pytest.mark.skipif("NC_AUTH_USER" not in environ or "NC_AUTH_PASS" not in environ, reason="Needs login & paasword.")
@pytest.mark.skipif(environ.get("CI", None) is None, reason="run only on GitHub")
async def test_password_confirmation_async(anc_client):
patch_path, cwd_path = _test_password_confirmation()
patch_path, cwd_path = _test_password_confirmation((await anc_client.srv_version)["major"])
await anc_client.update_server_info()
old_adapter = anc_client._session.adapter
with contextlib.suppress(NextcloudException):
Expand All @@ -37,9 +37,12 @@ async def test_password_confirmation_async(anc_client):
run(["git", "apply", "-R", patch_path], cwd=cwd_path, check=True)


def _test_password_confirmation() -> tuple[str, str]:
def _test_password_confirmation(nc_version) -> tuple[str, str]:
# patch "PasswordConfirmationMiddleware.php" decreasing asking before Password Confirmation from 30 min to 5 secs
patch_path = path.join(path.dirname(path.dirname(path.abspath(__file__))), "data/nc_pass_confirm.patch")
if nc_version <= 30:
patch_path = path.join(path.dirname(path.dirname(path.abspath(__file__))), "data/nc_pass_confirm.patch")
else:
patch_path = path.join(path.dirname(path.dirname(path.abspath(__file__))), "data/nc_pass_confirm_nc31.patch")
cwd_path = path.dirname(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))))
run(["patch", "-p", "1", "-i", patch_path], cwd=cwd_path, check=True)
sleep(6)
Expand Down
13 changes: 13 additions & 0 deletions tests/data/nc_pass_confirm_nc31.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php
index 5ff9d7386da..04edf4e9991 100644
--- a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php
+++ b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php
@@ -93,7 +93,7 @@ class PasswordConfirmationMiddleware extends Middleware {

$lastConfirm = (int)$this->session->get('last-password-confirm');
// TODO: confirm excludedUserBackEnds can go away and remove it
- if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay
+ if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - 5)) { // allow 5 seconds delay
throw new NotConfirmedException();
}
}

0 comments on commit c004759

Please sign in to comment.