@@ -247,10 +247,10 @@ public function testDbPortIsReturnedWhenThisParameterIsSet()
247247 self ::assertEquals ($ expectedPort , $ actualPort );
248248 }
249249
250- public function testDBPasswordFromPasswordFileIsTrimmedAndReturned ()
250+ public function testDBPasswordFromPasswordFileIsReturned ()
251251 {
252252
253- $ expectedPassword = 'very-secret 909!&äßZ ' ;
253+ $ expectedPassword = 'v_erY-secr3ttt 909!&äßZ ' ;
254254
255255 $ db_password_file = tempnam ("/tmp " , "user_backend_sql_raw-db_password_file " );
256256 if ($ db_password_file === false ) {
@@ -262,8 +262,38 @@ public function testDBPasswordFromPasswordFileIsTrimmedAndReturned()
262262 self ::fail ("Temporary db password file could not be opened for writing. " );
263263 }
264264
265- // add whitespace at the end which will be trimmed
266- fwrite ($ file , "{$ expectedPassword } " );
265+ fwrite ($ file , $ expectedPassword );
266+ fclose ($ file );
267+
268+ $ this ->nextcloudConfigStub ->method ('getSystemValue ' )
269+ ->willReturn (array (
270+ 'db_password_file ' => $ db_password_file ,
271+ ));
272+
273+ $ config = new Config ($ this ->logStub , $ this ->nextcloudConfigStub );
274+
275+ $ actualPassword = $ config ->getDbPassword ();
276+ unlink ($ db_password_file );
277+ self ::assertEquals ($ expectedPassword , $ actualPassword );
278+ }
279+
280+ public function testDBPasswordFromPasswordFileIsTrimmed ()
281+ {
282+
283+ $ expectedPassword = 'secret ' ;
284+
285+ $ db_password_file = tempnam ("/tmp " , "user_backend_sql_raw-db_password_file " );
286+ if ($ db_password_file === false ) {
287+ self ::fail ("Temporary db password file could not be created. " );
288+ }
289+
290+ $ file = fopen ($ db_password_file , "w " );
291+ if ($ file === false ) {
292+ self ::fail ("Temporary db password file could not be opened for writing. " );
293+ }
294+
295+ // add tab in front and whitespace at the end which will be trimmed
296+ fwrite ($ file , "\t{$ expectedPassword } " );
267297 fclose ($ file );
268298
269299 $ this ->nextcloudConfigStub ->method ('getSystemValue ' )
0 commit comments