-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #19139: CSRF in Reset Survey menus
New remote control tests added.
- Loading branch information
1 parent
f0ae09b
commit 669bf8d
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
} | ||
} |