102 102 | mod malformed_unique_items_test {
|
103 103 |
|
104 104 | /// When the list has duplicated items, the response should be a 400
|
105 105 | /// ValidationException.
|
106 106 | /// Test ID: RestJsonMalformedUniqueItemsDuplicateItems
|
107 107 | #[::tokio::test]
|
108 108 | #[::tracing_test::traced_test]
|
109 109 | async fn rest_json_malformed_unique_items_duplicate_items_malformed_request() {
|
110 110 | {
|
111 111 | #[allow(unused_mut)]
|
112 - | let mut http_request = http::Request::builder()
|
112 + | let mut http_request = ::http_1x::Request::builder()
|
113 113 | .uri("/MalformedUniqueItems")
|
114 114 | .method("POST")
|
115 115 | .header("content-type", "application/json")
|
116 - | .body(::aws_smithy_http_server::body::Body::from(
|
117 - | ::bytes::Bytes::copy_from_slice(&::aws_smithy_protocol_test::decode_body_data(
|
116 + | .body(::aws_smithy_http_server::body::boxed(
|
117 + | ::http_body_util::Full::new(::bytes::Bytes::copy_from_slice(
|
118 + | &::aws_smithy_protocol_test::decode_body_data(
|
118 119 | "{ \"set\" : [\"a\", \"a\", \"b\", \"c\"] }".as_bytes(),
|
119 120 | ::aws_smithy_protocol_test::MediaType::from("unknown"),
|
121 + | ),
|
120 122 | )),
|
121 123 | ))
|
122 124 | .unwrap();
|
123 125 | #[allow(unused_mut)]
|
124 126 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
125 127 | let config = crate::service::UniqueItemsServiceConfig::builder().build();
|
126 - | let service = crate::service::UniqueItemsService::builder::<::hyper::body::Body, _, _, _>(config)
|
128 + | let service = crate::service::UniqueItemsService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
127 129 | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
128 130 | let sender = sender.clone();
|
129 131 | async move {
|
130 132 | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
131 133 | sender.send(()).await.expect("receiver dropped early");
|
132 134 | result
|
133 135 | }
|
134 136 | })
|
135 137 | .build_unchecked();
|
136 138 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
137 139 | .await
|
138 140 | .expect("unable to make an HTTP request");
|
139 141 | ::pretty_assertions::assert_eq!(
|
140 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
142 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
141 143 | http_response.status()
|
142 144 | );
|
143 145 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
144 146 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
145 147 | http_response.headers(),
|
146 148 | expected_headers,
|
147 149 | ));
|
148 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
150 + | use ::http_body_util::BodyExt;
|
151 + | let body = http_response
|
152 + | .into_body()
|
153 + | .collect()
|
149 154 | .await
|
150 - | .expect("unable to extract body to bytes");
|
155 + | .expect("unable to collect body")
|
156 + | .to_bytes();
|
151 157 | ::aws_smithy_protocol_test::assert_ok(
|
152 158 | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with repeated values at indices [0, 1] at '/set' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value with repeated values at indices [0, 1] at '/set' failed to satisfy constraint: Member must have unique values\", \"path\": \"/set\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
153 159 | );
|
154 160 | }
|
155 161 | }
|
156 162 |
|
157 163 | /// When the list has duplicated blobs, the response should be a 400
|
158 164 | /// ValidationException.
|
159 165 | /// Test ID: RestJsonMalformedUniqueItemsDuplicateBlobs
|
160 166 | #[::tokio::test]
|
161 167 | #[::tracing_test::traced_test]
|
162 168 | async fn rest_json_malformed_unique_items_duplicate_blobs_malformed_request() {
|
163 169 | {
|
164 170 | #[allow(unused_mut)]
|
165 - | let mut http_request = http::Request::builder()
|
171 + | let mut http_request = ::http_1x::Request::builder()
|
166 172 | .uri("/MalformedUniqueItems")
|
167 173 | .method("POST")
|
168 174 | .header("content-type", "application/json")
|
169 - | .body(::aws_smithy_http_server::body::Body::from(
|
175 + | .body(::aws_smithy_http_server::body::boxed(::http_body_util::Full::new(
|
170 176 | ::bytes::Bytes::copy_from_slice(
|
171 177 | &::aws_smithy_protocol_test::decode_body_data("{ \"complexSet\" : [{\"foo\": true, \"blob\": \"YmxvYg==\"}, {\"foo\": true, \"blob\": \"b3RoZXJibG9i\"}, {\"foo\": true, \"blob\": \"YmxvYg==\"}] }".as_bytes(), ::aws_smithy_protocol_test::MediaType::from("unknown"))
|
172 178 | )
|
173 - | )).unwrap();
|
179 + | ))).unwrap();
|
174 180 | #[allow(unused_mut)]
|
175 181 | let (sender, mut receiver) = ::tokio::sync::mpsc::channel(1);
|
176 182 | let config = crate::service::UniqueItemsServiceConfig::builder().build();
|
177 - | let service = crate::service::UniqueItemsService::builder::<::hyper::body::Body, _, _, _>(config)
|
183 + | let service = crate::service::UniqueItemsService::builder::<::aws_smithy_http_server::body::BoxBody, _, _, _>(config)
|
178 184 | .malformed_unique_items(move |input: crate::input::MalformedUniqueItemsInput| {
|
179 185 | let sender = sender.clone();
|
180 186 | async move {
|
181 187 | let result = { panic!("request should have been rejected, but we accepted it; we parsed operation input `{:?}`", &input) as Result<crate::output::MalformedUniqueItemsOutput, crate::error::MalformedUniqueItemsError> };
|
182 188 | sender.send(()).await.expect("receiver dropped early");
|
183 189 | result
|
184 190 | }
|
185 191 | })
|
186 192 | .build_unchecked();
|
187 193 | let http_response = ::tower::ServiceExt::oneshot(service, http_request)
|
188 194 | .await
|
189 195 | .expect("unable to make an HTTP request");
|
190 196 | ::pretty_assertions::assert_eq!(
|
191 - | http::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
197 + | ::http_1x::StatusCode::from_u16(400).expect("invalid expected HTTP status code"),
|
192 198 | http_response.status()
|
193 199 | );
|
194 200 | let expected_headers = [("x-amzn-errortype", "ValidationException")];
|
195 201 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(
|
196 202 | http_response.headers(),
|
197 203 | expected_headers,
|
198 204 | ));
|
199 - | let body = ::hyper::body::to_bytes(http_response.into_body())
|
205 + | use ::http_body_util::BodyExt;
|
206 + | let body = http_response
|
207 + | .into_body()
|
208 + | .collect()
|
200 209 | .await
|
201 - | .expect("unable to extract body to bytes");
|
210 + | .expect("unable to collect body")
|
211 + | .to_bytes();
|
202 212 | ::aws_smithy_protocol_test::assert_ok(
|
203 213 | ::aws_smithy_protocol_test::validate_body(&body, "{ \"message\" : \"1 validation error detected. Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\",\n \"fieldList\" : [{\"message\": \"Value with repeated values at indices [0, 2] at '/complexSet' failed to satisfy constraint: Member must have unique values\", \"path\": \"/complexSet\"}]}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
204 214 | );
|
205 215 | }
|
206 216 | }
|
207 217 | }
|