10000 Validate SQS dev endpoints (#11620) · localstack/localstack@56f6a78 · GitHub
[go: up one dir, main page]

Skip to content

Commit 56f6a78

Browse files
authored
Validate SQS dev endpoints (#11620)
1 parent 5c8320a commit 56f6a78

File tree

3 files changed

+98
-2
lines changed

3 files changed

+98
-2
lines changed

localstack-core/localstack/openapi.yaml

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ info:
88
checks, plugins, initialisation hooks, service introspection, and more.
99
termsOfService: https://www.localstack.cloud/legal/tos
1010
title: LocalStack REST API for Community
11-
version: 3.6.1.dev
11+
version: latest
1212
externalDocs:
1313
description: LocalStack Documentation
1414
url: https://docs.localstack.cloud
@@ -211,6 +211,58 @@ components:
211211
- error
212212
- subscription_arn
213213
type: object
214+
ReceiveMessageRequest:
215+
type: object
216+
description: https://github.com/boto/botocore/blob/develop/botocore/data/sqs/2012-11-05/service-2.json
217+
required:
218+
- QueueUrl
219+
properties:
220+
QueueUrl:
221+
type: string
222+
format: uri
223+
AttributeNames:
224+
type: array
225+
items:
226+
type: string
227+
MessageSystemAttributeNames:
228+
type: array
229+
items:
230+
type: string
231+
MessageAttributeNames:
232+
type: array
233+
items:
234+
type: string
235+
MaxNumberOfMessages:
236+
type: integer
237+
VisibilityTimeout:
238+
type: integer
239+
WaitTimeSeconds:
240+
type: integer
241+
ReceiveRequestAttemptId:
242+
type: string
243+
ReceiveMessageResult:
244+
type: object
245+
description: https://github.com/boto/botocore/blob/develop/botocore/data/sqs/2012-11-05/service-2.json
246+
properties:
247+
Messages:
248+
type: array
249+
items:
250+
$ref: '#/components/schemas/Message'
251+
Message:
252+
type: object
253+
properties:
254+
MessageId:
255+
type: [string, 'null']
256+
ReceiptHandle:
257+
type: [string, 'null']
258+
MD5OfBody:
259+
type: [string, 'null']
260+
Body:
261+
type: [string, 'null']
262+
Attributes:
263+
type: object
264+
MessageAttributes:
265+
type: object
214266
CloudWatchMetrics:
215267
additionalProperties: false
216268
properties:
@@ -529,14 +581,52 @@ paths:
529581
'200':
530582
content:
531583
text/xml: {}
584+
application/json:
585+
schema:
586+
$ref: '#/components/schemas/ReceiveMessageResult'
532587
description: SQS queue messages
533588
'400':
534589
content:
535590
text/xml: {}
591+
application/json: {}
536592
description: Bad request
537593
'404':
538594
content:
539595
text/xml: {}
596+
application/json: {}
597+
description: Not found
598+
post:
599+
summary: Retrieves one or more messages from the specified queue.
600+
description: |
601+
This API receives messages from an SQS queue.
602+
https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html#API_ReceiveMessage_ResponseSyntax
603+
operationId: receive_message
604+
requestBody:
605+
required: true
606+
content:
607+
application/x-www-form-urlencoded:
608+
schema:
609+
$ref: '#/components/schemas/ReceiveMessageRequest'
610+
application/json:
611+
schema:
612+
$ref: '#/components/schemas/ReceiveMessageRequest'
613+
responses:
614+
'200':
615+
content:
616+
text/xml: {}
617+
application/json:
618+
schema:
619+
$ref: '#/components/schemas/ReceiveMessageResult'
620+
description: SQS queue messages
621+
'400':
622+
content:
623+
text/xml: {}
624+
application/json: {}
625+
description: Bad request
626+
'404':
627+
content:
628+
text/xml: {}
629+
application/json: {}
540630
description: Not found
541631
/_aws/sqs/messages/{region}/{account_id}/{queue_name}:
542632
get:
@@ -566,14 +656,19 @@ paths:
566656
'200':
567657
content:
568658
text/xml: {}
659+
application/json:
660+
schema:
661+
$ref: '#/components/schemas/ReceiveMessageResult'
569662
description: SQS queue messages
570663
'400':
571664
content:
572665
text/xml: {}
666+
application/json: {}
573667
description: Bad request
574668
'404':
575669
content:
576670
text/xml: {}
671+
application/json: {}
577672
description: Not found
578673
/_localstack/config:
579674
get:

localstack-core/localstack/services/sqs/provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ def __init__(self, stores=None):
624624
self.service = load_service("sqs-query")
625625
self.serializer = create_serializer(self.service)
626626

627-
@route("/_aws/sqs/messages")
627+
@route("/_aws/sqs/messages", methods=["GET", "POST"])
628628
@aws_response_serializer("sqs-query", "ReceiveMessage")
629629
def list_messages(self, request: Request) -> ReceiveMessageResult:
630630
"""

tests/aws/services/sqs/test_sqs_backdoor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def _parse_attribute_map(json_message: dict) -> dict[str, str]:
2626
return {attr["Name"]: attr["Value"] for attr in json_message["Attribute"]}
2727

2828

29+
@pytest.mark.usefixtures("openapi_validate")
2930
class TestSqsDeveloperEndpoints:
3031
@markers.aws.only_localstack
3132
@pytest.mark.parametrize("strategy", ["standard", "domain", "path"])

0 commit comments

Comments
 (0)
0