Skip to content

Commit 493bf3e

Browse files
✨(ingestion-presentation) accept token auth for upsert offer API
1 parent ee3b2aa commit 493bf3e

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/web/presentation/ingestion/views/offers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def post(self, request):
188188
},
189189
)
190190
class OffersUpsertView(APIView):
191+
authentication_classes = [JWTAuthentication, ApiKeyAuthentication]
191192
parser_classes = [JSONParser]
192193
serializer_class = UpsertOffersRequestSerializer
193194

src/web/presentation/static/api/schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ paths:
572572
required: true
573573
security:
574574
- jwtAuth: []
575+
- ApiKeyAuth: []
575576
responses:
576577
'201':
577578
content:

src/web/tests/ingestion/presentation/views/test_upsert_offers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ def test_unauthenticated_access(api_client):
162162
assert response.status_code == status.HTTP_401_UNAUTHORIZED
163163

164164

165+
def test_api_key_authentication(api_key_client, use_case):
166+
use_case.execute.return_value = {"created": 1, "updated": 0, "errors": []}
167+
response = api_key_client.post(
168+
URL,
169+
data=[MINIMAL_VALID_OFFER],
170+
content_type="application/json",
171+
)
172+
assert response.status_code == status.HTTP_201_CREATED
173+
174+
165175
def test_get_method_not_allowed(authenticated_client):
166176
response = authenticated_client.get(URL)
167177
assert response.status_code == status.HTTP_405_METHOD_NOT_ALLOWED

0 commit comments

Comments
 (0)