@@ -58,7 +58,7 @@ fn after_all() {
5858 guard. take ( ) ;
5959}
6060
61- async fn get_catalog ( ) -> RestCatalog {
61+ async fn get_catalog ( authenticator : Option < Arc < dyn CustomAuthenticator > > ) -> RestCatalog {
6262 set_up ( ) ;
6363
6464 let rest_catalog_ip = {
@@ -73,7 +73,12 @@ async fn get_catalog() -> RestCatalog {
7373 sleep ( std:: time:: Duration :: from_millis ( 1000 ) ) . await ;
7474 }
7575
76- RestCatalogBuilder :: default ( )
76+ let mut builder = RestCatalogBuilder :: default ( ) ;
77+ if let Some ( auth) = authenticator {
78+ builder = builder. with_token_authenticator ( auth) ;
79+ }
80+
81+ builder
7782 . load (
7883 "rest" ,
7984 HashMap :: from ( [ (
@@ -87,7 +92,7 @@ async fn get_catalog() -> RestCatalog {
8792
8893#[ tokio:: test]
8994async fn test_get_non_exist_namespace ( ) {
90- let catalog = get_catalog ( ) . await ;
95+ let catalog = get_catalog ( None ) . await ;
9196
9297 let result = catalog
9398 . get_namespace ( & NamespaceIdent :: from_strs ( [ "test_get_non_exist_namespace" ] ) . unwrap ( ) )
@@ -99,7 +104,7 @@ async fn test_get_non_exist_namespace() {
99104
100105#[ tokio:: test]
101106async fn test_get_namespace ( ) {
102- let catalog = get_catalog ( ) . await ;
107+ let catalog = get_catalog ( None ) . await ;
103108
104109 let ns = Namespace :: with_properties (
105110 NamespaceIdent :: from_strs ( [ "apple" , "ios" ] ) . unwrap ( ) ,
@@ -129,7 +134,7 @@ async fn test_get_namespace() {
129134
130135#[ tokio:: test]
131136async fn test_list_namespace ( ) {
132- let catalog = get_catalog ( ) . await ;
137+ let catalog = get_catalog ( None ) . await ;
133138
134139 let ns1 = Namespace :: with_properties (
135140 NamespaceIdent :: from_strs ( [ "test_list_namespace" , "ios" ] ) . unwrap ( ) ,
@@ -181,7 +186,7 @@ async fn test_list_namespace() {
181186
182187#[ tokio:: test]
183188async fn test_list_empty_namespace ( ) {
184- let catalog = get_catalog ( ) . await ;
189+ let catalog = get_catalog ( None ) . await ;
185190
186191 let ns_apple = Namespace :: with_properties (
187192 NamespaceIdent :: from_strs ( [ "test_list_empty_namespace" , "apple" ] ) . unwrap ( ) ,
@@ -215,7 +220,7 @@ async fn test_list_empty_namespace() {
215220
216221#[ tokio:: test]
217222async fn test_list_root_namespace ( ) {
218- let catalog = get_catalog ( ) . await ;
223+ let catalog = get_catalog ( None ) . await ;
219224
220225 let ns1 = Namespace :: with_properties (
221226 NamespaceIdent :: from_strs ( [ "test_list_root_namespace" , "apple" , "ios" ] ) . unwrap ( ) ,
@@ -260,7 +265,7 @@ async fn test_list_root_namespace() {
260265
261266#[ tokio:: test]
262267async fn test_create_table ( ) {
263- let catalog = get_catalog ( ) . await ;
268+ let catalog = get_catalog ( None ) . await ;
264269
265270 let ns = Namespace :: with_properties (
266271 NamespaceIdent :: from_strs ( [ "test_create_table" , "apple" , "ios" ] ) . unwrap ( ) ,
@@ -315,7 +320,7 @@ async fn test_create_table() {
315320
316321#[ tokio:: test]
317322async fn test_update_table ( ) {
318- let catalog = get_catalog ( ) . await ;
323+ let catalog = get_catalog ( None ) . await ;
319324
320325 let ns = Namespace :: with_properties (
321326 NamespaceIdent :: from_strs ( [ "test_update_table" , "apple" , "ios" ] ) . unwrap ( ) ,
@@ -384,7 +389,7 @@ fn assert_map_contains(map1: &HashMap<String, String>, map2: &HashMap<String, St
384389
385390#[ tokio:: test]
386391async fn test_list_empty_multi_level_namespace ( ) {
387- let catalog = get_catalog ( ) . await ;
392+ let catalog = get_catalog ( None ) . await ;
388393
389394 let ns_apple = Namespace :: with_properties (
390395 NamespaceIdent :: from_strs ( [ "test_list_empty_multi_level_namespace" , "a_a" , "apple" ] )
@@ -422,7 +427,7 @@ async fn test_list_empty_multi_level_namespace() {
422427
423428#[ tokio:: test]
424429async fn test_register_table ( ) {
425- let catalog = get_catalog ( ) . await ;
430+ let catalog = get_catalog ( None ) . await ;
426431
427432 // Create namespace
428433 let ns = NamespaceIdent :: from_strs ( [ "ns" ] ) . unwrap ( ) ;
@@ -471,36 +476,6 @@ impl CustomAuthenticator for CountingAuthenticator {
471476 }
472477}
473478
474- async fn get_catalog_with_authenticator (
475- authenticator : Arc < dyn CustomAuthenticator > ,
476- ) -> RestCatalog {
477- set_up ( ) ;
478-
479- let rest_catalog_ip = {
480- let guard = DOCKER_COMPOSE_ENV . read ( ) . unwrap ( ) ;
481- let docker_compose = guard. as_ref ( ) . unwrap ( ) ;
482- docker_compose. get_container_ip ( "rest" )
483- } ;
484-
485- let rest_socket_addr = SocketAddr :: new ( rest_catalog_ip, REST_CATALOG_PORT ) ;
486- while !scan_port_addr ( rest_socket_addr) {
487- info ! ( "Waiting for 1s rest catalog to ready..." ) ;
488- sleep ( std:: time:: Duration :: from_millis ( 1000 ) ) . await ;
489- }
490-
491- RestCatalogBuilder :: default ( )
492- . with_token_authenticator ( authenticator)
493- . load (
494- "rest" ,
495- HashMap :: from ( [ (
496- REST_CATALOG_PROP_URI . to_string ( ) ,
497- format ! ( "http://{rest_socket_addr}" ) ,
498- ) ] ) ,
499- )
500- . await
501- . unwrap ( )
502- }
503-
504479#[ tokio:: test]
505480async fn test_authenticator_token_refresh ( ) {
506481 // Track how many times tokens were requested
@@ -511,7 +486,7 @@ async fn test_authenticator_token_refresh() {
511486 count : token_request_count_clone,
512487 } ) ;
513488
514- let catalog_with_auth = get_catalog_with_authenticator ( authenticator) . await ;
489+ let catalog_with_auth = get_catalog ( Some ( authenticator) ) . await ;
515490
516491 // Perform multiple operations that should trigger token requests
517492 let ns1 = Namespace :: with_properties (
@@ -550,7 +525,7 @@ async fn test_authenticator_persists_across_operations() {
550525 count : operation_count_clone,
551526 } ) ;
552527
553- let catalog_with_auth = get_catalog_with_authenticator ( authenticator) . await ;
528+ let catalog_with_auth = get_catalog ( Some ( authenticator) ) . await ;
554529
555530 // Create a namespace
556531 let ns = Namespace :: with_properties (
0 commit comments