diff options
author | Alex Auvolat <alex@adnab.me> | 2022-01-07 16:23:04 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-01-13 17:27:16 +0100 |
commit | bed3106c6a4cbdc7257eb88060fc04ec84340ee4 (patch) | |
tree | 6237fb5a7a49208c3c990b1b7b3955d35124da19 /src/api/s3_website.rs | |
parent | 60c0033c8bbd3dbc18f8c91f15674a60fd8acdc0 (diff) | |
download | garage-bed3106c6a4cbdc7257eb88060fc04ec84340ee4.tar.gz garage-bed3106c6a4cbdc7257eb88060fc04ec84340ee4.zip |
Implement {Put,Get,Delete}BucketCors and CORS in web server
Diffstat (limited to 'src/api/s3_website.rs')
-rw-r--r-- | src/api/s3_website.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/api/s3_website.rs b/src/api/s3_website.rs index fcf8cba3..6dcb59c8 100644 --- a/src/api/s3_website.rs +++ b/src/api/s3_website.rs @@ -5,7 +5,7 @@ use hyper::{Body, Request, Response, StatusCode}; use serde::{Deserialize, Serialize}; use crate::error::*; -use crate::s3_xml::{xmlns_tag, IntValue, Value}; +use crate::s3_xml::{to_xml_with_header, xmlns_tag, IntValue, Value}; use crate::signature::verify_signed_content; use garage_model::bucket_table::*; @@ -39,7 +39,7 @@ pub async fn handle_get_website( redirect_all_requests_to: None, routing_rules: None, }; - let xml = quick_xml::se::to_string(&wc)?; + let xml = to_xml_with_header(&wc)?; Ok(Response::builder() .status(StatusCode::OK) .header(http::header::CONTENT_TYPE, "application/xml") @@ -303,7 +303,7 @@ mod tests { use quick_xml::de::from_str; #[test] - fn test_deserialize() { + fn test_deserialize() -> Result<(), Error> { let message = r#"<?xml version="1.0" encoding="UTF-8"?> <WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <ErrorDocument> @@ -365,7 +365,12 @@ mod tests { ref_value, conf } - // TODO verify result is ok - // TODO cycle back and verify if ok + + let message2 = to_xml_with_header(&ref_value)?; + + let cleanup = |c: &str| c.replace(char::is_whitespace, ""); + assert_eq!(cleanup(message), cleanup(&message2)); + + Ok(()) } } |