@@ -673,12 +673,56 @@ bind_addr = "127.0.0.1:8080"
673673 config. validate( ) . expect( "config should validate" ) ;
674674 }
675675
676+ <<<<<<< HEAD
676677 #[ test ]
677678 fn s3_timeout_defaults_are_applied ( ) {
679+ =======
680+ fn sample_s3_config_toml ( circuit_path : & Path , credential_lines : & str ) -> String {
681+ format ! (
682+ r#"
683+ [logging]
684+ filter = "debug"
685+
686+ [circuit]
687+ path = "{}"
688+
689+ [network]
690+ signing_key_hex = "1111111111111111111111111111111111111111111111111111111111111111"
691+ bind_addr = "127.0.0.1:7000"
692+
693+ [[network.peers]]
694+ peer_id_hex = "2222222222222222222222222222222222222222222222222222222222222222"
695+ addr = "127.0.0.1:7001"
696+
697+ [storage]
698+
699+ [table_store]
700+ backend = "s3_compatible"
701+ bucket = "bucket"
702+ region = "us-east-1"
703+ prefix = "prefix"
704+ {}
705+
706+ [job_scheduler]
707+
708+ [sm_executor]
709+
710+ [rpc]
711+ bind_addr = "127.0.0.1:8080"
712+ "# ,
713+ circuit_path. display( ) ,
714+ credential_lines
715+ )
716+ }
717+
718+ #[ test]
719+ fn validate_accepts_s3_default_credential_chain( ) {
720+ >>>>>>> 6 d1277f ( config: reject invalid s3 session token configs)
678721 let path = std:: env:: current_exe ( ) . expect( "current executable path" ) ;
679722 let config: MosaicConfig =
680723 toml:: from_str ( & sample_s3_config_toml( & path, "" ) ) . expect( "config should parse" ) ;
681724
725+ <<<<<<< HEAD
682726 let options = config
683727 . table_store
684728 . backend
@@ -725,6 +769,44 @@ bind_addr = "127.0.0.1:8080"
725769 assert_eq!(
726770 options. get_config_value( & ClientConfigKey :: ConnectTimeout ) ,
727771 expected. get_config_value( & ClientConfigKey :: ConnectTimeout )
772+ =======
773+ config. validate( ) . expect( "config should validate" ) ;
774+ }
775+
776+ #[ test]
777+ fn validate_accepts_s3_static_credentials_with_optional_token( ) {
778+ let path = std:: env:: current_exe( ) . expect( "current executable path" ) ;
779+ let config: MosaicConfig = toml:: from_str( & sample_s3_config_toml(
780+ & path,
781+ r#"
782+ access_key_id = "access"
783+ secret_access_key = "secret"
784+ session_token = "token"
785+ "# ,
786+ ) )
787+ . expect( "config should parse" ) ;
788+
789+ config. validate( ) . expect( "config should validate" ) ;
790+ }
791+
792+ #[ test]
793+ fn validate_rejects_s3_session_token_without_static_credentials( ) {
794+ let path = std:: env:: current_exe( ) . expect( "current executable path" ) ;
795+ let config: MosaicConfig = toml:: from_str( & sample_s3_config_toml(
796+ & path,
797+ r#"
798+ session_token = "token"
799+ "# ,
800+ ) )
801+ . expect( "config should parse" ) ;
802+
803+ let error = config. validate( ) . expect_err( "config should be rejected" ) ;
804+ assert!(
805+ error
806+ . to_string( )
807+ . contains( "table_store.session_token requires table_store.access_key_id" ) ,
808+ "unexpected error: {error}"
809+ >>>>>>> 6 d1277f ( config: reject invalid s3 session token configs)
728810 ) ;
729811 }
730812}
0 commit comments