Skip to content

[Storage] SAS PoC #2798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions sdk/storage/azure_storage_blob/src/clients/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,32 @@ impl BlobClient {
})
}

pub fn new_no_credential(
endpoint: &str,
container_name: String,
blob_name: String,
options: Option<BlobClientOptions>,
) -> Result<Self> {
let mut options = options.unwrap_or_default();

let storage_headers_policy = Arc::new(StorageHeadersPolicy);
options
.client_options
.per_call_policies
.push(storage_headers_policy);

let client = GeneratedBlobClient::new_no_credential(
endpoint,
container_name.clone(),
blob_name.clone(),
Some(options),
)?;
Ok(Self {
endpoint: endpoint.parse()?,
client,
})
}

/// Returns a new instance of AppendBlobClient.
///
/// # Arguments
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions sdk/storage/azure_storage_blob/tests/blob_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ use azure_core::{
Bytes,
};
use azure_core_test::{recorded, TestContext};
use azure_storage_blob::models::{
AccessTier, BlobClientAcquireLeaseResultHeaders, BlobClientChangeLeaseResultHeaders,
BlobClientDownloadOptions, BlobClientDownloadResultHeaders, BlobClientGetPropertiesOptions,
BlobClientGetPropertiesResultHeaders, BlobClientSetMetadataOptions,
BlobClientSetPropertiesOptions, BlobClientSetTierOptions, BlockBlobClientUploadOptions,
LeaseState,
use azure_storage_blob::{
models::{
AccessTier, BlobClientAcquireLeaseResultHeaders, BlobClientChangeLeaseResultHeaders,
BlobClientDownloadOptions, BlobClientDownloadResultHeaders, BlobClientGetPropertiesOptions,
BlobClientGetPropertiesResultHeaders, BlobClientSetMetadataOptions,
BlobClientSetPropertiesOptions, BlobClientSetTierOptions, BlockBlobClientUploadOptions,
LeaseState,
},
BlobClient,
};
use azure_storage_blob_test::{create_test_blob, get_blob_name, get_container_client};
use std::{collections::HashMap, error::Error, time::Duration};
Expand Down Expand Up @@ -423,3 +426,19 @@ async fn test_leased_blob_operations(ctx: TestContext) -> Result<(), Box<dyn Err
container_client.delete_container(None).await?;
Ok(())
}

#[recorded::test]
async fn test_sassy(ctx: TestContext) -> Result<(), Box<dyn Error>> {
// SAS
let endpoint = "endpoint_with_sas";
let container_name = "acontainer108f32e8";
let blob_name = "goodbye.txt";
let sas_blob_client =
BlobClient::new_no_credential(endpoint, container_name.into(), blob_name.into(), None)?;

let blob_properties = sas_blob_client.get_properties(None).await?;
let content_length = blob_properties.content_length()?;
assert_eq!(11, content_length.unwrap());

Ok(())
}
Loading