Skip to content

Commit

Permalink
Fixed issue #19139: CSRF in Reset Survey menus
Browse files Browse the repository at this point in the history
New remote control tests added.
  • Loading branch information
lapiudevgit committed Nov 14, 2023
1 parent f0ae09b commit 669bf8d
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/functional/backend/RemoteControlTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace ls\tests;

use Yii;

class RemoteControlTest extends TestBaseClassWeb
{
private static $tmpBaseUrl;
private static $tmpRPCType;

private static $client;

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

$urlMan = Yii::app()->urlManager;
self::$tmpBaseUrl = $urlMan->getBaseUrl();
$urlMan->setBaseUrl('http://' . self::$domain . '/index.php');
//$serverUrl = App()->createAbsoluteUrl('/admin/remotecontrol');
$serverUrl = $urlMan->createUrl('/admin/remotecontrol');

self::$tmpRPCType = Yii::app()->getConfig('RPCInterface');

if (self::$tmpRPCType === 'off') {
\SettingGlobal::setSetting('RPCInterface', 'json');
$RPCType = 'json';
} else {
$RPCType = self::$tmpRPCType;
}

if ($RPCType == 'xml') {
$cur_path = get_include_path();
set_include_path($cur_path . PATH_SEPARATOR . APPPATH . 'helpers');
require_once('Zend/XmlRpc/Client.php');

self::$client = new \Zend_XmlRpc_Client($serverUrl);
} elseif ($RPCType == 'json') {
Yii::app()->loadLibrary('jsonRPCClient');
self::$client = new \jsonRPCClient($serverUrl);
}
}

public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();

$urlMan = Yii::app()->urlManager;
$urlMan->setBaseUrl(self::$tmpBaseUrl);

\SettingGlobal::setSetting('RPCInterface', self::$tmpRPCType);
}

public function testGetSessionKey()
{
$sessionKey = self::$client->call('get_session_key', ['admin', 'password']);
$this->assertIsNotArray($sessionKey);

self::$client->call('release_session_key', [$sessionKey]);
}
}

0 comments on commit 669bf8d

Please sign in to comment.