Skip to content

Commit

Permalink
Merge pull request #622 from praekeltfoundation/update-new-aaq-auth
Browse files Browse the repository at this point in the history
update update authorization Bearer
  • Loading branch information
Hlamallama authored Sep 4, 2024
2 parents b494319 + 1b2ae97 commit 54d613c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aaq/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def send_feedback_task_v2(feedback_secret_key, query_id, content_id=None, **kwar

url = urljoin(settings.AAQ_V2_API_URL, path)
headers = {
"Authorization": settings.AAQ_V2_AUTH,
"Authorization": f"Bearer {settings.AAQ_V2_AUTH}",
"Content-Type": "application/json",
}
response = requests.post(url, json=data, headers=headers)
Expand Down
2 changes: 2 additions & 0 deletions aaq/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_search_function(self):
self.assertIn("query_id", response)
self.assertEqual(response["query_id"], 1)
self.assertEqual(json.loads(search_request.request.body), payload)
self.assertIn("Bearer", search_request.request.headers["Authorization"])
assert response == {
"message": "*0* - Example content title\n"
"*1* - Another example content title",
Expand Down Expand Up @@ -94,6 +95,7 @@ def test_urgency_check(self):
self.assertIn("is_urgent", response)
self.assertIn("matched_rules", response)
self.assertEqual(json.loads(request.request.body), message_text)
self.assertIn("Bearer", request.request.headers["Authorization"])

assert response == {
"details": {
Expand Down
6 changes: 6 additions & 0 deletions aaq/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ def test_response_feedback_view(self):

response = self.client.post(self.url, data=payload, format="json")

request = responses.calls[0]

assert response.status_code == 200
self.assertIn("Bearer", request.request.headers["Authorization"])

def test_response_feedback_invalid_view(self):
"""Test that we can submit response feedback"""
Expand Down Expand Up @@ -488,7 +491,10 @@ def test_content_feedback_view(self):

response = self.client.post(self.url, data=payload, format="json")

request = responses.calls[0]

assert response.status_code == 200
self.assertIn("Bearer", request.request.headers["Authorization"])

def test_content_feedback_invalid_view(self):
"""Test that we can submit content feedback"""
Expand Down
4 changes: 2 additions & 2 deletions aaq/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def check_urgency_v2(message_text):
url = urllib.parse.urljoin(settings.AAQ_V2_API_URL, "check-urgency")
headers = {
"Authorization": settings.AAQ_V2_AUTH,
"Authorization": f"Bearer {settings.AAQ_V2_AUTH}",
"Content-Type": "application/json",
}

Expand All @@ -27,7 +27,7 @@ def search(query_text, generate_llm_response, query_metadata):
"query_metadata": query_metadata,
}
headers = {
"Authorization": settings.AAQ_V2_AUTH,
"Authorization": f"Bearer {settings.AAQ_V2_AUTH}",
"Content-Type": "application/json",
}

Expand Down

0 comments on commit 54d613c

Please sign in to comment.