Merge remote-tracking branch 'origin/support/2.7' into support/3.0

This commit is contained in:
Pierre Goiffon
2023-07-06 15:48:42 +02:00
8 changed files with 47 additions and 14 deletions

View File

@@ -229,6 +229,7 @@ HTML
$this->Set('refresh_token', $oAccessToken->getRefreshToken()); $this->Set('refresh_token', $oAccessToken->getRefreshToken());
} }
$this->Set('status', 'active'); $this->Set('status', 'active');
$this->AllowWrite();
$this->DBUpdate(); $this->DBUpdate();
} }
]]></code> ]]></code>

View File

@@ -11,6 +11,7 @@ use Combodo\iTop\Application\TwigBase\Controller\Controller;
use Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory; use Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProviderFactory;
use Dict; use Dict;
use IssueLog; use IssueLog;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use MetaModel; use MetaModel;
use utils; use utils;
use WebPage; use WebPage;
@@ -65,13 +66,15 @@ class AjaxOauthClientController extends Controller
} }
if (isset($aQuery['code'])) { if (isset($aQuery['code'])) {
$sCode = $aQuery['code']; $sCode = $aQuery['code'];
$oAccessToken = OAuthClientProviderFactory::GetAccessTokenFromCode($oOAuthClient, $sCode); try {
$oAccessToken = OAuthClientProviderFactory::GetAccessTokenFromCode($oOAuthClient, $sCode);
$oOAuthClient->SetAccessToken($oAccessToken); $oOAuthClient->SetAccessToken($oAccessToken);
$aResult['status'] = 'success';
}
catch (IdentityProviderException $e) {
$aResult['status'] = 'success'; $aResult['status'] = 'error';
$aResult['error_description'] = $e->getMessage();
}
} }
} else { } else {
$aResult['status'] = 'error'; $aResult['status'] = 'error';

View File

@@ -306,6 +306,7 @@ class DBBackup
$sPortOption = self::GetMysqliCliSingleOption('port', $this->iDBPort); $sPortOption = self::GetMysqliCliSingleOption('port', $this->iDBPort);
$sTlsOptions = self::GetMysqlCliTlsOptions($this->oConfig); $sTlsOptions = self::GetMysqlCliTlsOptions($this->oConfig);
$sProtocolOption = self::GetMysqlCliTransportOption($this->sDBHost);
$sMysqlVersion = CMDBSource::GetDBVersion(); $sMysqlVersion = CMDBSource::GetDBVersion();
$bIsMysqlSupportUtf8mb4 = (version_compare($sMysqlVersion, self::MYSQL_VERSION_WITH_UTF8MB4_IN_PROGRAMS) === -1); $bIsMysqlSupportUtf8mb4 = (version_compare($sMysqlVersion, self::MYSQL_VERSION_WITH_UTF8MB4_IN_PROGRAMS) === -1);
@@ -326,8 +327,8 @@ EOF;
// Note: opt implicitely sets lock-tables... which cancels the benefit of single-transaction! // Note: opt implicitely sets lock-tables... which cancels the benefit of single-transaction!
// skip-lock-tables compensates and allows for writes during a backup // skip-lock-tables compensates and allows for writes during a backup
$sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1"; $sCommand = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=$sUser $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables 2>&1";
$sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables"; $sCommandDisplay = "$sMySQLDump --defaults-extra-file=\"$sMySQLDumpCnfFile\" --opt --skip-lock-tables --default-character-set=".$sMysqldumpCharset." --add-drop-database --single-transaction --host=$sHost $sPortOption $sProtocolOption --user=xxxxx $sTlsOptions --result-file=$sTmpFileName $sDBName $sTables";
// Now run the command for real // Now run the command for real
$this->LogInfo("backup: generate data file with command: $sCommandDisplay"); $this->LogInfo("backup: generate data file with command: $sCommandDisplay");
@@ -520,6 +521,24 @@ EOF;
return ' --'.$sCliArgName.'='.self::EscapeShellArg($sData); return ' --'.$sCliArgName.'='.self::EscapeShellArg($sData);
} }
/**
* @param string $sHost
*
* @return string .
* @since 2.7.9 3.0.4 3.1.1 N°6123
*/
public static function GetMysqlCliTransportOption(string $sHost)
{
$sTransportOptions = '';
if($sHost === 'localhost'){
$sTransportOptions = '--protocol=tcp';
}
return $sTransportOptions;
}
/** /**
* @return string the command to launch mysqldump (without its params) * @return string the command to launch mysqldump (without its params)
*/ */

View File

@@ -74,6 +74,7 @@ class OAuthClientProviderFactory
* @return AccessTokenInterface * @return AccessTokenInterface
* @throws \ArchivedObjectException * @throws \ArchivedObjectException
* @throws \CoreException * @throws \CoreException
* @throws \League\OAuth2\Client\Provider\Exception\IdentityProviderException
*/ */
public static function GetAccessTokenFromCode(OAuthClient $oOAuthClient, $sCode) public static function GetAccessTokenFromCode(OAuthClient $oOAuthClient, $sCode)
{ {
@@ -109,7 +110,7 @@ class OAuthClientProviderFactory
/** /**
* @param \DBObject $oOAuthClient * @param \DBObject $oOAuthClient
* *
* @return mixed * @return OAuthClientProviderAbstract
* @throws \ArchivedObjectException * @throws \ArchivedObjectException
* @throws \CoreException * @throws \CoreException
*/ */

View File

@@ -181,7 +181,11 @@ class EmailSwiftMailer extends EMail
case 'PHPMail': case 'PHPMail':
default: default:
$oTransport = new Swift_SendmailTransport(); // Retrieve sendmail path or select a default one as SwiftMailer is not doing it anymore
$sSendmailPath = ini_get('sendmail_path');
$sSendmailPath = ($sSendmailPath === false || $sSendmailPath === '') ? '/usr/sbin/sendmail -bs' : $sSendmailPath;
$oTransport = new Swift_SendmailTransport($sSendmailPath);
} }
$oMailer = new Swift_Mailer($oTransport); $oMailer = new Swift_Mailer($oTransport);

View File

@@ -18,6 +18,9 @@ namespace Combodo\iTop\Test\UnitTest\Integration;
use Combodo\iTop\Test\UnitTest\ItopTestCase; use Combodo\iTop\Test\UnitTest\ItopTestCase;
/**
* @group beforeSetup
*/
class DictionariesConsistencyTest extends ItopTestCase class DictionariesConsistencyTest extends ItopTestCase
{ {
/** /**

View File

@@ -15,7 +15,7 @@ use PHPUnit\Exception;
* *
* @package Combodo\iTop\Test\UnitTest\Setup * @package Combodo\iTop\Test\UnitTest\Setup
*/ */
class TestForITopDesignFormatClass extends ItopTestCase class iTopDesignFormatChecklistTest extends ItopTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
@@ -47,7 +47,7 @@ class TestForITopDesignFormatClass extends ItopTestCase
$aErrors[] = "cannot retrieve itop_design datamodel version in $sDataModelFile:1"; $aErrors[] = "cannot retrieve itop_design datamodel version in $sDataModelFile:1";
continue; continue;
} }
$aDatamodelCurrentVersions[$sVersion] = $sVersion; $aDatamodelCurrentVersions[$sVersion] = $sVersion;
} }
} }
@@ -159,4 +159,4 @@ class TestForITopDesignFormatClass extends ItopTestCase
} }
return $aDataModelFiles; return $aDataModelFiles;
} }
} }

View File

@@ -16,6 +16,7 @@
stopOnRisky="false" stopOnRisky="false"
stopOnSkipped="false" stopOnSkipped="false"
verbose="true" verbose="true"
printerClass="Sempro\PHPUnitPrettyPrinter\PrettyPrinter"
> >
<php> <php>
@@ -23,6 +24,7 @@
<ini name="display_errors" value="On"/> <ini name="display_errors" value="On"/>
<ini name="log_errors" value="On"/> <ini name="log_errors" value="On"/>
<ini name="html_errors" value="Off"/> <ini name="html_errors" value="Off"/>
<env name="PHPUNIT_PRETTY_PRINT_PROGRESS" value="true"/>
</php> </php>
<testsuites> <testsuites>