How To Test the Course Embargo Feature
On A Sandbox
Suppose you've made some changes to the course embargo feature and you want to see if it still works. Try these steps:
SSH into the sandbox and connect to the sandbox MySQL DB using the information in lms.auth.json.
Issue this SQL:Â
- To allow the "staff" user to access the Django admin interface:
- update auth_user set is_superuser=1 where username='staff';
- To allow the "staff" user to access the embargo models:
- insert into auth_user_user_permissions (user_id, permission_id) VALUES (5, 497), (5,498), (5,499),(5,500),(5,501),(5,502),(5,503),(5,504),(5,506),(5,507),(5,508),(5,509),(5,510),(5,511),(5,512),(5,513),(5,514),(5,515),(5,516),(5,517),(5,518);
- To allow the "staff" user to access the Django admin interface:
Login as "staff@example.com" and go to the admin interface here:
http://your_sandbox.sandbox.edx.org/admin/embargo/Add a course restriction in the admin interface for a course (like the demo course). The course key should be in this format: course-v1:edX+DemoX+Demo_Course
- Add a country access rule, picking a random "CountryX" to embargo.
- Modify lms.env.json to add the following line in the FEATURES section of the Django settings:
- "EMBARGO": true,
- Restart the LMS/CMS as your user (*not* edxapp) while SSH-ed into the sandbox:
- sudo /edx/bin/supervisorctl restart edxapp:*
- Login to the LMS as "honor@example.com" and set your country of origin to "CountryX".
- Ensure that you cannot access the embargoed course.
On stage.edx.org
- Open a pull request in the app-permissions repository.
- The specific file:Â https://github.com/edx/app-permissions/blob/master/stage-edx-edxapp.yml
- Add your user there and put the user in the course_embargo_admin group.
- Get the PR reviewed and merged.
- Login as your user and configure an embargoed course as specified above.
Notes
The code containing the embargo logic is here:
https://github.com/edx/edx-platform/blob/master/openedx/core/djangoapps/embargo/api.py#L45-L114
There are two ways to be denied access to courseware via embargo:
- If your account's country of origin is denied via a course's embargo country blacklist.
- If your originating IP address is determined to be from a course's embargo country blacklist.
Both checks are made and if either check is true, access is denied to the course. The steps above only trigger check 1).