diff --git a/en_us/install_operations/source/ecommerce/test_ecommerce.rst b/en_us/install_operations/source/ecommerce/test_ecommerce.rst index 9c135d8f73e..d1721af17fc 100644 --- a/en_us/install_operations/source/ecommerce/test_ecommerce.rst +++ b/en_us/install_operations/source/ecommerce/test_ecommerce.rst @@ -137,74 +137,180 @@ Configure the LMS To configure the LMS, follow these steps. -#. Verify that the following settings in ``lms.env.json`` are correct. +#. Ensure devstack Vagrant virtual machine ("**VM**") is up and running. - .. code-block:: bash + .. code:: sh - "ECOMMERCE_API_URL": "http://localhost:8002/api/v2/" - "ECOMMERCE_PUBLIC_URL_ROOT": "http://localhost:8002/" - "JWT_ISSUER": "http://127.0.0.1:8000/oauth2" // Must match the E-Commerce JWT_ISSUER setting - "OAUTH_ENFORCE_SECURE": false - "OAUTH_OIDC_ISSUER": "http://127.0.0.1:8000/oauth2" + vagrant up -#. Verify that the following settings in ``lms.auth.json`` are correct. +#. Login into the VM. - .. code-block:: bash + .. code:: sh - "EDX_API_KEY": "replace-me" // Must match the E-Commerce EDX_API_KEY setting - "ECOMMERCE_API_SIGNING_KEY": "insecure-secret-key" // Must match the E-Commerce JWT_SECRET_KEY setting + vagrant ssh + +#. Become the ``edxapp`` user. + + .. code:: sh + + sudo su edxapp + +#. Verify that the following settings in ``/edx/app/edxapp/lms.env.json`` are + correct. :: + + "ECOMMERCE_API_URL": "http://localhost:8002/api/v2/" + "ECOMMERCE_PUBLIC_URL_ROOT": "http://localhost:8002" + "JWT_ISSUER": "http://127.0.0.1:8000/oauth2" // Must match the E-Commerce JWT_ISSUER setting + "OAUTH_ENFORCE_SECURE": false + "OAUTH_OIDC_ISSUER": "http://127.0.0.1:8000/oauth2" + +#. Verify that the following settings in ``/edx/app/edxapp/lms.auth.json`` are + correct. :: + + "ECOMMERCE_API_SIGNING_KEY": "lms-secret" // Must match the E-Commerce JWT_SECRET_KEY setting + "EDX_API_KEY": "PUT_YOUR_API_KEY_HERE" // Must match the E-Commerce EDX_API_KEY setting #. Verify that an LMS account with staff and superuser permissions exists. - By default, most devstack and fullstack LMS instances include a user account - that has staff permissions. This account has the username ``staff``, the - email address ``staff@example.com``, and the password ``edx``. Run the - following commands to grant the account superuser permissions. + By default, most devstack and fullstack LMS instances include a user + account that has staff permissions. This account has the username + ``staff``, the email address ``staff@example.com``, and the password + ``edx``. Run the following commands to grant the account superuser + permissions. + + .. code:: sh + + cd ~/edx-platform + ./manage.py lms set_superuser staff --settings=devstack - .. code-block:: bash +#. Start LMS. - $ ``./manage.py lms shell --settings=devstack`` - >>> from django.contrib.auth.models import User - >>> u = User.objects.get(username='staff') - >>> u.is_superuser = True - >>> u.save() + .. code:: sh -#. In the Django administration panel, verify that an OAuth2 client with the - following attributes exists. If one does not already exist, :ref:`create a - new one `. The client ID and secret must match the - values of the E-Commerce ``SOCIAL_AUTH_EDX_OIDC_KEY`` and - ``SOCIAL_AUTH_EDX_OIDC_SECRET`` settings, respectively. + cd ~/edx-platform + paver devstack lms - .. code-block:: bash +#. Navigate to the `Oauth2 Clients section`_ of `Django adminstration`_, at + http://localhost:8000/admin/oauth2/client/. Login using th staff account + designated in step 5. - URL: http://localhost:8002/ - Redirect URI: http://localhost:8002/complete/edx-oidc/ - Client ID: 'replace-me' - Client Secret: 'replace-me' - Client Type: Confidential + Verify that an OAuth2 client with the following attributes exists. If one + does not already exist, :ref:`create a new one `. + The client ID and secret must match the values of the E-Commerce + ``SOCIAL_AUTH_EDX_OIDC_KEY`` and ``SOCIAL_AUTH_EDX_OIDC_SECRET`` settings, + respectively. :: -#. In the Django administration panel, verify that the OAuth2 client referred - to above is designated as a trusted client. If this isn't already the case, - add the client created above as a new trusted client. + Name: ecommerce + URL: http://localhost:8002/ + Redirect URI: http://localhost:8002/complete/edx-oidc/ + Client ID: 'ecommerce-key' + Client Secret: 'ecommerce-secret' + Client Type: Confidential (Web applications) + Logout url: http://localhost:8002/logout/ -#. In the Django administration panel, create a new access token for the - superuser account. Set the client to the OAuth2 client referred to above. - Make note of this token; it is required to run the acceptance tests. +#. Navigate to the `Edx\_Oauth2\_Provider Trusted clients section`_ + of `Django administration`_, at + http://localhost:8000/admin/edx_oauth2_provider/trustedclient/. + + Verify that the OAuth2 client referred to above is designated as a + trusted client (look for the Redirect URI). If this isn't already + the case, add the client created above as a new trusted client. + +#. In the Django administration panel, create a new access token for + the superuser account. Set the client to the OAuth2 client referred + to above. Make note of this token; it is required to run the + acceptance tests. + +#. Make sure that the LMS instance that you will use for testing has at + least two courses that learners could enroll in. By default, most + LMS instances include the edX demonstration course. Use Studio to + create a second course. + +.. _Django administration: http://localhost:8000/admin/ +.. _Django adminstration: http://localhost:8000/admin/ +.. _Edx\_Oauth2\_Provider Trusted clients section: http://localhost:8000/admin/edx_oauth2_provider/trustedclient/ +.. _Oauth2 Clients section: http://localhost:8000/admin/oauth2/client/ -#. Make sure that the LMS instance that you will use for testing has at least - two courses that learners could enroll in. By default, most LMS instances - include the edX demonstration course. Use Studio to create a second course. Configure E-Commerce ******************** -You use the CAT to finish configuring the two courses in your LMS instance. +You use the Course Administration Tool ("**CAT**") to finish configuring the +two courses in your LMS instance. + +#. Become the ``ecommerce`` user. + + .. code:: sh + + sudo su ecommerce + +#. Verify the following keys in ``/edx/etc/ecommerce.yml`` match your + settings in ``/edx/app/edxapp/lms.env.json`` and + ``/edx/app/edxapp/lms.auth.json``. -#. In your browser, go to ``http://localhost:8002/courses/`` to access the CAT. + - One of the ``JWT_AUTH:JWT_ISSUERS`` entries should match + ``/edx/app/edxapp/lms.env.json:JWT_ISSUER``, default value is + ``http://127.0.0.1:8000/oauth2``. + - ``JWT_AUTH:JWT_SECRET_KEY`` should match + ``/edx/app/edxapp/lms.auth.json:ECOMMERCE_API_SIGNING_KEY``, + default value is ``lms-secret``. + - ``EDX_API_KEY`` should match + ``/edx/app/edxapp/lms.auth.json:EDX_API_KEY``, default value is + ``PUT_YOUR_API_KEY_HERE``. -#. In the CAT, add both of the courses present on your LMS instance to - E-Commerce. Configure one as a "Free (Audit)" course, and the second as a - "Verified" course. +#. Set up the E-Commerce environment. + + .. code:: sh + + cd /edx/app/ecommerce/ecommerce + source ../ecommerce_env + source ../venvs/ecommerce/bin/activate + make requirements + make static + make migrate + +#. Create a new site linking to LMS. + + .. code:: sh + + ./manage.py create_or_update_site \ + --site-id=1 \ + --site-domain=localhost:8002 \ + --partner-code=edX \ + --partner-name='Open edX' \ + --lms-url-root=http://localhost:8000 \ + --theme-scss-path=sass/themes/edx.scss \ + --payment-processors=cybersource,paypal \ + --client-id=ecommerce-key \ + --client-secret=ecommerce-secret \ + --from-email staff@example.com + +#. Start the E-Commerce Django development server. + + .. code:: sh + + ./manage.py runserver 0.0.0.0:8002 + +#. Get the course key from LMS by navigating to a course and examining + its URL. It should looks something like + ``course-v1:edX+DemoX+Demo_Course``. + +#. Navigate to `E-Commerce Courses section`_ and add a new course. Leave + all fields at default, with the exception of the following. + + :: + + Course ID: The course key from LMS + Course Name: Use any name + Course Type: Verified + Include Honor Seat: No + +#. Navigate to `LMS Dashboard`_ and verify the course you added in + E-Commerce now has a green "Upgrade to Verified" badge, which you can + click on. + +#. In the CAT, add the second course present on your LMS instance to + E-Commerce. Configure it as a "Free (Audit)" course. #. So that you can test integration with external payment processors, update the contents of the ``PAYMENT_PROCESSOR_CONFIG`` dictionary found in the @@ -217,8 +323,10 @@ You use the CAT to finish configuring the two courses in your LMS instance. :ref:`set up your virtual environment `, you can use that same ``private.py`` file. - .. _Configure Acceptance Tests: +.. _E-Commerce Courses section: http://localhost:8002/courses/ +.. _LMS Dashboard: http://localhost:8000/dashboard + Configure Acceptance Tests *********************************