From 2951c7e2389108ff314c566024cc90a58cfdc5de Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Fri, 29 Mar 2024 18:11:44 +0800 Subject: [PATCH 01/13] fix: require phone_number when verify sms code --- leancloud/user.py | 9 +++++---- tests/test_user.py | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/leancloud/user.py b/leancloud/user.py index fee53b2..22c4b57 100644 --- a/leancloud/user.py +++ b/leancloud/user.py @@ -335,8 +335,8 @@ def request_password_reset_by_sms_code(cls, phone_number, validate_token=None): client.post("/requestPasswordResetBySmsCode", params) @classmethod - def reset_password_by_sms_code(cls, sms_code, new_password): - params = {"password": new_password} + def reset_password_by_sms_code(cls, sms_code, new_password, phone_number): + params = {"password": new_password, "mobilePhoneNumber": phone_number} client.put("/resetPasswordBySmsCode/" + sms_code, params) # This should be an instance method. @@ -359,8 +359,9 @@ def change_phone_number(cls, sms_code, phone_number): client.post("/changePhoneNumber", params) @classmethod - def verify_mobile_phone_number(cls, sms_code): - client.post("/verifyMobilePhone/" + sms_code, {}) + def verify_mobile_phone_number(cls, sms_code, phone_number): + params = {"mobilePhoneNumber": phone_number} + client.post("/verifyMobilePhone/" + sms_code, params) @classmethod def request_login_sms_code(cls, phone_number, validate_token=None): diff --git a/tests/test_user.py b/tests/test_user.py index f3999bd..3f4731a 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -322,7 +322,9 @@ def test_request_password_reset_by_sms_code(): # type: () -> None def test_reset_password_by_sms_code(): # type: () -> None try: User.reset_password_by_sms_code( - str(random.randrange(100000, 999999)), "password" + str(random.randrange(100000, 999999)), + "password", + "1861111" + str(random.randrange(1000, 9999)) ) except LeanCloudError as e: if e.code != 603: From aad2c7775166ca77e2e15e9ebd9335726b39b762 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Mon, 1 Apr 2024 12:15:13 +0800 Subject: [PATCH 02/13] build: remove CI build for python 2.7 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index ea15a42..86c3b46 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 - name: Set up Python From 6a2ef9468ed9f2d2f0e2502eba7842ab1486d5c3 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Mon, 1 Apr 2024 14:21:00 +0800 Subject: [PATCH 03/13] build: use another app --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 86c3b46..8463cf5 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -57,7 +57,7 @@ jobs: pip install -e .'[test]' - name: Run tests with ${{ matrix.python-version }} env: - APP_ID: YJRGphy60b8JCBib0vtDDtak-MdYXbMMI + APP_ID: u5xB92MjVH94kH6p3M66DUua-MdYXbMMI APP_KEY: ${{ secrets.APP_KEY }} MASTER_KEY: ${{ secrets.MASTER_KEY }} USE_REGION: US From 3070c5ef013d615e6c10acb994663a7c765e7dbd Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 11:14:15 +0800 Subject: [PATCH 04/13] test: only test on python 3.5, 3.9 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 8463cf5..15e99a0 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [3.5, 3.6, 3.7, 3.8, 3.9] + python-version: [3.5, 3.8, 3.9] steps: - uses: actions/checkout@v2 - name: Set up Python From 17f8125ce084bf3c5d485ad6538a107fefa04182 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 11:29:39 +0800 Subject: [PATCH 05/13] test: catch sms limit error --- .github/workflows/pythonpackage.yml | 2 +- tests/test_engine.py | 4 ++++ tests/test_user.py | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 15e99a0..283bd47 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [3.5, 3.8, 3.9] + python-version: [3.5, 3.9, 3.12] steps: - uses: actions/checkout@v2 - name: Set up Python diff --git a/tests/test_engine.py b/tests/test_engine.py index 53f1b70..d016c30 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -579,6 +579,10 @@ def test_request_sms_code(): # type: () -> None pass elif e.code == 601 or e.error.startswith("SMS request too fast"): # send sms too frequently pass + elif e.error.startswith("SMS sending exceeds limit"): + pass + elif "send too frequently" in e.error: + pass else: raise e diff --git a/tests/test_user.py b/tests/test_user.py index 3f4731a..fa935be 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -284,7 +284,13 @@ def test_request_change_phone_number(): # type: () -> None # phone number is from http://www.z-sms.com User.request_change_phone_number("+8617180655340") except LeanCloudError as e: - if e.code not in (119, 213, 601, 605): + if e.code in (119, 213, 601, 605): + pass + elif e.error.startswith("SMS sending exceeds limit"): + pass + elif "send too frequently" in e.error: + pass + else: raise e finally: user1.logout() From 925cabb07185611c1cb4d10ce03b6d183151352c Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 12:20:52 +0800 Subject: [PATCH 06/13] test: pin urllib3 to 1.x per requests/releases#v2.30.0 --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index b3fefa1..03256cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ iso8601>=0.1.14 six>=1.11.0 qiniu>=7.3.1 requests>=2.25.1 +urllib3<2 Werkzeug>=0.16.0,<2.0.0 secure-cookie>=0.1.0,<1.0.0 gevent>=22.10.2,<23.0.0 From b9c681ed79be7f910d5ff678ca6b2ec552274d12 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 14:42:06 +0800 Subject: [PATCH 07/13] test: test on python 3.11 instead of 3.12 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 283bd47..88268cd 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [3.5, 3.9, 3.12] + python-version: [3.5, 3.9, 3.11] steps: - uses: actions/checkout@v2 - name: Set up Python From f250fc3561c6d9ba5aa92e225bf3b079ac160764 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 15:02:41 +0800 Subject: [PATCH 08/13] test: test on python 3.10 instead of 3.11 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 88268cd..14cf9c2 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [3.5, 3.9, 3.11] + python-version: [3.5, 3.9, 3.10] steps: - uses: actions/checkout@v2 - name: Set up Python From 7cd9c6cf5719c2ab1b129a9625a9bf56d84612c9 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 15:08:38 +0800 Subject: [PATCH 09/13] test: fix python version --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 14cf9c2..7028c21 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [3.5, 3.9, 3.10] + python-version: [3.5, 3.9, "3.10"] steps: - uses: actions/checkout@v2 - name: Set up Python From ce4a9844495f22dedea99d9d254409c15ccd44c9 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 15:20:24 +0800 Subject: [PATCH 10/13] test: use nose-py3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 9d7cb02..a3cee18 100644 --- a/setup.py +++ b/setup.py @@ -42,6 +42,6 @@ install_requires=install_requires, extras_require={ 'dev': ['sphinx', 'sphinx_rtd_theme'], - 'test': ['nose', 'wsgi_intercept', 'flask'], + 'test': ['nose-py3', 'wsgi_intercept', 'flask'], } ) From 6ff00dfccefa957522f9d62e9bfc1f8b151131e6 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 15:25:29 +0800 Subject: [PATCH 11/13] test: drop test for python 3.5 --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 7028c21..678c836 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [3.5, 3.9, "3.10"] + python-version: [3.6, 3.9, "3.10"] steps: - uses: actions/checkout@v2 - name: Set up Python From e73f0d55998cc7e2769469f9094c6d8ea08014a5 Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 15:53:36 +0800 Subject: [PATCH 12/13] test: only for python 3.6, 3.9 --- .github/workflows/pythonpackage.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 678c836..b599464 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -43,7 +43,7 @@ jobs: strategy: max-parallel: 1 matrix: - python-version: [3.6, 3.9, "3.10"] + python-version: [3.6, 3.9] steps: - uses: actions/checkout@v2 - name: Set up Python diff --git a/setup.py b/setup.py index a3cee18..9d7cb02 100644 --- a/setup.py +++ b/setup.py @@ -42,6 +42,6 @@ install_requires=install_requires, extras_require={ 'dev': ['sphinx', 'sphinx_rtd_theme'], - 'test': ['nose-py3', 'wsgi_intercept', 'flask'], + 'test': ['nose', 'wsgi_intercept', 'flask'], } ) From 26b302b7586c2ab10f1bb6b75cb7d9010fd4abab Mon Sep 17 00:00:00 2001 From: Wu Yun Date: Tue, 2 Apr 2024 16:00:42 +0800 Subject: [PATCH 13/13] test: sms limit error --- tests/test_engine.py | 2 +- tests/test_user.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_engine.py b/tests/test_engine.py index d016c30..8db3682 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py @@ -579,7 +579,7 @@ def test_request_sms_code(): # type: () -> None pass elif e.code == 601 or e.error.startswith("SMS request too fast"): # send sms too frequently pass - elif e.error.startswith("SMS sending exceeds limit"): + elif "SMS sending exceeds limit" in e.error: pass elif "send too frequently" in e.error: pass diff --git a/tests/test_user.py b/tests/test_user.py index fa935be..860618c 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -286,7 +286,7 @@ def test_request_change_phone_number(): # type: () -> None except LeanCloudError as e: if e.code in (119, 213, 601, 605): pass - elif e.error.startswith("SMS sending exceeds limit"): + elif "SMS sending exceeds limit" in e.error: pass elif "send too frequently" in e.error: pass