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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update update authorization Bearer #622

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading