Set('db_tls.enabled', false); $sCliArgsNoTls = DBBackup::GetMysqlCliTlsOptions($oConfigToTest); $this->assertEmpty($sCliArgsNoTls); } /** * TLS connection configured = we need one CLI arg * * @return void * @throws \ConfigException * @throws \CoreException */ public function testGetMysqlCliTlsOptionsWithTlsNoCa() { $oConfigToTest = utils::GetConfig(); $oConfigToTest->Set('db_tls.enabled', true); $sCliArgsMinCfg = DBBackup::GetMysqlCliTlsOptions($oConfigToTest); // depending on the MySQL version, we would have `--ssl` or `--ssl-mode=VERIFY_CA` $this->assertStringStartsWith(' --ssl', $sCliArgsMinCfg); } /** * TLS connection configured + CA option = we need multiple CLI args * * @return void * @throws \ConfigException * @throws \CoreException */ public function testGetMysqlCliTlsOptionsWithTlsAndCa() { $oConfigToTest = utils::GetConfig(); $sTestCa = 'my_test_ca'; $oConfigToTest->Set('db_tls.enabled', true); $oConfigToTest->Set('db_tls.ca', $sTestCa); $sCliArgsCapathCfg = DBBackup::GetMysqlCliTlsOptions($oConfigToTest); $this->assertStringStartsWith(' --ssl', $sCliArgsCapathCfg); $this->assertStringEndsWith('--ssl-ca='.DBBackup::EscapeShellArg($sTestCa), $sCliArgsCapathCfg); } }