fix: [synctool] tests improved

pull/5635/head
iglocska 2020-03-02 23:09:47 +01:00
parent 183812756f
commit 03dc9a8206
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
3 changed files with 18 additions and 5 deletions

View File

@ -3,7 +3,7 @@
class SyncTool
{
// take a server as parameter and return a HttpSocket object using the ssl options defined in the server settings
public function setupHttpSocket($server = null)
public function setupHttpSocket($server = null, $timeout = false)
{
$params = array();
if (!empty($server)) {
@ -23,6 +23,9 @@ class SyncTool
if (!empty($server['Server']['skip_proxy'])) {
$params['skip_proxy'] = 1;
}
if (!empty($timeout)) {
$params['timeout'] = $timeout;
}
}
return $this->createHttpSocket($params);

View File

@ -286,7 +286,7 @@ class AppModel extends Model
public function updateDatabase($command)
{
$this->Log = ClassRegistry::init('Log');
$liveOff = false;
$exitOnError = false;
if (isset($this->advanced_updates_description[$command])) {
@ -2494,12 +2494,12 @@ class AppModel extends Model
return true;
}
public function setupHttpSocket($server, $HttpSocket = null)
public function setupHttpSocket($server, $HttpSocket = null, $timeout = false)
{
if (empty($HttpSocket)) {
App::uses('SyncTool', 'Tools');
$syncTool = new SyncTool();
$HttpSocket = $syncTool->setupHttpSocket($server);
$HttpSocket = $syncTool->setupHttpSocket($server, $timeout);
}
return $HttpSocket;
}

View File

@ -113,10 +113,20 @@ class Server extends AppModel
),
);
public $syncTestErrorCodes = array();
public function __construct($id = false, $table = null, $ds = null)
{
parent::__construct($id, $table, $ds);
$this->syncTestErrorCodes = array(
2 => __('Server unreachable'),
3 => __('Unexpected error'),
4 => __('Authentication failed'),
5 => __('Password change required'),
6 => __('Terms not accepted')
);
$this->command_line_functions = array(
'console_admin_tasks' => array(
'data' => array(
@ -4064,7 +4074,7 @@ class Server extends AppModel
public function runConnectionTest($id)
{
$server = $this->find('first', array('conditions' => array('Server.id' => $id)));
$HttpSocket = $this->setupHttpSocket($server);
$HttpSocket = $this->setupHttpSocket($server, null, 5);
$request = $this->setupSyncRequest($server);
$uri = $server['Server']['url'] . '/servers/getVersion';
try {