Skip to content

Add REST-JSON Content-Type tests #2756

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

Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
[
{
"description": "TestBody",
"given": {
"input": {
"testConfig": {
"timeout": 10
},
"testId": "t-12345"
}
},
"when": {
"action": "marshall",
"operation": "TestBody"
},
"then": {
"serializedAs": {
"uri": "/body",
"method": "POST",
"headers": {
"contains": {
"x-amz-test-id": "t-12345",
"Content-Type": "application/json"
}
},
"body": {
"jsonEquals": "{\"testConfig\": {\"timeout\": 10}}"
}
}
}
},
{
"description": "TestPayloadNoParams",
"given": {
"input":{
}
},
"when": {
"action": "marshall",
"operation": "TestPayload"
},
"then": {
"serializedAs": {
"uri": "/payload",
"method": "POST",
"headers": {
"contains": {
"Content-Type": "application/json"
}
},
"body": {
"jsonEquals": "{}"
}
}
}
},
{
"description": "TestPayload",
"given": {
"input": {
"payloadConfig": {
"data": 25
},
"testId": "t-12345"
}
},
"when": {
"action": "marshall",
"operation": "TestPayload"
},
"then": {
"serializedAs": {
"uri": "/payload",
"method": "POST",
"headers": {
"contains": {
"x-amz-test-id": "t-12345",
"Content-Type": "application/json"
}
},
"body": {
"jsonEquals": "{\"data\": 25}"
}
}
}
},
{
"description": "TestPayloadNoBody",
"given": {
"input": {
"testId": "t-12345"
}
},
"when": {
"action":"marshall",
"operation":"TestPayload"
},
"then": {
"serializedAs": {
"uri": "/payload",
"method": "POST",
"headers": {
"contains": {
"x-amz-test-id": "t-12345",
"Content-Type": "application/json"
}
},
"body": {
"jsonEquals": "{}"
}
}
}
},
{
"description": "TestBlobPayload",
"given": {
"input": {
"data": "1234",
"contentType": "image/jpg"
}
},
"when": {
"action": "marshall",
"operation": "TestBlobPayload"
},
"then": {
"serializedAs": {
"uri": "/blob-payload",
"method": "POST",
"headers": {
"contains": {
"Content-Type": "image/jpg"
}
},
"body": {
"equals": "1234"
}
}
}
},
{
"description": "TestBlobPayloadNoParams",
"given": {
"input": {
}
},
"when": {
"action": "marshall",
"operation": "TestBlobPayload"
},
"then": {
"serializedAs": {
"uri": "/blob-payload",
"method": "POST",
"headers": {
"doesNotContain": [
"Content-Type"
]
},
"body": {
"equals": ""
}
}
}
},
{
"description": "NoPayload",
"given": {
"input": {
}
},
"when": {
"action": "marshall",
"operation": "NoPayload"
},
"then": {
"serializedAs": {
"uri": "/no-payload",
"method": "GET",
"headers": {
"doesNotContain": [
"Content-Type",
"Content-Length"
]
},
"body": {
"equals": ""
}
}
}
},
{
"description": "NoPayloadWithHeader",
"given": {
"input": {
"testId": "t-12345"
}
},
"when": {
"action": "marshall",
"operation": "NoPayload"
},
"then": {
"serializedAs": {
"uri": "/no-payload",
"method": "GET",
"headers": {
"contains": {
"x-amz-test-id": "t-12345"
},
"doesNotContain": [
"Content-Type",
"Content-Length"
]
},
"body": {
"equals": ""
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"testCases": [
"cases/rest-json-contenttype.json"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"version":"2.0",
"metadata":{
"apiVersion":"2021-05-13",
"endpointPrefix":"rest-test",
"protocol":"rest-json",
"serviceAbbreviation":"AmazonProtocolRestJsonContentType",
"serviceFullName":"Content Type Amazon Protocol Rest Json",
"serviceId":"AmazonProtocolRestJsonContentType",
"signatureVersion":"v4",
"timestampFormat":"unixTimestamp",
"uid":"restjson-contenttype-2021-05-13"
},
"operations":{
"TestBody":{
"name":"TestBody",
"http":{
"method":"POST",
"requestUri":"/body"
},
"input":{"shape":"TestBodyRequest"}
},
"TestPayload": {
"name": "TestPayload",
"http": {
"method": "POST",
"requestUri": "/payload"
},
"input":{"shape": "TestPayloadRequest"}
},
"TestBlobPayload": {
"name": "TestBlobPayload",
"http": {
"method": "POST",
"requestUri": "/blob-payload"
},
"input": {"shape": "TestBlobPayloadRequest"}
},
"NoPayload": {
"name": "NoPayload",
"http": {
"method": "GET",
"requestUri": "no-payload"
},
"input": {"shape": "NoPayloadRequest"}
}
},
"shapes":{
"Integer":{
"type":"integer"
},
"String":{"type":"string"},
"Blob":{"type":"blob"},
"NoPayloadRequest":{
"type":"structure",
"required":[],
"members":{
"testId":{
"shape":"TestId",
"documentation":"<p> The unique ID for a test. </p>",
"location":"header",
"locationName":"x-amz-test-id"
}
},
"documentation":"<p> The request structure for a no payload request. </p>"
},
"TestId":{
"type":"string",
"max":8,
"min":3,
"pattern":"t-[a-z0-9-]+"
},
"TestConfig":{
"type":"structure",
"required":[],
"members":{
"timeout":{
"shape":"Integer",
"documentation":"<p> Timeout in seconds </p>"
}
}
},
"PayloadConfig":{
"type":"structure",
"required":[],
"members":{
"data":{
"shape":"Integer",
"documentation":"<p> Numerical data </p>"
}
}
},
"TestBodyRequest":{
"type":"structure",
"required":[],
"members":{
"testConfig":{
"shape":"TestConfig",
"documentation":"<p> Content to post </p>"
},
"testId":{
"shape":"TestId",
"documentation":"<p> Optional test identifier </p>",
"location":"header",
"locationName":"x-amz-test-id"
}
},
"documentation":"<p> The request structure for a test body request. </p>"
},
"TestPayloadRequest":{
"type":"structure",
"required":[],
"members":{
"payloadConfig":{
"shape":"PayloadConfig",
"documentation":"<p> Payload to post </p>"
},
"testId":{
"shape":"TestId",
"documentation":"<p> Optional test identifier </p>",
"location":"header",
"locationName":"x-amz-test-id"
}
},
"documentation":"<p> The request structure for a payload request. </p>",
"payload":"payloadConfig"
},
"TestBlobPayloadRequest":{
"type":"structure",
"required":[],
"members":{
"data":{
"shape":"Blob",
"documentation":"<p> Blob payload to post </p>"
},
"contentType":{
"shape":"String",
"documentation":"<p> Optional content-type header </p>",
"location":"header",
"locationName":"Content-Type"
}
},
"documentation":"<p> The request structure for a blob payload request. </p>",
"payload":"data"
}
}
}
Loading