Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update E-Commerce testing instructions #1417

Merged
merged 1 commit into from Mar 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
195 changes: 148 additions & 47 deletions en_us/install_operations/source/ecommerce/test_ecommerce.rst
Expand Up @@ -137,74 +137,175 @@ 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.
#. Sign in to 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

.. code-block:: bash
cd ~/edx-platform
./manage.py lms set_superuser staff --settings=devstack

$ ``./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()
#. Start the LMS.

#. 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 <Create Register Client>`. 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.
.. code:: sh

.. code-block:: bash
cd ~/edx-platform
paver devstack lms

URL: http://localhost:8002/
Redirect URI: http://localhost:8002/complete/edx-oidc/
Client ID: 'replace-me'
Client Secret: 'replace-me'
Client Type: Confidential
#. Navigate to the Oauth2 Clients section of the Django administration console
(e.g. http://localhost:8000/admin/oauth2/client/). Sign in using the
superuser account you created earlier.

#. 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.
Verify that an OAuth2 client with the following attributes exists. If one
does not already exist, :ref:`create a new one <Create Register Client>`.
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, 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.
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/

#. Navigate to the Edx\_Oauth2\_Provider Trusted clients section of the Django
administration console (e.g.
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.

#. 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 that 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``. The 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``. The default
value is ``lms-secret``.
* ``EDX_API_KEY`` should match
``/edx/app/edxapp/lms.auth.json:EDX_API_KEY``. The 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 the 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 the LMS by navigating to a course and examining its
URL. It should look something like ``course-v1:edX+DemoX+Demo_Course``.

#. Navigate to the E-Commerce Courses section (e.g.
http://localhost:8002/courses/) and add a new course. Leave the default
values in all fields, with the exception of the following.

::

Course ID: The course key from the LMS
Course Name: Use any name
Course Type: Verified
Include Honor Seat: No

#. Navigate to the learner dashboard (e.g. http://localhost:8000/dashboard) and
verify the course you added in E-Commerce now has a green "Upgrade to
Verified" badge, which you can select.

#. In the CAT, add the second course 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
Expand All @@ -217,9 +318,9 @@ You use the CAT to finish configuring the two courses in your LMS instance.
:ref:`set up your virtual environment <Set Up a Virtual Environment>`, you
can use that same ``private.py`` file.


.. _Configure Acceptance Tests:


Configure Acceptance Tests
*********************************

Expand Down