Skip to content

Validating connections between open discussions, reddit, and micromasters

Alice edited this page Jan 3, 2018 · 8 revisions

Environment variables

micromasters

Verify that these environment variables look right:

  • OPEN_DISCUSSIONS_API_USERNAME - should be the username of an already existing account on open-discussions (i.e. you need to create it if it does not already exist)
  • OPEN_DISCUSSIONS_BASE_URL - The absolute base URL for the open-discussions instance, formatted like https://discussions-ci.odl.mit.edu/
  • OPEN_DISCUSSIONS_COOKIE_DOMAIN - should be odl.mit.edu
  • OPEN_DISCUSSIONS_COOKIE_NAME - should match the value for open-discussions set below
  • OPEN_DISCUSSIONS_JWT_SECRET - should look like a secret
  • OPEN_DISCUSSIONS_REDIRECT_URL - should be the same as OPEN_DISCUSSIONS_BASE_URL
  • MICROMASTERS_CORS_ORIGIN_WHITELIST - should be a list of one item, the open-discussions host (same as from OPEN_DISCUSSIONS_BASE_URL) ['discussions-ci.odl.mit.edu']

open-discussions

Verify that these environment variables look right:

  • OPEN_DISCUSSIONS_REDDIT_CLIENT_ID - should look like a client id
  • OPEN_DISCUSSIONS_REDDIT_SECRET - should look like a secret
  • OPEN_DISCUSSIONS_REDDIT_URL - should be the base URL for reddit, formatted like https://discussions-reddit-ci.odl.mit.edu
  • OPEN_DISCUSSIONS_REDDIT_ACCESS_TOKEN - should look like an access token
  • OPEN_DISCUSSIONS_JWT_SECRET - should look like a secret
  • OPEN_DISCUSSIONS_CORS_ORIGIN_WHITELIST - should be a list of one item, the micromasters host. For example: ['micromasters-ci.odl.mit.edu']
  • OPEN_DISCUSSIONS_COOKIE_NAME - should be some value, matching the same environment variable on micromasters, and unique between deployments on the same domain

reddit

Verify that access to reddit is protected using OPEN_DISCUSSIONS_REDDIT_ACCESS_TOKEN in the header. You should not be able to see reddit without this token in your header. This URL should match OPEN_DISCUSSIONS_REDDIT_URL

On the reddit instance go to /prefs/apps. Verify that OPEN_DISCUSSIONS_REDDIT_CLIENT_ID matches the value right under the title of one of the 'developed applications'. Click 'edit' and match the 'secret' to OPEN_DISCUSSIONS_REDDIT_SECRET.

Go to this URL, substituting your base URL and admin username

https://your.reddit.base.url.here/api/v1/generate_refresh_token?username=your_admin_username_here

You should see a JSON object being returned with an access and refresh token. If this fails, check that refresh_token is part of the list of plugins. Also check that you have this configuration in reddit:

[secrets]
generate_refresh_token_client_id = client_id

Where client_id matches the value of OPEN_DISCUSSIONS_REDDIT_CLIENT_ID

Integration

Also verify that:

  • both base URLs end with odl.mit.edu, to match the value set for the cookie domain above.
  • OPEN_DISCUSSIONS_JWT_SECRET matches between open-discussions and micromasters.
  • A user exists on open-discussions with the same username as the value for OPEN_DISCUSSIONS_API_USERNAME
  • The right feature flags are turned on in micromasters: FEATURE_OPEN_DISCUSSIONS_CREATE_CHANNEL_UI, FEATURE_OPEN_DISCUSSIONS_POST_UI, FEATURE_OPEN_DISCUSSIONS_USER_SYNC.

Initial Setup

  • On micromasters run ./manage.py backfill_discussion_users and wait until the celery task completes. Check that there are no celery errors.

Functional testing

To validate that the applications work correctly:

  • Login as a user and view `/dashboard'. You should see a list of recent posts (this list will probably be empty at this point).
  • Login as a user with a staff role. Go to /learners and check that you see a button to create a discussion channel.
  • Open your browser console. Go to /discussions. You should be redirected to open-discussions front page. You should see no relevant console errors.