Skip to content

Commit

Permalink
fixed "password_confirmation" test
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <[email protected]>
  • Loading branch information
bigcat88 committed Sep 3, 2024
1 parent 2d49cea commit 0436df5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/actual_tests/z_special_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@ async def test_password_confirmation_async(anc_client):

def _test_password_confirmation() -> 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")
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)
patch_success = False
for i in ("data/nc_pass_confirm.patch", "data/nc_pass_confirm_nc31.patch"):
patch_path = path.join(path.dirname(path.dirname(path.abspath(__file__))), i)
cwd_path = path.dirname(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))))
r = run(["patch", "-p", "1", "-i", patch_path], cwd=cwd_path)
if r.returncode == 0:
patch_success = True
break
assert patch_success
sleep(6)
return patch_path, cwd_path
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 0436df5

Please sign in to comment.