File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed 
main/java/org/testcontainers/containers 
test/java/org/testcontainers/junit/mariadb Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,10 @@ protected void configure() {
7575        );
7676
7777        addEnv ("MYSQL_DATABASE" , databaseName );
78-         addEnv ("MYSQL_USER" , username );
78+ 
79+         if  (!MARIADB_ROOT_USER .equalsIgnoreCase (this .username )) {
80+             addEnv ("MYSQL_USER" , username );
81+         }
7982        if  (password  != null  && !password .isEmpty ()) {
8083            addEnv ("MYSQL_PASSWORD" , password );
8184            addEnv ("MYSQL_ROOT_PASSWORD" , password );
Original file line number Diff line number Diff line change @@ -132,6 +132,18 @@ public void testWithOnlyUserReadableCustomIniFile() throws Exception {
132132        }
133133    }
134134
135+     @ Test 
136+     public  void  testEmptyPasswordWithRootUser () throws  SQLException  {
137+         try  (MariaDBContainer <?> mysql  = new  MariaDBContainer <>("mariadb:11.2.4" ).withUsername ("root" )) {
138+             mysql .start ();
139+ 
140+             ResultSet  resultSet  = performQuery (mysql , "SELECT 1" );
141+             int  resultSetInt  = resultSet .getInt (1 );
142+ 
143+             assertThat (resultSetInt ).isEqualTo (1 );
144+         }
145+     }
146+ 
135147    private  void  assertThatCustomIniFileWasUsed (MariaDBContainer <?> mariadb ) throws  SQLException  {
136148        try  (ResultSet  resultSet  = performQuery (mariadb , "SELECT @@GLOBAL.innodb_max_undo_log_size" )) {
137149            long  result  = resultSet .getLong (1 );
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments