Commit Graph

144 Commits

Author SHA1 Message Date
Muhammad Umar Khan
10a4d12b06 feat!: remove pyjwkest (#36707)
Co-authored-by: M Umar Khan <umar.khan@A006-01609.local>
2025-06-12 14:30:32 +05:00
Kyle McCormick
32275662b0 feat!: A Better API for Derived Settings (#36192)
The Python API for declaring derived settings was confusing to the uninitiated
reader, and also prone to spelling mistakes. This replaces the API with one
that is more readable and more concise, and updates the implementation of
`derive_settings` to properly derive settings declared using the new API.

BREAKING CHANGE: The `derived` and `derived_collection_entry` function are
replaced with the `Derived` class. We do not expect those functions to have
been used outside of edx-platform, but if they are, this commit will cause them
to loudly ImportError.

Note that there should be NO change in behavior to the `derive_settings`
function, which we DO know to be used by some external edx-platform plugins.

Part of: https://github.com/openedx/edx-platform/issues/36215
2025-02-04 14:57:43 -05:00
Marcos
747289bc1a fix: Removed JWT constants from CMS and added comments on how to generate them 2025-01-23 15:55:58 -03:00
Marcos
67a56c270f chore: Moved jwt file to openedx.core.lib 2025-01-23 15:55:58 -03:00
Maria Grimaldi
809ffc3743 feat: connect teams with content groups using dynamic partition generator (#33788)
Implements the connection from the teams feature to the content groups feature. This implementation uses the dynamic partition generator extension point to associate content groups with the users that belong to a Team.

This implementation was heavily inspired by the enrollment tracks dynamic partitions.
2024-04-25 13:02:49 -04:00
Deborah Kaplan
bde84117c3 feat: linting error
* unused import
* format

FIXES: APER-3146
2024-01-30 16:36:14 +00:00
Deborah Kaplan
ae3ce9c498 feat: fix exception handling in program cert revocation
To determine whether or not we need to  revoke any program certificates, we first run get_revokable_program_uuids. This calls get_certified_programs, which calls get_credentials, which uses the OpenEdx Core  utility method get_api_data. get_api_data makes the API call inside a try block, does raise_for_status  also inside the try block, and then catches the exception, logs it, and returns an empty result to the caller.

This means that on a failure to call the credentials API, get_credentials can’t  tell the difference between a failure to hit the API (because credentials is, as it sometimes is during a notify_programs run, overloaded), or a learner with no program certificates. In this particular case, this is absolute failure, incorrect behavior.

* Adds a new flag, `raise_on_error`  which will make `get_api_data` log the exception and then re-raise the HTTPError,  defaulting to false in order to avoid changing the behavior on any other callers
* Also: my editor reformatted all of the touched files to our modern code standards, and it seemed appropriate to let it do that.
* Also: added type hints in some cases, because they helped me write the code and debug. Our test suite definitely  reports mypy  results on type errors so we are verifying that hints are correct.

FIXES: APER-3146
2024-01-26 22:20:30 +00:00
Yagnesh Nayi
d9af2dfb36 feat!: DEPR expected error part of EXPECTED_ERRORS (#33184)
Removes expected part of EXPECTED_ERRORS with a variety of changes.
- In many placed in the code, "expected" was used to mean
  "ignored and expected", and all such instances are renamed to "ignored".
- The setting ``EXPECTED_ERRORS`` is renamed to ``IGNORED_ERRORS``,
  which better matches how it was being used in the first place.
- The setting ``EXPECTED_ERRORS[REASON_EXPECTED]`` is renamed to ``IGNORED_ERRORS[REASON_IGNORED]``.
- The setting toggle ``EXPECTED_ERRORS[IS_IGNORED]`` is removed,
  because it will now always be True.
- The how-to will is renamed to how_tos/logging-and-monitoring-ignored-errors.rst.

See 0002-logging-and-monitoring-expected-errors-removed.rst for more details.

Implements DEPR: https://github.com/openedx/edx-platform/issues/32405

**BREAKING CHANGE:** The rename of the setting ``EXPECTED_ERRORS`` to
  ``IGNORED_ERRORS``, and ``REASON_EXPECTED`` to ``REASON_IGNORED``,
  was implemented without backward compatibility. Simply copy the old settings
  with the new name as an expand phase before deleting the old names in the 
  contract phase.
2023-10-04 10:03:41 -04:00
Arunmozhi
d417a7561f refactor: rename ItemFactory to BlockFactory 2023-01-23 14:47:47 +01:00
Sagirov Eugeniy
f3de63058c test: tests for removing support for children in Old Mongo
* updated test_authoring_mixin.py
* updated test_xblock_utils.py
* updated TestOnboardingView tests (update default course key)
* updated UsersDefaultRole tests
2023-01-17 14:54:14 -05:00
Jansen Kantor
db082830e3 fix: slight change to logic of how teams is considered enabled (#31277)
* fix: slight change to logic of how teams is considered enabled

* fixup! fix: slight change to logic of how teams is considered enabled
2022-11-29 14:01:55 -05:00
Sagirov Eugeniy
8f88422c4a test: prepare tests for removing support for children in Old Mongo 2022-10-28 11:43:20 -04:00
Mohammad Ahtasham ul Hassan
44fa09eba5 refactor: refactor discussions_xblock (#30636)
JIRA: https://openedx.atlassian.net/browse/BOM-2580
This PR aims at refactoring the discussion xblock sub project and moving it within the xmodule directory effectively removing its position as a sub project within edx-platform
2022-06-27 17:11:56 +05:00
Eugene Dyudyunov
289e682b8f FC-0001: Remove old EdxRestAPIClient usage across the platform (#30301)
* refactor: remove EdxRestAPIClient

* test: update tests according to EdxRestAPIClient removal

* fix: remove unused import
2022-05-09 12:48:26 -04:00
Robert Raposa
9fa79809d8 refactor: CookieMonitoringMiddleware moved to edx-django-utils
The CookieMonitoringMiddleware and its related script
moved to edx-django-utils.

ARCHBOM-2054
2022-03-17 16:59:00 -04:00
Kaustav Banerjee
c48c655998 refactor: deprecates replace url related properties from ModuleSystem
Deprecates the following attributes from ModuleSystem:
 * replace_urls
 * replace_course_urls
 * replace_jump_to_id_urls

A new ReplaceURLService is created as replacement with a unified replace_urls method
2022-03-14 09:35:41 -04:00
Robert Raposa
78ba9f09a1 feat: add corrupt cookie header monitoring (#30039)
In case of unusual cookie headers containing "Cookie ",
add custom attributes for monitoring:
- cookies.header.corrupt_count
- cookies.header.corrupt_key_count

See annotation documentation for more details.

Separately, updated to skip cookie log sampling for
0 size cookie header.

ARCHBOM-2055
2022-03-11 14:36:26 -05:00
Robert Raposa
29e50710dc feat: enhance cookie monitoring and logging
Contains a number of cookie monitoring changes.

Enhancements:
- Add sampling capability for cookie logging on headers
 smaller than the threshold. For details, see
 COOKIE_SAMPLING_REQUEST_COUNT.
- Add cookie header size to log message.
- Sort logged cookies starting with largest cookie.
- Move logging from Middleware request processing
 to response processing to ensure the user id is
 available for logging for authenticated calls.
- Added cookies.header.size.computed to check
 if there are any large hidden duplicate cookies.
 Can be compared against the cookies.header.size
 custom attribute.
- Add delimiters into logs to make it simpler to parse
 when the logging tools accidentally exports multiple
 log lines together.

Removed:
- Legacy cookie capture code. This code was dangerous to
  to enable and provided more limited insight than the
  newer logging, so this was removed to simplify the code.

Other refactors:
- Switched Middleware to use new Django format, rather
 than the Mixin.
- Moved tests to its own test class. Note: this
 middleware is likely to move to a separate
 library.

ARCHBOM-2055
2022-03-09 20:39:27 -05:00
Tim McCormack
e218b71601 feat: Just log cookie sizes when over threshold (no encrypted contents) (#29938)
This should really be all we need for most cases, and we don't want to
emit sensitive data more than necessary, even encrypted. If we need to
inspect one cookie in particular, we can add special logging for that.

Also, change to greater-than-or-equal for threshold to match setting docs.

ref: ARCHBOM-2042
2022-02-18 19:01:37 +00:00
Michael Terry
cb1bb7fa64 test: switch default test store to the split store
It's long past time that the default test modulestore was Split,
instead of Old Mongo. This commit switches the default store and
fixes some tests that now fail:
- Tests that didn't expect MFE to be enabled (because we don't
  enable MFE for Old Mongo) - opt out of MFE for those
- Tests that hardcoded old key string formats
- Lots of other random little differences

In many places, I didn't spend much time trying to figure out how to
properly fix the test, and instead just set the modulestore to Old
Mongo.

For those tests that I didn't spend time investigating, I've set
the modulestore to TEST_DATA_MONGO_AMNESTY_MODULESTORE - search for
that string to find further work.
2022-02-04 14:32:50 -05:00
Jillian Vogel
2173a98ef8 refactor: deprecates ModuleSystem properties for code sandboxing and cache
* Deprecates ModuleSystem can_execute_unsafe_code, get_python_lib_zip and cache properties
* Adds a new CacheService and SandboxService to provide the deprecated property
* Adds tests for the added CacheService and SandboxService
* Updates the ModuleSystemShim tests in Lms and Studio
2022-01-25 14:42:39 +10:30
Rebecca Graber
0e9499de7d feat: log an encrypted string of the full cookie header when over threshold (#29735)
* feat: log an encrypted string of the full cookie header when over threshold
2022-01-10 13:02:47 -05:00
Jawayria
dba7d78c74 chore: Applied lint-amnesty on openedx/core/lib 2021-12-02 15:11:13 +05:00
Kshitij Sobti
ff61434893 feat: Add a new way to enable/disable teams [BD-38] [TNL-9175] [BB-5066] (#29099)
* feat: Add a new way to enable/disable teams

Adds a new mechanism for enabling/disabling the team feature in a course using an 'enabled' field to the teams config.
If this field is set to true, teams is enabled (team sets/groups) still need to be defined. If this is set to false then teams is disabled whether or not team sets are defined.

* fix: review feedback
2021-11-01 17:12:06 +05:00
Kshitij Sobti
2ecb4daece fix: update course URL match pattern to also match learning MFE (#29050)
The learning MFE paths include /course/{course_id} which doesn't match /courses/{course_id} which is what the regex expects. This causes issues with the Wiki when when accessed from the learning MFE doesn't detect that course it's related to in the middleware.
2021-10-21 20:24:40 +05:00
Rebecca Graber
bf025a9b0c feat: Add custom attribute for cookie header size
ARCHBOM-1910
2021-10-01 08:09:41 -04:00
Rebecca Graber
2ffbbeba9a chore: lint 2021-09-30 14:46:31 -04:00
Rebecca Graber
adcc9cb9b8 fix: tests 2021-09-30 14:34:57 -04:00
Usama Sadiq
d5e2ac9b0e fix: update static file path in tests (#28872)
fix similar test in openedx
2021-09-30 19:16:23 +05:00
Manjinder Singh
19b45069fa feat: adding more parameters (#28264)
* fix: adding more parameters for cookie monitoring

Added: cookies_total_num, cookies_unaccounted_size. 
  -Both are to help us gauge how many cookies we are not collecting data for.
Increased: # of cookies data collected
2021-07-26 09:11:44 -04:00
Usama Sadiq
64752ed66c refactor: pyupgrade second iteration (#27459) 2021-05-10 13:56:40 +05:00
Usama Sadiq
068ac5290f refactor: Ran pyupgrade on openedx/core
Ran pyupgrade on openedx/core/{lib, tests}
2021-04-08 18:34:38 +05:00
M. Zulqarnain
072b6b8875 Revert "chore: Unpin python-dateutil (#27196)" (#27217)
This reverts commit 40878cd554.
2021-04-01 23:32:51 +05:00
M. Zulqarnain
40878cd554 chore: Unpin python-dateutil (#27196) 2021-04-01 19:53:02 +05:00
Robert Raposa
d4bbd9d03e fix: move ignored error message custom attribute (#27047)
The `error_expected` custom attribute used to contain
both the class name and the error message. This had
the following issues:

* Combining data in the same custom attribute limits
the ability to query.
* The additional error class and message data is only
needed for ignored errors, since this data isn't
available elsewhere.

The following changes were made:
* `error_expected` will always have the value True
if present.
* `error_ignored` no longer exists.
* `error_ignored_class` will contain the error module
and class for ignored errors.
* `error_ignored_message` will contain the error message
for ignored errors.

ARCHBOM-1708
2021-03-18 10:37:47 -04:00
Robert Raposa
2c0a8242f7 ARCHBOM-1708: feat: monitor and log expected errors (#26980)
Adds logging and monitoring capabilities for expected
errors. See the ADR and how-to  documentation for
details of how to configure and use the EXPECTED_ERRORS
setting and new monitoring and logging.

ARCHBOM-1708

Co-authored-by: Tim McCormack <tmccormack@edx.org>
2021-03-17 07:27:13 -04:00
Usman Khalid
dd96a2aa72 Convert Course, Section and Sequence XModules to XBlocks. (#25965) 2021-03-02 10:29:33 -05:00
Aarif
813064ad49 replaced unittest assertions pytest assertions (#26574) 2021-02-22 20:04:51 +05:00
Jawayria
9909b933a7 Applied pylint-amnesty to openedx/core/{djangolib, lib, tests, *.py 2021-02-02 21:13:24 +05:00
Robert Raposa
8b4ea05d5e fix cookie monitoring middleware
The cases of no cookies or no cookie groups
found would cause an error. This was fixed
and additional test coverage was added.
2021-01-15 15:07:22 -05:00
Feanil Patel
e5e2b7f7b6 Only capture the top N cookies and cookie groups.
Instead of adding new attributes for each cookie name we create
consistent attribute names.  This should prevent any issues where we
have too many different unique attribute names because the cookie names
are unique to the user.

We added two new settings to make the number of cookies and groups
capture configurable:

- TOP_N_COOKIES_CAPTURED
- TOP_N_COOKIE_GROUPS_CAPTURED
2021-01-14 15:49:15 -05:00
Feanil Patel
1a1da89f55 Drop setting attributes for the size of each cookie.
Setting a new metric per cookie name resulted in a lot of metrics
getting added to New Relic.  In some cases, this was causing other
more important metrics to not get registered.
2021-01-14 11:03:28 -05:00
Feanil Patel
1ae50fc466 Add more cookie logging code.
We want to be able to easily figure out what our biggest cookies are and we
want to also group cookies by prefix because certain services create multiple
cookies and then put unique identifiers in the cookie name.

For example braze cookie names use the following pattern:
    ab.storage.<userId>
    ab.storage.<deviceId>
    ab.storage.<sessionId>

In this case we want to group all the `ab` cookies together so we can see
their total size.

New attributes:

cookies.<group_prefix>.group.size: The size of a group of cookies. For example
	the sum of the size of all braze cookies would be the value of the
	`cookies.ab.group.size` attribute.
cookies.max.name: The name of the largest cookie sent by the user.
cookies.max.size: The size of the largest cookie sent by the user.
cookies.max.group.name: The name of the largest group of cookies. A single cookie
	counts as a group of one for this calculation.
cookies.max.group.size: The sum total size of all the cookies in the largest group.
2021-01-14 09:55:49 -05:00
Kyle McCormick
151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00
Manjinder Singh
c76ed6ae45 Extracting plugin app from edx-platform (#24678)
* Moving plugins infrastructure to edx-django-utils
This PR extracts the code that enables plugins in edx-platform and puts it in edx-django-utils. This is done to allow other IDAS to add plugin functionality.
2020-08-12 07:48:53 -04:00
Danial Malik
c962423bbc Replace track calls with eventtracking in task_track and server_track (#24282)
* Replace track calls with eventtracking in task_track and server_track

* Making  events compatible with events emitted via track app

* Fixed broken tests and quality violation

* Removed useless changes in shim. using  in  to have  and  keys in event context

Co-authored-by: zia.fazal@arbisoft.com <zia.fazal@arbisoft.com>
2020-06-26 13:49:16 -04:00
Aarif
6ee2089077 fixed warnings for wrong-import-order 2020-04-08 23:43:06 +05:00
Manjinder Singh
4399d13955 removing all of provider (#23269)
* Revert "Ran make migration on third_party_auth (#23253)"

This reverts commit 49be65cc58.

* Removing provider.util import

* Removing further provider things

* Adding hash tests
2020-03-03 10:42:18 -05:00
Jansen Kantor
0e0b488fb5 EDUCATOR-4876: Correctly handle 'None' as a valid max_team_size (#23038)
add default max team sizes, change ui to not show max for managed teams
2020-02-18 16:44:20 -05:00
Feanil Patel
046feb0cf0 Merge pull request #22649 from edx/feanil/fix_pep8
Fix all E303 pep8 errors.
2019-12-30 13:32:26 -05:00