This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 4b275a2 chore(catalog): Deprecate rest.authorization-url in favor of
oauth2-server-uri (#480)
4b275a2 is described below
commit 4b275a2cfb7810b29938f67e0fe8a218d4dd01ea
Author: Andre Luis Anastacio <[email protected]>
AuthorDate: Thu Jul 25 01:13:36 2024 -0300
chore(catalog): Deprecate rest.authorization-url in favor of
oauth2-server-uri (#480)
---
crates/catalog/rest/src/catalog.rs | 40 ++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/crates/catalog/rest/src/catalog.rs
b/crates/catalog/rest/src/catalog.rs
index 83cc0ec..594e2a9 100644
--- a/crates/catalog/rest/src/catalog.rs
+++ b/crates/catalog/rest/src/catalog.rs
@@ -69,7 +69,13 @@ impl RestCatalogConfig {
}
pub(crate) fn get_token_endpoint(&self) -> String {
- if let Some(auth_url) = self.props.get("rest.authorization-url") {
+ if let Some(oauth2_uri) = self.props.get("oauth2-server-uri") {
+ oauth2_uri.to_string()
+ } else if let Some(auth_url) =
self.props.get("rest.authorization-url") {
+ log::warn!(
+ "'rest.authorization-url' is deprecated and will be removed in
version 0.4.0. \
+ Please use 'oauth2-server-uri' instead."
+ );
auth_url.to_string()
} else {
[&self.uri, PATH_V1, "oauth", "tokens"].join("/")
@@ -891,7 +897,7 @@ mod tests {
}
#[tokio::test]
- async fn test_oauth_with_auth_url() {
+ async fn test_oauth_with_deprecated_auth_url() {
let mut server = Server::new_async().await;
let config_mock = create_config_mock(&mut server).await;
@@ -920,6 +926,36 @@ mod tests {
assert_eq!(token, Some("ey000000000000".to_string()));
}
+ #[tokio::test]
+ async fn test_oauth_with_oauth2_server_uri() {
+ let mut server = Server::new_async().await;
+ let config_mock = create_config_mock(&mut server).await;
+
+ let mut auth_server = Server::new_async().await;
+ let auth_server_path = "/some/path";
+ let oauth_mock = create_oauth_mock_with_path(&mut auth_server,
auth_server_path).await;
+
+ let mut props = HashMap::new();
+ props.insert("credential".to_string(), "client1:secret1".to_string());
+ props.insert(
+ "oauth2-server-uri".to_string(),
+ format!("{}{}", auth_server.url(), auth_server_path).to_string(),
+ );
+
+ let catalog = RestCatalog::new(
+ RestCatalogConfig::builder()
+ .uri(server.url())
+ .props(props)
+ .build(),
+ );
+
+ let token = catalog.context().await.unwrap().client.token().await;
+
+ oauth_mock.assert_async().await;
+ config_mock.assert_async().await;
+ assert_eq!(token, Some("ey000000000000".to_string()));
+ }
+
#[tokio::test]
async fn test_config_override() {
let mut server = Server::new_async().await;