diff options
author | Sam Scott <sam@osohq.com> | 2024-04-07 14:36:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-07 14:36:05 -0500 |
commit | c6e5914a31e0d602695a3ea601f6976a1ab07d0e (patch) | |
tree | 08d2521ea9c6d5067466f08978488a0db5db298a /tests | |
parent | 671266456066aca49e577b871281191d84d01e2e (diff) |
Actix: extract querystring from form data (#98)
* Deprecate support for actix-web 2.0
* Update actix.rs
Added QsForm to support application/x-www-form-urlencoded Web forms
* Update actix.rs with working adjustments
Added Into_inner function for both QsQuery and QsForm to behave like actix_webs default extractors
Made some fixes
* Added missing code to actix.rs for QsForm
* Update actix.rs
Added new trait "IntoInner"
Fixed QsFormConfig not correctly setting new settings correctly
* Update actix.rs
Removed trait requirement for using into_inner() now functions as a function.
* Update src/actix.rs
* Remove redundant config, add tests
* Add changelog
* Bump serde qs version
* Add Debug bound to docs example
---------
Co-authored-by: nMessage <135612238+nMessage@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_actix.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/test_actix.rs b/tests/test_actix.rs index 792afb2..48ad27f 100644 --- a/tests/test_actix.rs +++ b/tests/test_actix.rs @@ -16,7 +16,7 @@ use actix_web::error::InternalError; use actix_web::http::StatusCode; use actix_web::test::TestRequest; use actix_web::{FromRequest, HttpResponse}; -use qs::actix::{QsQuery, QsQueryConfig}; +use qs::actix::{QsForm, QsQuery, QsQueryConfig}; use qs::Config as QsConfig; use serde::de::Error; @@ -143,3 +143,25 @@ fn test_custom_qs_config() { assert_eq!(s.common.remaining, true); }) } + +#[test] +fn test_form_extractor() { + futures::executor::block_on(async { + let test_data = Query { + foo: 1, + bars: vec![0, 1], + common: CommonParams { + limit: 100, + offset: 50, + remaining: true, + }, + }; + let req = TestRequest::with_uri("/test") + .set_payload(serde_qs::to_string(&test_data).unwrap()) + .to_srv_request(); + let (req, mut pl) = req.into_parts(); + + let s = QsForm::<Query>::from_request(&req, &mut pl).await.unwrap(); + assert_eq!(s.into_inner(), test_data); + }) +} |