Skip to content

Commit fb3ee49

Browse files
authored
CI: "password_confirmation" test fix (#291)
This is only half of fix for CI, "test_conversation_avatar" test should fail still and need fix Signed-off-by: Alexander Piskun <[email protected]>
1 parent 2d49cea commit fb3ee49

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

tests/actual_tests/z_special_test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@pytest.mark.skipif("NC_AUTH_USER" not in environ or "NC_AUTH_PASS" not in environ, reason="Needs login & paasword.")
1414
@pytest.mark.skipif(environ.get("CI", None) is None, reason="run only on GitHub")
1515
def test_password_confirmation(nc_client):
16-
patch_path, cwd_path = _test_password_confirmation()
16+
patch_path, cwd_path = _test_password_confirmation(nc_client.srv_version["major"])
1717
nc_client.update_server_info()
1818
old_adapter = nc_client._session.adapter
1919
with contextlib.suppress(NextcloudException):
@@ -27,7 +27,7 @@ def test_password_confirmation(nc_client):
2727
@pytest.mark.skipif("NC_AUTH_USER" not in environ or "NC_AUTH_PASS" not in environ, reason="Needs login & paasword.")
2828
@pytest.mark.skipif(environ.get("CI", None) is None, reason="run only on GitHub")
2929
async def test_password_confirmation_async(anc_client):
30-
patch_path, cwd_path = _test_password_confirmation()
30+
patch_path, cwd_path = _test_password_confirmation((await anc_client.srv_version)["major"])
3131
await anc_client.update_server_info()
3232
old_adapter = anc_client._session.adapter
3333
with contextlib.suppress(NextcloudException):
@@ -37,9 +37,12 @@ async def test_password_confirmation_async(anc_client):
3737
run(["git", "apply", "-R", patch_path], cwd=cwd_path, check=True)
3838

3939

40-
def _test_password_confirmation() -> tuple[str, str]:
40+
def _test_password_confirmation(nc_version) -> tuple[str, str]:
4141
# patch "PasswordConfirmationMiddleware.php" decreasing asking before Password Confirmation from 30 min to 5 secs
42-
patch_path = path.join(path.dirname(path.dirname(path.abspath(__file__))), "data/nc_pass_confirm.patch")
42+
if nc_version <= 30:
43+
patch_path = path.join(path.dirname(path.dirname(path.abspath(__file__))), "data/nc_pass_confirm.patch")
44+
else:
45+
patch_path = path.join(path.dirname(path.dirname(path.abspath(__file__))), "data/nc_pass_confirm_nc31.patch")
4346
cwd_path = path.dirname(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))))
4447
run(["patch", "-p", "1", "-i", patch_path], cwd=cwd_path, check=True)
4548
sleep(6)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php
2+
index 5ff9d7386da..04edf4e9991 100644
3+
--- a/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php
4+
+++ b/lib/private/AppFramework/Middleware/Security/PasswordConfirmationMiddleware.php
5+
@@ -93,7 +93,7 @@ class PasswordConfirmationMiddleware extends Middleware {
6+
7+
$lastConfirm = (int)$this->session->get('last-password-confirm');
8+
// TODO: confirm excludedUserBackEnds can go away and remove it
9+
- if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - (30 * 60 + 15))) { // allow 15 seconds delay
10+
+ if (!isset($this->excludedUserBackEnds[$backendClassName]) && $lastConfirm < ($this->timeFactory->getTime() - 5)) { // allow 5 seconds delay
11+
throw new NotConfirmedException();
12+
}
13+
}

0 commit comments

Comments
 (0)