From 2cbf58436858f5ae810bb1255d164baa9a51789c Mon Sep 17 00:00:00 2001 From: Alexander Piskun <13381981+bigcat88@users.noreply.github.com> Date: Sun, 12 Jan 2025 10:39:56 +0300 Subject: [PATCH] removed "password confirmation" test (#326) Since this test needs to be updated about every 1 or 2 month(s), I will remove it as I don't have time to do this update regularly. --- tests/actual_tests/z_special_test.py | 49 --------------------------- tests/data/nc_pass_confirm.patch | 13 ------- tests/data/nc_pass_confirm_nc31.patch | 13 ------- 3 files changed, 75 deletions(-) delete mode 100644 tests/actual_tests/z_special_test.py delete mode 100644 tests/data/nc_pass_confirm.patch delete mode 100644 tests/data/nc_pass_confirm_nc31.patch diff --git a/tests/actual_tests/z_special_test.py b/tests/actual_tests/z_special_test.py deleted file mode 100644 index 075e3314..00000000 --- a/tests/actual_tests/z_special_test.py +++ /dev/null @@ -1,49 +0,0 @@ -import contextlib -from os import environ, path -from subprocess import run -from time import sleep - -import pytest - -from nc_py_api import NextcloudException - -# These tests should be run only on GitHub and only in special environment. - - -@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(nc_client.srv_version["major"]) - nc_client.update_server_info() - old_adapter = nc_client._session.adapter - with contextlib.suppress(NextcloudException): - nc_client.users.create("test_cover_user_spec", password="ThisIsA54StrongPassword013") - nc_client.users.delete("test_cover_user_spec") - assert old_adapter != nc_client._session.adapter - run(["git", "apply", "-R", patch_path], cwd=cwd_path, check=True) - - -@pytest.mark.asyncio(scope="session") -@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((await anc_client.srv_version)["major"]) - await anc_client.update_server_info() - old_adapter = anc_client._session.adapter - with contextlib.suppress(NextcloudException): - await anc_client.users.create("test_cover_user_spec", password="ThisIsA54StrongPassword013") - await anc_client.users.delete("test_cover_user_spec") - assert old_adapter != anc_client._session.adapter - run(["git", "apply", "-R", patch_path], cwd=cwd_path, check=True) - - -def _test_password_confirmation(nc_version) -> tuple[str, str]: - # patch "PasswordConfirmationMiddleware.php" decreasing asking before Password Confirmation from 30 min to 5 secs - 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) - return patch_path, cwd_path diff --git a/tests/data/nc_pass_confirm.patch b/tests/data/nc_pass_confirm.patch deleted file mode 100644 index d330f63e..00000000 --- a/tests/data/nc_pass_confirm.patch +++ /dev/null @@ -1,13 +0,0 @@ -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(); - } - } diff --git a/tests/data/nc_pass_confirm_nc31.patch b/tests/data/nc_pass_confirm_nc31.patch deleted file mode 100644 index 722c03ef..00000000 --- a/tests/data/nc_pass_confirm_nc31.patch +++ /dev/null @@ -1,13 +0,0 @@ -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(); - } - }