Skip to content

Commit

Permalink
Fix #[serde(flatten)] annotation and add ResourceType value (#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
CHarrod283 authored Oct 9, 2023
1 parent 20c1d78 commit f290339
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sdk/storage_blobs/src/blob/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use azure_core::{
};
use azure_storage::{ConsistencyCRC64, ConsistencyMD5, CopyId, CopyProgress};
use serde::{self, Deserialize, Deserializer};
use serde_json::Value;
use std::collections::HashMap;
use time::OffsetDateTime;

Expand Down Expand Up @@ -174,8 +175,9 @@ pub struct BlobProperties {
)]
pub expiry_time: Option<OffsetDateTime>,
pub blob_committed_block_count: Option<u64>,
pub resource_type: Option<String>,
#[serde(flatten)]
extra: HashMap<String, String>, // For debug purposes, should be compiled out in the future
extra: HashMap<String, Value>, // For debug purposes, should be compiled out in the future
}

impl Blob {
Expand Down Expand Up @@ -281,6 +283,7 @@ impl Blob {
tag_count: None, // TODO
rehydrate_priority: None, // TODO
expiry_time: None,
resource_type: None,
blob_committed_block_count,
extra: HashMap::new(),
},
Expand Down
41 changes: 41 additions & 0 deletions sdk/storage_blobs/src/container/operations/list_blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,47 @@ mod tests {
let _list_blobs_response_internal: ListBlobsResponseInternal = read_xml(&bytes).unwrap();
}

#[test]
fn deserde_properties_with_non_existent_field() {
const XML: &str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<EnumerationResults ServiceEndpoint=\"http://127.0.0.1:10000/devstoreaccount1\" ContainerName=\"temp\">
<Prefix>b39bc5c9-0f31-459c-a271-828467105470/</Prefix>
<Marker/>
<MaxResults>5000</MaxResults>
<Delimiter/>
<Blobs>
<Blob>
<Name>b39bc5c9-0f31-459c-a271-828467105470/corrupted_data_2020-01-02T03_04_05.json</Name>
<Properties>
<Creation-Time>Mon, 02 Oct 2023 20:00:31 GMT</Creation-Time>
<Last-Modified>Mon, 02 Oct 2023 20:00:31 GMT</Last-Modified>
<Etag>0x23D9DB658CF7480</Etag>
<Content-Length>0</Content-Length>
<Content-Type>application/octet-stream</Content-Type>
<Content-Encoding/>
<Content-Language/>
<Content-CRC64/>
<Content-MD5/>
<Cache-Control/>
<Content-Disposition/>
<BlobType>BlockBlob</BlobType>
<AccessTier>Hot</AccessTier>
<AccessTierInferred>true</AccessTierInferred>
<LeaseStatus>unlocked</LeaseStatus>
<LeaseState>available</LeaseState>
<ServerEncrypted>true</ServerEncrypted>
<ResourceType>file</ResourceType>
<NotRealProperty>notRealValue</NotRealProperty>
</Properties>
</Blob>
</Blobs>
<NextMarker/>
</EnumerationResults>";

let bytes = Bytes::from(XML);
let _list_blobs_response_internal: ListBlobsResponseInternal = read_xml(&bytes).unwrap();
}

#[test]
fn deserde_azurite_without_server_encrypted() {
const S: &str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
Expand Down

0 comments on commit f290339

Please sign in to comment.