Commit graph

30 commits

Author SHA1 Message Date
David Arnold
d4382dc020
feat: add allowed referrers to loosen csrf prevention (#27841)
* fix: add allowed referrers to loosen csrf prevention

* feat: Add test case for is_allowed_referrer functionality
2024-11-15 12:09:53 +05:30
David Arnold
c114e5fae8
refactor: unit vs integration treewide (#27992)
* refactor: constitute unit test case

* fix: docs and type hints

* refactor: mark presumed integration test cases explicitly

At time of writing, we now have at least two base test classes:

- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase

They load in their perspective priority queue during execution.

Probably more to come for more efficient queing and scheduling.

In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.

* feat: Move test-related functions from test_runner.py to tests/utils.py

* refactor: add bare UnitTestCase to all doctype tests

This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
2024-10-06 09:43:36 +00:00
Ankush Menat
618c2e60a1 test: fix failing tests 2024-04-08 18:55:05 +05:30
Ankush Menat
72c2207e0f refactor: useless use of dict in frappe.get_doc 2024-02-10 12:52:38 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
70a6a8334f
fix: set same cookie expiry as client side (#24560) 2024-01-29 05:52:40 +00:00
Ankush Menat
484049c5ae
fix: simultenous sessions ux (#24387)
* fix: set 2 as simultaneous_sessions by default

* fix: Correct offset for simultaneous_sessions

* refactor: use freeze_time instead of patching

* chore: misleading docstring

* test: set lower simultaneous_sessions for test
2024-01-16 13:36:05 +00:00
Ankush Menat
f4f6d97d06 refactor: make login tracker support arbitrary keys 2023-10-17 17:18:11 +05:30
Ankush Menat
970a740164
revert: #22308 (#22389)
* Revert "chore: move function to correct file"

This reverts commit ebfdfa283b.

* Revert "refactor!: merge get_site_url into get_url (#22308)"

This reverts commit 2001bc278f.
2023-09-13 14:34:52 +05:30
David Arnold
2001bc278f
refactor!: merge get_site_url into get_url (#22308)
* chore: merge get_site_url into get_url

* fix: keep alias with deprecation notice
2023-09-11 15:09:05 +05:30
Ankush Menat
0e1236b6be refactor: Simplify expiry queries.
Dont rely on mysql dateutils, simply compare dates with a cutoff.
2023-06-28 18:05:12 +05:30
Ankush Menat
3d0888a5d5 refactor: set_value usage 2023-06-13 16:00:43 +05:30
Ankush Menat
a43a0149eb refactor: improve test, rate limiting 2022-12-30 13:42:42 +05:30
Shariq Ansari
289aa9a13b test: test valid & invalid key 2022-12-21 14:43:10 +05:30
Nikhil Kothari
89b2e5133f
feat: option to disable user pass based login (#18000)
* Added checkbox to disable pass login in settings

* Added user_pass disable option in Login page context

* Hide user-pass fields when option disabled

* Added check for social login key and LDAP

* feat: Disable API based usr-pwd login

* style: format with black

* refactor: simpify auth validation

No need for else clause

* refactor: fixup sys setting json and move field

* refactor: sys settings validation

* refactor: simpler imports

* chore: undo unintional changes

* test: add test for disabled user pass

Co-authored-by: Ankush Menat <ankush@frappe.io>
2022-09-06 13:48:00 +05:30
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Gavin D'souza
7136106e3d test: Clear cache on updating system settings 2022-01-12 16:14:24 +05:30
Gavin D'souza
73dc1b567d test: Added test for deny_multiple_sessions 2022-01-05 14:13:00 +05:30
Gavin D'souza
069bcec0aa refactor: TestAuth
* Made it easier to run locally :')
* Moved content in setupclass rather than class init
2022-01-05 14:11:35 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Gavin D'souza
b8f2c979b5 ci: Remove test suite TestFrappeHTTPRequest
Remove tests for HTTPRequest under test_auth because Frappe
develop CI started breaking after PR merge
2021-07-24 01:56:29 +05:30
Gavin D'souza
2ccfb547b5 test: Added test to check sanity of HTTPRequest.set_lang 2021-07-15 01:11:10 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Suraj Shetty
8875848355 perf(test): Reduce token expiry wait time for test
- Also, reduce lock_interval
2021-05-06 14:49:19 +05:30
Walstan Baptista
a15e1a7d59
test: sort folders and files before running tests for consistency (#12689)
* fix: sorted folders list befor adding tests

* fix: sort files as well

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>

* fix: remove unnecessary cstr

* fix: minor code quality change

* test: use unique `user_email` in `TestAuth`

* test: Use unique username for auth test

* test: Delete DocType Doc A completely after test is done

* test: Fix permission issue & typo in test cases

Co-authored-by: Sagar Vora <sagar@resilient.tech>
Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
Co-authored-by: Suraj Shetty <surajshetty3416@gmail.com>
2021-03-26 12:33:46 +00:00
Leela vadlamudi
2984026035
fix: Login with username fails (#12658)
With the recent refactoring we missed to include username check in auth
flow. Added test cases along with the fix.
2021-03-24 21:18:37 +05:30
leela
b22f53e74b test: basic authentication test is added 2021-03-22 19:17:57 +05:30
leela
6e5e0890f3 refactor: Cleaned authentication logic
Auth flow is changed to use login attempt tracker.
2021-02-22 21:11:18 +05:30
leela
49317ce045 refactor: Track login attempts of a user
Existing login attempt tracker is a set of funcions those are not easy
to understand. Created a tracker class that handles all tracker logic and provides
useful methods to access.

Testcases added for the same.
2021-02-22 21:08:33 +05:30