Skip to content
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

fix truncating signature on SAS #1007

Merged
merged 2 commits into from
Dec 12, 2022
Merged
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
18 changes: 18 additions & 0 deletions python/tests/test_fs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import urllib

import pyarrow as pa
import pyarrow.parquet as pq
import pytest
Expand Down Expand Up @@ -204,3 +206,19 @@ def test_roundtrip_azure_sas(azurite_sas_creds, sample_data: pa.Table):
table = dt.to_pyarrow_table()
assert table == sample_data
assert dt.version() == 0


@pytest.mark.azure
@pytest.mark.integration
@pytest.mark.timeout(timeout=5, method="thread")
def test_roundtrip_azure_decoded_sas(azurite_sas_creds, sample_data: pa.Table):
table_path = "az://deltars/roundtrip4"
azurite_sas_creds["SAS_TOKEN"] = urllib.parse.unquote(
azurite_sas_creds["SAS_TOKEN"]
)

write_deltalake(table_path, sample_data, storage_options=azurite_sas_creds)
dt = DeltaTable(table_path, storage_options=azurite_sas_creds)
table = dt.to_pyarrow_table()
assert table == sample_data
assert dt.version() == 0
12 changes: 3 additions & 9 deletions rust/src/builder/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,10 @@ fn split_sas(sas: &str) -> Result<Vec<(String, String)>, BuilderError> {
.filter(|s| !s.chars().all(char::is_whitespace));
let mut pairs = Vec::new();
for kv_pair_str in kv_str_pairs {
let mut kv = kv_pair_str.trim().split('=');
let k = match kv.next().filter(|k| !k.chars().all(char::is_whitespace)) {
None => {
return Err(BuilderError::MissingCredential);
}
Some(k) => k,
};
let v = match kv.next().filter(|k| !k.chars().all(char::is_whitespace)) {
let kv = kv_pair_str.trim().split_once('=');
Copy link
Member

@houqp houqp Dec 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to:

Suggested change
let kv = kv_pair_str.trim().split_once('=');
let (k, v) = kv_pair_str.trim().split_once('=').ok_or(BuilderError::MissingCredential)?;

let (k, v) = match kv {
None => return Err(BuilderError::MissingCredential),
Some(v) => v,
Some(kv) => kv,
};
pairs.push((k.into(), v.into()))
}
Expand Down