236 236 | mod sparse_json_maps_test {
|
237 237 |
|
238 238 | /// Serializes JSON maps
|
239 239 | /// Test ID: RestJsonSparseJsonMaps
|
240 240 | #[::tokio::test]
|
241 241 | #[::tracing_test::traced_test]
|
242 242 | async fn rest_json_sparse_json_maps_request() {
|
243 243 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
244 244 | let config_builder = crate::config::Config::builder()
|
245 245 | .with_test_defaults()
|
246 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
246 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
247 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
248 + | .allow_no_auth()
|
247 249 | .endpoint_url("https://example.com");
|
248 250 |
|
249 251 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
250 252 | let result = client
|
251 253 | .sparse_json_maps()
|
252 254 | .set_sparse_struct_map(::std::option::Option::Some({
|
253 255 | let mut ret = ::std::collections::HashMap::new();
|
254 256 | ret.insert(
|
255 257 | "foo".to_owned(),
|
256 258 | ::std::option::Option::Some(
|
257 259 | crate::types::GreetingStruct::builder()
|
258 260 | .set_hi(::std::option::Option::Some("there".to_owned()))
|
259 261 | .build(),
|
260 262 | ),
|
261 263 | );
|
262 264 | ret.insert(
|
263 265 | "baz".to_owned(),
|
264 266 | ::std::option::Option::Some(
|
265 267 | crate::types::GreetingStruct::builder()
|
266 268 | .set_hi(::std::option::Option::Some("bye".to_owned()))
|
267 269 | .build(),
|
268 270 | ),
|
269 271 | );
|
270 272 | ret
|
271 273 | }))
|
272 274 | .send()
|
273 275 | .await;
|
274 276 | let _ = dbg!(result);
|
275 277 | let http_request = request_receiver.expect_request();
|
276 278 | let expected_headers = [("Content-Type", "application/json")];
|
277 279 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
278 280 | let body = http_request.body().bytes().expect("body should be strict");
|
279 281 | ::aws_smithy_protocol_test::assert_ok(
|
280 282 | ::aws_smithy_protocol_test::validate_body(body, "{\n \"sparseStructMap\": {\n \"foo\": {\n \"hi\": \"there\"\n },\n \"baz\": {\n \"hi\": \"bye\"\n }\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
281 283 | );
|
282 284 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
283 285 | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
284 286 | ::pretty_assertions::assert_eq!(uri.path(), "/SparseJsonMaps", "path was incorrect");
|
285 287 | }
|
286 288 |
|
287 289 | /// Serializes JSON map values in sparse maps
|
288 290 | /// Test ID: RestJsonSerializesSparseNullMapValues
|
289 291 | #[::tokio::test]
|
290 292 | #[::tracing_test::traced_test]
|
291 293 | async fn rest_json_serializes_sparse_null_map_values_request() {
|
292 294 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
293 295 | let config_builder = crate::config::Config::builder()
|
294 296 | .with_test_defaults()
|
295 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
297 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
298 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
299 + | .allow_no_auth()
|
296 300 | .endpoint_url("https://example.com");
|
297 301 |
|
298 302 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
299 303 | let result = client
|
300 304 | .sparse_json_maps()
|
301 305 | .set_sparse_boolean_map(::std::option::Option::Some({
|
302 306 | let mut ret = ::std::collections::HashMap::new();
|
303 307 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
304 308 | ret
|
305 309 | }))
|
306 310 | .set_sparse_number_map(::std::option::Option::Some({
|
307 311 | let mut ret = ::std::collections::HashMap::new();
|
308 312 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
309 313 | ret
|
310 314 | }))
|
311 315 | .set_sparse_string_map(::std::option::Option::Some({
|
312 316 | let mut ret = ::std::collections::HashMap::new();
|
313 317 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
314 318 | ret
|
315 319 | }))
|
316 320 | .set_sparse_struct_map(::std::option::Option::Some({
|
317 321 | let mut ret = ::std::collections::HashMap::new();
|
318 322 | ret.insert("x".to_owned(), ::std::option::Option::None);
|
319 323 | ret
|
320 324 | }))
|
321 325 | .send()
|
322 326 | .await;
|
323 327 | let _ = dbg!(result);
|
324 328 | let http_request = request_receiver.expect_request();
|
325 329 | let expected_headers = [("Content-Type", "application/json")];
|
326 330 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
327 331 | let body = http_request.body().bytes().expect("body should be strict");
|
328 332 | ::aws_smithy_protocol_test::assert_ok(
|
329 333 | ::aws_smithy_protocol_test::validate_body(body, "{\n \"sparseBooleanMap\": {\n \"x\": null\n },\n \"sparseNumberMap\": {\n \"x\": null\n },\n \"sparseStringMap\": {\n \"x\": null\n },\n \"sparseStructMap\": {\n \"x\": null\n }\n}", ::aws_smithy_protocol_test::MediaType::from("application/json"))
|
330 334 | );
|
331 335 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
332 336 | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
333 337 | ::pretty_assertions::assert_eq!(uri.path(), "/SparseJsonMaps", "path was incorrect");
|
334 338 | }
|
335 339 |
|
336 340 | /// Ensure that 0 and false are sent over the wire in all maps and lists
|
337 341 | /// Test ID: RestJsonSerializesZeroValuesInSparseMaps
|
338 342 | #[::tokio::test]
|
339 343 | #[::tracing_test::traced_test]
|
340 344 | async fn rest_json_serializes_zero_values_in_sparse_maps_request() {
|
341 345 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
342 346 | let config_builder = crate::config::Config::builder()
|
343 347 | .with_test_defaults()
|
344 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
348 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
349 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
350 + | .allow_no_auth()
|
345 351 | .endpoint_url("https://example.com");
|
346 352 |
|
347 353 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
348 354 | let result = client
|
349 355 | .sparse_json_maps()
|
350 356 | .set_sparse_number_map(::std::option::Option::Some({
|
351 357 | let mut ret = ::std::collections::HashMap::new();
|
352 358 | ret.insert("x".to_owned(), ::std::option::Option::Some(0));
|
353 359 | ret
|
354 360 | }))
|
355 361 | .set_sparse_boolean_map(::std::option::Option::Some({
|
356 362 | let mut ret = ::std::collections::HashMap::new();
|
357 363 | ret.insert("x".to_owned(), ::std::option::Option::Some(false));
|
358 364 | ret
|
359 365 | }))
|
360 366 | .send()
|
361 367 | .await;
|
362 368 | let _ = dbg!(result);
|
363 369 | let http_request = request_receiver.expect_request();
|
364 370 | let expected_headers = [("Content-Type", "application/json")];
|
365 371 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
366 372 | let body = http_request.body().bytes().expect("body should be strict");
|
367 373 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
368 374 | body,
|
369 375 | "{\n \"sparseNumberMap\": {\n \"x\": 0\n },\n \"sparseBooleanMap\": {\n \"x\": false\n }\n}",
|
370 376 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
371 377 | ));
|
372 378 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
373 379 | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
374 380 | ::pretty_assertions::assert_eq!(uri.path(), "/SparseJsonMaps", "path was incorrect");
|
375 381 | }
|
376 382 |
|
377 383 | /// A request that contains a sparse map of sets
|
378 384 | /// Test ID: RestJsonSerializesSparseSetMap
|
379 385 | #[::tokio::test]
|
380 386 | #[::tracing_test::traced_test]
|
381 387 | async fn rest_json_serializes_sparse_set_map_request() {
|
382 388 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
383 389 | let config_builder = crate::config::Config::builder()
|
384 390 | .with_test_defaults()
|
385 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
391 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
392 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
393 + | .allow_no_auth()
|
386 394 | .endpoint_url("https://example.com");
|
387 395 |
|
388 396 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
389 397 | let result = client
|
390 398 | .sparse_json_maps()
|
391 399 | .set_sparse_set_map(::std::option::Option::Some({
|
392 400 | let mut ret = ::std::collections::HashMap::new();
|
393 401 | ret.insert("x".to_owned(), ::std::option::Option::Some(vec![]));
|
394 402 | ret.insert("y".to_owned(), ::std::option::Option::Some(vec!["a".to_owned(), "b".to_owned()]));
|
395 403 | ret
|
396 404 | }))
|
397 405 | .send()
|
398 406 | .await;
|
399 407 | let _ = dbg!(result);
|
400 408 | let http_request = request_receiver.expect_request();
|
401 409 | let expected_headers = [("Content-Type", "application/json")];
|
402 410 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
|
403 411 | let body = http_request.body().bytes().expect("body should be strict");
|
404 412 | ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_body(
|
405 413 | body,
|
406 414 | "{\n \"sparseSetMap\": {\n \"x\": [],\n \"y\": [\"a\", \"b\"]\n }\n}",
|
407 415 | ::aws_smithy_protocol_test::MediaType::from("application/json"),
|
408 416 | ));
|
409 417 | let uri: ::http::Uri = http_request.uri().parse().expect("invalid URI sent");
|
410 418 | ::pretty_assertions::assert_eq!(http_request.method(), "POST", "method was incorrect");
|
411 419 | ::pretty_assertions::assert_eq!(uri.path(), "/SparseJsonMaps", "path was incorrect");
|
412 420 | }
|
413 421 |
|
414 422 | /// A request that contains a sparse map of sets.
|
415 423 | /// Test ID: RestJsonSerializesSparseSetMapAndRetainsNull
|
416 424 | #[::tokio::test]
|
417 425 | #[::tracing_test::traced_test]
|
418 426 | async fn rest_json_serializes_sparse_set_map_and_retains_null_request() {
|
419 427 | let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
|
420 428 | let config_builder = crate::config::Config::builder()
|
421 429 | .with_test_defaults()
|
422 - | .auth_scheme_resolver(crate::config::auth::NoAuthSchemeResolver)
|
430 + | // TODO(https://github.com/smithy-lang/smithy-rs/issues/4177):
|
431 + | // Until the incorrect separation is addressed, we need to rely on this workaround.
|
432 + | .allow_no_auth()
|
423 433 | .endpoint_url("https://example.com");
|
424 434 |
|
425 435 | let client = crate::Client::from_conf(config_builder.http_client(http_client).build());
|
426 436 | let result = client
|
427 437 | .sparse_json_maps()
|
428 438 | .set_sparse_set_map(::std::option::Option::Some({
|
429 439 | let mut ret = ::std::collections::HashMap::new();
|
430 440 | ret.insert("x".to_owned(), ::std::option::Option::Some(vec![]));
|
431 441 | ret.insert("y".to_owned(), ::std::option::Option::Some(vec!["a".to_owned(), "b".to_owned()]));
|
432 442 | ret.insert("z".to_owned(), ::std::option::Option::None);
|