@@ -71,7 +71,11 @@ impl RestCatalogConfig {
71
71
}
72
72
73
73
fn get_token_endpoint ( & self ) -> String {
74
- [ & self . uri , PATH_V1 , "oauth" , "tokens" ] . join ( "/" )
74
+ if let Some ( auth_url) = self . props . get ( "rest.authorization-url" ) {
75
+ auth_url. to_string ( )
76
+ } else {
77
+ [ & self . uri , PATH_V1 , "oauth" , "tokens" ] . join ( "/" )
78
+ }
75
79
}
76
80
77
81
fn namespaces_endpoint ( & self ) -> String {
@@ -865,8 +869,12 @@ mod tests {
865
869
}
866
870
867
871
async fn create_oauth_mock ( server : & mut ServerGuard ) -> Mock {
872
+ create_oauth_mock_with_path ( server, "/v1/oauth/tokens" ) . await
873
+ }
874
+
875
+ async fn create_oauth_mock_with_path ( server : & mut ServerGuard , path : & str ) -> Mock {
868
876
server
869
- . mock ( "POST" , "/v1/oauth/tokens" )
877
+ . mock ( "POST" , path )
870
878
. with_status ( 200 )
871
879
. with_body (
872
880
r#"{
@@ -955,6 +963,39 @@ mod tests {
955
963
) ;
956
964
}
957
965
966
+ #[ tokio:: test]
967
+ async fn test_oauth_with_auth_url ( ) {
968
+ let mut server = Server :: new_async ( ) . await ;
969
+ let config_mock = create_config_mock ( & mut server) . await ;
970
+
971
+ let mut auth_server = Server :: new_async ( ) . await ;
972
+ let auth_server_path = "/some/path" ;
973
+ let oauth_mock = create_oauth_mock_with_path ( & mut auth_server, auth_server_path) . await ;
974
+
975
+ let mut props = HashMap :: new ( ) ;
976
+ props. insert ( "credential" . to_string ( ) , "client1:secret1" . to_string ( ) ) ;
977
+ props. insert (
978
+ "rest.authorization-url" . to_string ( ) ,
979
+ format ! ( "{}{}" , auth_server. url( ) , auth_server_path) . to_string ( ) ,
980
+ ) ;
981
+
982
+ let catalog = RestCatalog :: new (
983
+ RestCatalogConfig :: builder ( )
984
+ . uri ( server. url ( ) )
985
+ . props ( props)
986
+ . build ( ) ,
987
+ )
988
+ . await
989
+ . unwrap ( ) ;
990
+
991
+ oauth_mock. assert_async ( ) . await ;
992
+ config_mock. assert_async ( ) . await ;
993
+ assert_eq ! (
994
+ catalog. config. props. get( "token" ) ,
995
+ Some ( & "ey000000000000" . to_string( ) )
996
+ ) ;
997
+ }
998
+
958
999
#[ tokio:: test]
959
1000
async fn test_config_override_prefix ( ) {
960
1001
let mut server = Server :: new_async ( ) . await ;
0 commit comments