From 3172000aba1a9db3f009a158bdb1f0b0ce5e83f3 Mon Sep 17 00:00:00 2001 From: Troy Sankey Date: Fri, 8 Jun 2018 14:45:39 -0400 Subject: [PATCH] [edxnotes] use the correct url and update the API params This is really two separate things: 1. Fix the notes retirement endpoint to generate the correct notes API url "/api/v1/annotations/" rather than the nonexistent "/api/v1/". 2. Update the API params to use "user" rather than "user_id". This depends on another PR in edx/edx-notes-api to make the corresponding change on the API side. This is required because "user" is the hard-coded key that the permissions class uses to check the JWT token user. --- lms/djangoapps/edxnotes/helpers.py | 4 ++-- lms/djangoapps/edxnotes/tests.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/edxnotes/helpers.py b/lms/djangoapps/edxnotes/helpers.py index e01c0cc539..8c42da5ef7 100644 --- a/lms/djangoapps/edxnotes/helpers.py +++ b/lms/djangoapps/edxnotes/helpers.py @@ -131,12 +131,12 @@ def delete_all_notes_for_user(user): Raises: EdxNotesServiceUnavailable - when notes api is not found/misconfigured. """ - url = get_internal_endpoint() + url = get_internal_endpoint('annotations') headers = { "x-annotator-auth-token": get_edxnotes_id_token(user), } data = { - "user_id": anonymous_id_for_user(user, None) + "user": anonymous_id_for_user(user, None) } try: response = requests.delete( diff --git a/lms/djangoapps/edxnotes/tests.py b/lms/djangoapps/edxnotes/tests.py index 173c696871..be0ff35194 100644 --- a/lms/djangoapps/edxnotes/tests.py +++ b/lms/djangoapps/edxnotes/tests.py @@ -543,12 +543,12 @@ class EdxNotesHelpersTest(ModuleStoreTestCase): mock_get_id_token.return_value = "test_token" helpers.delete_all_notes_for_user(self.user) mock_delete.assert_called_with( - url='http://example.com/', + url='http://example.com/annotations/', headers={ 'x-annotator-auth-token': 'test_token' }, data={ - 'user_id': 'anonymous_id' + 'user': 'anonymous_id' }, timeout=(settings.EDXNOTES_CONNECT_TIMEOUT, settings.EDXNOTES_READ_TIMEOUT) )