Skip to content

Commit

Permalink
Tweak and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Apr 4, 2024
1 parent 4426f8b commit c0b3c98
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
7 changes: 2 additions & 5 deletions object_store/src/gcp/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ use std::time::{Duration, Instant};
use tracing::info;
use url::Url;

pub const DEFAULT_SCOPE: [&str; 2] = [
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/cloud-platform",
];
pub const DEFAULT_SCOPE: &str = "https://www.googleapis.com/auth/cloud-platform";

pub const DEFAULT_GCS_BASE_URL: &str = "https://storage.googleapis.com";

Expand Down Expand Up @@ -357,7 +354,7 @@ impl ServiceAccountCredentials {
self.private_key_id,
self.client_email,
ServiceAccountKey::from_pem(self.private_key.as_bytes())?,
DEFAULT_SCOPE.join(" ").to_string(),
DEFAULT_SCOPE.to_string(),
)?)
}

Expand Down
30 changes: 30 additions & 0 deletions object_store/src/gcp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,36 @@ mod test {
}
}

#[tokio::test]
#[ignore]
async fn gcs_test_sign() {
crate::test_util::maybe_skip_integration!();
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();

let client = reqwest::Client::new();

let path = Path::from("test_sign");
let url = integration
.signed_url(Method::PUT, &path, Duration::from_secs(3600))
.await
.unwrap();
println!("PUT {url}");

let resp = client.put(url).body("data").send().await.unwrap();
resp.error_for_status().unwrap();

let url = integration
.signed_url(Method::GET, &path, Duration::from_secs(3600))
.await
.unwrap();
println!("GET {url}");

let resp = client.get(url).send().await.unwrap();
let resp = resp.error_for_status().unwrap();
let data = resp.bytes().await.unwrap();
assert_eq!(data.as_ref(), b"data");
}

#[tokio::test]
async fn gcs_test_get_nonexistent_location() {
crate::test_util::maybe_skip_integration!();
Expand Down

0 comments on commit c0b3c98

Please sign in to comment.