File tree Expand file tree Collapse file tree 8 files changed +74
-9
lines changed
Expand file tree Collapse file tree 8 files changed +74
-9
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ before_script:
1212 - if [ $TRAVIS_PHP_VERSION = "7.4" ]; then wget -O phpstan.phar https://github.com/phpstan/phpstan/releases/download/0.12.18/phpstan.phar ; fi
1313
1414script :
15- - php phpunit.phar --configuration ./build/travis-ci.phpunit.xml
15+ - XDEBUG_MODE=coverage php phpunit.phar --configuration ./build/travis-ci.phpunit.xml
1616 - if [ $TRAVIS_PHP_VERSION = "7.4" ]; then php phpstan.phar analyse --no-progress -c phpstan.neon; fi
1717
1818notifications :
Original file line number Diff line number Diff line change @@ -169,6 +169,14 @@ class Pgdump extends SimulatorExecutable implements Simulator
169169 */
170170 private $ noPrivileges ;
171171
172+ /**
173+ * Set SSL mode
174+ * PGSSLMODE=allow pg_dump ...
175+ *
176+ * @var string
177+ */
178+ private $ sslMode ;
179+
172180 /**
173181 * Setup
174182 *
@@ -196,6 +204,7 @@ private function setupConnection(array $conf)
196204 $ this ->port = Util \Arr::getValue ($ conf , 'port ' , 0 );
197205 $ this ->user = Util \Arr::getValue ($ conf , 'user ' , '' );
198206 $ this ->password = Util \Arr::getValue ($ conf , 'password ' , '' );
207+ $ this ->sslMode = Util \Arr::getValue ($ conf , 'sslMode ' , '' );
199208 }
200209
201210 /**
@@ -264,6 +273,7 @@ protected function createExecutable(Target $target) : Executable
264273 $ executable ->credentials ($ this ->user , $ this ->password )
265274 ->useHost ($ this ->host )
266275 ->usePort ($ this ->port )
276+ ->sslMode ($ this ->sslMode )
267277 ->dumpDatabase ($ this ->database )
268278 ->dumpSchemas ($ this ->schemas )
269279 ->excludeSchemas ($ this ->excludeSchemas )
Original file line number Diff line number Diff line change @@ -37,6 +37,14 @@ class Pgdump extends Abstraction implements Executable
3737 */
3838 private $ port ;
3939
40+ /**
41+ * Set SSL mode
42+ * PGSSLMODE=allow pg_dump ...
43+ *
44+ * @var string
45+ */
46+ private $ sslMode ;
47+
4048 /**
4149 * User to connect with
4250 * --user=<username>
@@ -189,6 +197,20 @@ class Pgdump extends Abstraction implements Executable
189197 'tar ' => true ,
190198 ];
191199
200+ /**
201+ * List of available sslmode
202+ *
203+ * @var array
204+ */
205+ private $ availableSslMode = [
206+ 'disable ' => true ,
207+ 'allow ' => true ,
208+ 'prefer ' => true ,
209+ 'require ' => true ,
210+ 'verify-ca ' => true ,
211+ 'verify-full ' => true ,
212+ ];
213+
192214 /**
193215 * Constructor.
194216 *
@@ -238,6 +260,21 @@ public function usePort(int $port) : Pgdump
238260 return $ this ;
239261 }
240262
263+ /**
264+ * Set the sslmode
265+ *
266+ * @param string $sslMode
267+ * @return Pgdump
268+ */
269+ public function sslMode (string $ sslMode ): Pgdump
270+ {
271+ if ($ sslMode && !isset ($ this ->availableSslMode [$ sslMode ])) {
272+ throw new Exception ('invalid sslMode ' );
273+ }
274+ $ this ->sslMode = $ sslMode ;
275+ return $ this ;
276+ }
277+
241278 /**
242279 * Set database to dump.
243280 *
@@ -454,7 +491,8 @@ protected function createCommandLine() : CommandLine
454491 {
455492 $ process = new CommandLine ();
456493 $ password = $ this ->password ? 'PGPASSWORD= ' . escapeshellarg ($ this ->password ) . ' ' : '' ;
457- $ cmd = new Cmd ($ password . $ this ->binary );
494+ $ sslMode = $ this ->sslMode ? 'PGSSLMODE= ' . escapeshellarg ($ this ->sslMode ) . ' ' : '' ;
495+ $ cmd = new Cmd ($ sslMode . $ password . $ this ->binary );
458496 $ process ->addCommand ($ cmd );
459497
460498 // always disable password prompt
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public function testBackupFail()
115115 try {
116116 $ influxd ->backup ($ target , $ appResult );
117117 } catch (Exception $ e ) {
118- $ this ->assertFileDoesNotExist ($ file );
118+ $ this ->assertFileNotExists ($ file );
119119 throw $ e ;
120120 }
121121 }
Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ public function testBackupFail()
200200 try {
201201 $ ldap ->backup ($ target , $ appResult );
202202 } catch (Exception $ e ) {
203- $ this ->assertFileDoesNotExist ($ file );
203+ $ this ->assertFileNotExists ($ file );
204204 throw $ e ;
205205 }
206206 }
Original file line number Diff line number Diff line change @@ -338,7 +338,7 @@ public function testBackupFail()
338338 try {
339339 $ mysqldump ->backup ($ target , $ appResult );
340340 } catch (Exception $ e ) {
341- $ this ->assertFileDoesNotExist ($ file );
341+ $ this ->assertFileNotExists ($ file );
342342 throw $ e ;
343343 }
344344 }
Original file line number Diff line number Diff line change @@ -38,6 +38,23 @@ public function testDefault()
3838 );
3939 }
4040
41+ /**
42+ * Tests Pgdump::getExecutable
43+ */
44+ public function testSslMode ()
45+ {
46+ $ target = $ this ->createTargetMock ('foo.sql ' );
47+ $ pgDump = new Pgdump ();
48+ $ pgDump ->setup (['pathToPgdump ' => PHPBU_TEST_BIN , 'sslMode ' => 'require ' ]);
49+
50+ $ executable = $ pgDump ->getExecutable ($ target );
51+
52+ $ this ->assertEquals (
53+ 'PGSSLMODE= \'require \' ' . PHPBU_TEST_BIN . '/pg_dump -w --file= \'foo.sql \' --format= \'p \'' ,
54+ $ executable ->getCommand ()
55+ );
56+ }
57+
4158 /**
4259 * Tests Pgdump::getExecutable
4360 */
Original file line number Diff line number Diff line change @@ -181,10 +181,10 @@ public function testRemoveDir()
181181
182182 Cli::removeDir ($ dirToDelete );
183183
184- $ this ->assertFileDoesNotExist ($ file );
185- $ this ->assertFileDoesNotExist ($ fileInSub );
186- $ this ->assertFileDoesNotExist ($ subDir );
187- $ this ->assertFileDoesNotExist ($ dirToDelete );
184+ $ this ->assertFileNotExists ($ file );
185+ $ this ->assertFileNotExists ($ fileInSub );
186+ $ this ->assertFileNotExists ($ subDir );
187+ $ this ->assertFileNotExists ($ dirToDelete );
188188 }
189189
190190 /**
You can’t perform that action at this time.
0 commit comments