245 245 | mod test_payload_structure_test {
|
246 246 |
|
247 247 | /// Serializes a payload targeting an empty structure
|
248 248 | /// Test ID: RestJsonHttpWithEmptyStructurePayload
|
249 249 | #[::tokio::test]
|
250 250 | #[::tracing_test::traced_test]
|
251 251 | async fn rest_json_http_with_empty_structure_payload_request() {
|
252 252 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
253 253 | let config_builder = crate::config::Config::builder()
|
254 254 | .with_test_defaults()
|
255 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
255 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
256 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
257 + | .allow_no_auth()
|
256 258 | .endpoint_url("https://example.com");
|
257 259 |
|
258 260 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
259 261 | let result = client
|
260 262 | .test_payload_structure()
|
261 263 | .set_payload_config(::std::option::Option::Some(crate::types::PayloadConfig::builder().build()))
|
262 264 | .send()
|
263 265 | .await;
|
264 266 | let _ = dbg!(result);
|
265 267 | let http_request = request_receiver.expect_request();
|
266 268 | let expected_headers = [("Content-Type", "application/json")];
|
267 269 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
268 270 | let required_headers = &["Content-Length"];
|
269 271 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::require_headers(http_request.headers(), required_headers));
|
270 272 | let body = http_request.body().bytes().expect("body should be strict");
|
271 273 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
272 274 | body,
|
273 275 | "{}",
|
274 276 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
275 277 | ));
|
276 278 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
277 279 | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
278 280 | ::pretty_assertions::assert_eq!(uri.path(), "/payload", "path was incorrect");
|
279 281 | }
|
280 282 |
|
281 283 | /// Serializes a payload targeting a structure
|
282 284 | /// Test ID: RestJsonTestPayloadStructure
|
283 285 | #[::tokio::test]
|
284 286 | #[::tracing_test::traced_test]
|
285 287 | async fn rest_json_test_payload_structure_request() {
|
286 288 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
287 289 | let config_builder = crate::config::Config::builder()
|
288 290 | .with_test_defaults()
|
289 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
291 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
292 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
293 + | .allow_no_auth()
|
290 294 | .endpoint_url("https://example.com");
|
291 295 |
|
292 296 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
293 297 | let result = client
|
294 298 | .test_payload_structure()
|
295 299 | .set_payload_config(::std::option::Option::Some(
|
296 300 | crate::types::PayloadConfig::builder().set_data(::std::option::Option::Some(25)).build(),
|
297 301 | ))
|
298 302 | .send()
|
299 303 | .await;
|
300 304 | let _ = dbg!(result);
|
301 305 | let http_request = request_receiver.expect_request();
|
302 306 | let expected_headers = [("Content-Type", "application/json")];
|
303 307 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
304 308 | let required_headers = &["Content-Length"];
|
305 309 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::require_headers(http_request.headers(), required_headers));
|
306 310 | let body = http_request.body().bytes().expect("body should be strict");
|
307 311 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
308 312 | body,
|
309 313 | "{\"data\": 25\n}",
|
310 314 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
311 315 | ));
|
312 316 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
313 317 | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
314 318 | ::pretty_assertions::assert_eq!(uri.path(), "/payload", "path was incorrect");
|
315 319 | }
|
316 320 |
|
317 321 | /// Serializes an request with header members but no payload
|
318 322 | /// Test ID: RestJsonHttpWithHeadersButNoPayload
|
319 323 | #[::tokio::test]
|
320 324 | #[::tracing_test::traced_test]
|
321 325 | async fn rest_json_http_with_headers_but_no_payload_request() {
|
322 326 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
323 327 | let config_builder = crate::config::Config::builder()
|
324 328 | .with_test_defaults()
|
325 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
329 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
330 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
331 + | .allow_no_auth()
|
326 332 | .endpoint_url("https://example.com");
|
327 333 |
|
328 334 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
329 335 | let result = client
|
330 336 | .test_payload_structure()
|
331 337 | .set_test_id(::std::option::Option::Some("t-12345".to_owned()))
|
332 338 | .set_payload_config(::std::option::Option::Some(crate::types::PayloadConfig::builder().build()))
|
333 339 | .send()
|
334 340 | .await;
|
335 341 | let _ = dbg!(result);
|
336 342 | let http_request = request_receiver.expect_request();
|
337 343 | let expected_headers = [("Content-Type", "application/json"), ("X-Amz-Test-Id", "t-12345")];
|
338 344 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
339 345 | let required_headers = &["Content-Length"];
|
340 346 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::require_headers(http_request.headers(), required_headers));
|
341 347 | let body = http_request.body().bytes().expect("body should be strict");
|
342 348 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
343 349 | body,
|
344 350 | "{}",
|
345 351 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
346 352 | ));
|
347 353 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
348 354 | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
349 355 | ::pretty_assertions::assert_eq!(uri.path(), "/payload", "path was incorrect");
|
350 356 | }
|
351 357 | }
|
352 358 |
|
353 359 | /// Error type for the `TestPayloadStructureError` operation.
|
354 360 | #[non_exhaustive]
|
355 361 | #[derive(::std::fmt::Debug)]
|