mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Fix tests
This commit is contained in:
@@ -92,6 +92,7 @@ use Alchemy\Phrasea\Core\Provider\JMSSerializerServiceProvider;
|
|||||||
use Alchemy\Phrasea\Core\Provider\LocaleServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\LocaleServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\NotificationDelivererServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\Provider\ORMServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\ORMServiceProvider;
|
||||||
|
use Alchemy\Phrasea\Core\Provider\PhraseaEventServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\PhraseanetServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\Provider\PluginServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\PluginServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\Provider\PhraseaVersionServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\PhraseaVersionServiceProvider;
|
||||||
@@ -307,6 +308,7 @@ class Application extends SilexApplication
|
|||||||
$this->register(new XPDFServiceProvider());
|
$this->register(new XPDFServiceProvider());
|
||||||
$this->register(new FileServeServiceProvider());
|
$this->register(new FileServeServiceProvider());
|
||||||
$this->register(new PluginServiceProvider());
|
$this->register(new PluginServiceProvider());
|
||||||
|
$this->register(new PhraseaEventServiceProvider());
|
||||||
|
|
||||||
$this['phraseanet.exception_handler'] = $this->share(function ($app) {
|
$this['phraseanet.exception_handler'] = $this->share(function ($app) {
|
||||||
return PhraseaExceptionHandler::register($app['debug']);
|
return PhraseaExceptionHandler::register($app['debug']);
|
||||||
@@ -399,11 +401,11 @@ class Application extends SilexApplication
|
|||||||
$this->extend('dispatcher', function ($dispatcher, Application $app) {
|
$this->extend('dispatcher', function ($dispatcher, Application $app) {
|
||||||
$dispatcher->addListener(KernelEvents::REQUEST, array($app, 'initSession'), 254);
|
$dispatcher->addListener(KernelEvents::REQUEST, array($app, 'initSession'), 254);
|
||||||
$dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'addUTF8Charset'), -128);
|
$dispatcher->addListener(KernelEvents::RESPONSE, array($app, 'addUTF8Charset'), -128);
|
||||||
$dispatcher->addSubscriber(new LogoutSubscriber());
|
$dispatcher->addSubscriber($app['phraseanet.logout-subscriber']);
|
||||||
$dispatcher->addSubscriber(new PhraseaLocaleSubscriber($app));
|
$dispatcher->addSubscriber($app['phraseanet.locale-subscriber']);
|
||||||
$dispatcher->addSubscriber(new MaintenanceSubscriber($app));
|
$dispatcher->addSubscriber($app['phraseanet.maintenance-subscriber']);
|
||||||
$dispatcher->addSubscriber(new CookiesDisablerSubscriber($app));
|
$dispatcher->addSubscriber($app['phraseanet.cookie-disabler-subscriber']);
|
||||||
$dispatcher->addSubscriber(new SessionManagerSubscriber($app));
|
$dispatcher->addSubscriber($app['phraseanet.session-manager-subscriber']);
|
||||||
|
|
||||||
return $dispatcher;
|
return $dispatcher;
|
||||||
})
|
})
|
||||||
@@ -792,94 +794,6 @@ class Application extends SilexApplication
|
|||||||
|
|
||||||
$this->mount('/datafiles/', new Datafiles());
|
$this->mount('/datafiles/', new Datafiles());
|
||||||
|
|
||||||
// log real human activity on application, to keep session alive
|
|
||||||
$app = $this;
|
|
||||||
$this->before(function(Request $request) use ($app) {
|
|
||||||
|
|
||||||
$modulesIds = array(
|
|
||||||
"prod" => 1,
|
|
||||||
"client" => 2,
|
|
||||||
"admin" => 3,
|
|
||||||
"thesaurus" => 5,
|
|
||||||
"report" => 10,
|
|
||||||
"lightbox" => 6,
|
|
||||||
);
|
|
||||||
|
|
||||||
$pathInfo = explode('/', $request->getPathInfo());
|
|
||||||
|
|
||||||
if(count($pathInfo) < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$moduleName = strtolower($pathInfo[1]);
|
|
||||||
if(!array_key_exists($moduleName, $modulesIds) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this route is polled by js in admin/databox to refresh infos (progress bar...)
|
|
||||||
if(preg_match("#^/admin/databox/[0-9]+/informations/documents/#", $request->getPathInfo()) == 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this route is polled by js in admin/tasks to refresh tasks status
|
|
||||||
if($request->getPathInfo() == "/admin/task-manager/tasks/" && $request->getContentType() == 'json') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we are already disconnected (ex. from another window), quit immediatly
|
|
||||||
if(!($app['authentication']->isAuthenticated())) {
|
|
||||||
if($request->isXmlHttpRequest()) {
|
|
||||||
$r = new Response("End-Session", 403);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$r = new RedirectResponse($app["url_generator"]->generate("homepage", array("redirect"=>'..' . $request->getPathInfo())));
|
|
||||||
}
|
|
||||||
$r->headers->set('X-Phraseanet-End-Session', '1');
|
|
||||||
|
|
||||||
return $r;
|
|
||||||
}
|
|
||||||
|
|
||||||
$session = $app['EM']->find('Entities\Session', $app['session']->get('session_id'));
|
|
||||||
|
|
||||||
$idle = 0;
|
|
||||||
if(isset($app["phraseanet.configuration"]["session"]["idle"])) {
|
|
||||||
$idle = (int)($app["phraseanet.configuration"]["session"]["idle"]);
|
|
||||||
}
|
|
||||||
$now = new \DateTime();
|
|
||||||
$dt = $now->getTimestamp() - $session->getUpdated()->getTimestamp();
|
|
||||||
if($idle > 0 && $dt > $idle) {
|
|
||||||
// we must disconnet due to idletime
|
|
||||||
$app['authentication']->closeAccount();
|
|
||||||
if($request->isXmlHttpRequest()) {
|
|
||||||
$r = new Response("End-Session", 403);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$r = new RedirectResponse($app["url_generator"]->generate("homepage", array("redirect"=>'..' . $request->getPathInfo())));
|
|
||||||
}
|
|
||||||
$r->headers->set('X-Phraseanet-End-Session', '1');
|
|
||||||
|
|
||||||
return $r;
|
|
||||||
}
|
|
||||||
|
|
||||||
$moduleId = $modulesIds[$moduleName];
|
|
||||||
|
|
||||||
$session->setUpdated(new \DateTime());
|
|
||||||
|
|
||||||
if (!$session->hasModuleId($moduleId)) {
|
|
||||||
$module = new \Entities\SessionModule();
|
|
||||||
$module->setModuleId($moduleId);
|
|
||||||
$module->setSession($session);
|
|
||||||
$session->addModule($module);
|
|
||||||
|
|
||||||
$app['EM']->persist($module);
|
|
||||||
} else {
|
|
||||||
$app['EM']->persist($session->getModuleById($moduleId)->setUpdated(new \DateTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
$app['EM']->persist($session);
|
|
||||||
$app['EM']->flush();
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->mount('/admin/', new AdminRoot());
|
$this->mount('/admin/', new AdminRoot());
|
||||||
$this->mount('/admin/dashboard', new Dashboard());
|
$this->mount('/admin/dashboard', new Dashboard());
|
||||||
$this->mount('/admin/collection', new Collection());
|
$this->mount('/admin/collection', new Collection());
|
||||||
@@ -893,8 +807,6 @@ class Application extends SilexApplication
|
|||||||
$this->mount('/admin/fields', new Fields());
|
$this->mount('/admin/fields', new Fields());
|
||||||
$this->mount('/admin/task-manager', new TaskManager());
|
$this->mount('/admin/task-manager', new TaskManager());
|
||||||
$this->mount('/admin/subdefs', new Subdefs());
|
$this->mount('/admin/subdefs', new Subdefs());
|
||||||
$this->mount('/admin/tests/connection', new ConnectionTest());
|
|
||||||
$this->mount('/admin/tests/pathurl', new PathFileTest());
|
|
||||||
|
|
||||||
$this->mount('/client/', new ClientRoot());
|
$this->mount('/client/', new ClientRoot());
|
||||||
$this->mount('/client/baskets', new ClientBasket());
|
$this->mount('/client/baskets', new ClientBasket());
|
||||||
@@ -931,8 +843,6 @@ class Application extends SilexApplication
|
|||||||
$this->mount('/session/', new Session());
|
$this->mount('/session/', new Session());
|
||||||
|
|
||||||
$this->mount('/setup', new SetupController());
|
$this->mount('/setup', new SetupController());
|
||||||
$this->mount('/setup/connection_test/', new ConnectionTest());
|
|
||||||
$this->mount('/setup/test/', new PathFileTest());
|
|
||||||
|
|
||||||
$this->mount('/report/', new ReportRoot());
|
$this->mount('/report/', new ReportRoot());
|
||||||
$this->mount('/report/activity', new ReportActivity());
|
$this->mount('/report/activity', new ReportActivity());
|
||||||
|
@@ -12,13 +12,13 @@
|
|||||||
namespace Alchemy\Phrasea\Controller\Admin;
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Exception\SessionNotFound;
|
use Alchemy\Phrasea\Exception\SessionNotFound;
|
||||||
|
use Alchemy\Phrasea\Helper\DatabaseHelper;
|
||||||
|
use Alchemy\Phrasea\Helper\PathHelper;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ControllerProviderInterface;
|
use Silex\ControllerProviderInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Controller\Root\Session;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
@@ -452,6 +452,24 @@ class Root implements ControllerProviderInterface
|
|||||||
->assert('bit', '\d+')
|
->assert('bit', '\d+')
|
||||||
->bind('database_submit_statusbit');
|
->bind('database_submit_statusbit');
|
||||||
|
|
||||||
|
$controllers->get('/tests/connection/mysql/', function (Application $app, Request $request) {
|
||||||
|
$dbHelper = new DatabaseHelper($app, $request);
|
||||||
|
|
||||||
|
return $app->json($dbHelper->checkConnection());
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/tests/pathurl/path/', function (Application $app, Request $request) {
|
||||||
|
$pathHelper = new PathHelper($app, $request);
|
||||||
|
|
||||||
|
return $app->json($pathHelper->checkPath());
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/tests/pathurl/url/', function (Application $app, Request $request) {
|
||||||
|
$pathHelper = new PathHelper($app, $request);
|
||||||
|
|
||||||
|
return $app->json($pathHelper->checkUrl());
|
||||||
|
});
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,13 +21,13 @@ use Silex\ControllerProviderInterface;
|
|||||||
*/
|
*/
|
||||||
class Language implements ControllerProviderInterface
|
class Language implements ControllerProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function connect(Application $app)
|
public function connect(Application $app)
|
||||||
{
|
{
|
||||||
$controller = $app['controllers_factory'];
|
$controller = $app['controllers_factory'];
|
||||||
|
|
||||||
$controller->get("/", function (Application $app) {
|
$app['firewall']->addMandatoryAuthentication($controller);
|
||||||
|
|
||||||
|
$controller->get("/", function (Application $app) {
|
||||||
$out = array();
|
$out = array();
|
||||||
$out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.');
|
$out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.');
|
||||||
$out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?');
|
$out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?');
|
||||||
|
@@ -39,7 +39,7 @@ class Session implements ControllerProviderInterface
|
|||||||
->bind('update_session');
|
->bind('update_session');
|
||||||
|
|
||||||
$controllers->post('/notifications/', $this->call('getNotifications'))
|
$controllers->post('/notifications/', $this->call('getNotifications'))
|
||||||
->bind('get_notifications');
|
->bind('list_notifications');
|
||||||
|
|
||||||
$controller = $controllers->post('/delete/{id}', $this->call('deleteSession'))
|
$controller = $controllers->post('/delete/{id}', $this->call('deleteSession'))
|
||||||
->bind('delete_session');
|
->bind('delete_session');
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
namespace Alchemy\Phrasea\Controller;
|
namespace Alchemy\Phrasea\Controller;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Helper\DatabaseHelper;
|
||||||
|
use Alchemy\Phrasea\Helper\PathHelper;
|
||||||
use Alchemy\Phrasea\Setup\Requirements\BinariesRequirements;
|
use Alchemy\Phrasea\Setup\Requirements\BinariesRequirements;
|
||||||
use Alchemy\Phrasea\Setup\Requirements\FilesystemRequirements;
|
use Alchemy\Phrasea\Setup\Requirements\FilesystemRequirements;
|
||||||
use Alchemy\Phrasea\Setup\Requirements\LocalesRequirements;
|
use Alchemy\Phrasea\Setup\Requirements\LocalesRequirements;
|
||||||
@@ -46,6 +48,24 @@ class Setup implements ControllerProviderInterface
|
|||||||
$controllers->post('/installer/install/', 'controller.setup:doInstall')
|
$controllers->post('/installer/install/', 'controller.setup:doInstall')
|
||||||
->bind('install_do_install');
|
->bind('install_do_install');
|
||||||
|
|
||||||
|
$controllers->get('/connection_test/mysql/', function (Application $app, Request $request) {
|
||||||
|
$dbHelper = new DatabaseHelper($app, $request);
|
||||||
|
|
||||||
|
return $app->json($dbHelper->checkConnection());
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/test/path/', function (Application $app, Request $request) {
|
||||||
|
$pathHelper = new PathHelper($app, $request);
|
||||||
|
|
||||||
|
return $app->json($pathHelper->checkPath());
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/test/url/', function (Application $app, Request $request) {
|
||||||
|
$pathHelper = new PathHelper($app, $request);
|
||||||
|
|
||||||
|
return $app->json($pathHelper->checkUrl());
|
||||||
|
});
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2014 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Utils;
|
|
||||||
|
|
||||||
use Silex\Application;
|
|
||||||
use Silex\ControllerProviderInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
class ConnectionTest implements ControllerProviderInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public function connect(Application $app)
|
|
||||||
{
|
|
||||||
$controllers = $app['controllers_factory'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo : check this as it would lead to a security issue
|
|
||||||
*/
|
|
||||||
$controllers->get('/mysql/', function (Application $app) {
|
|
||||||
|
|
||||||
$request = $app['request'];
|
|
||||||
$hostname = $request->query->get('hostname', '127.0.0.1');
|
|
||||||
$port = (int) $request->query->get('port', 3306);
|
|
||||||
$user = $request->query->get('user');
|
|
||||||
$password = $request->query->get('password');
|
|
||||||
$dbname = $request->query->get('dbname');
|
|
||||||
|
|
||||||
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), false);
|
|
||||||
$connection_ok = true;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($dbname && $connection_ok === true) {
|
|
||||||
try {
|
|
||||||
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), false);
|
|
||||||
$db_ok = true;
|
|
||||||
|
|
||||||
$sql = "SHOW TABLE STATUS";
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
|
|
||||||
$empty = $stmt->rowCount() === 0;
|
|
||||||
|
|
||||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
if ($row["Name"] === 'sitepreff') {
|
|
||||||
$is_appbox = true;
|
|
||||||
}
|
|
||||||
if ($row["Name"] === 'pref') {
|
|
||||||
$is_databox = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$datas = array(
|
|
||||||
'connection' => $connection_ok
|
|
||||||
, 'database' => $db_ok
|
|
||||||
, 'is_empty' => $empty
|
|
||||||
, 'is_appbox' => $is_appbox
|
|
||||||
, 'is_databox' => $is_databox
|
|
||||||
);
|
|
||||||
|
|
||||||
return $app->json($datas);
|
|
||||||
});
|
|
||||||
|
|
||||||
return $controllers;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2014 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Alchemy\Phrasea\Controller\Utils;
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Silex\Application;
|
|
||||||
use Silex\ControllerProviderInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
class PathFileTest implements ControllerProviderInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public function connect(Application $app)
|
|
||||||
{
|
|
||||||
$controllers = $app['controllers_factory'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo : check this as it would lead to a security issue
|
|
||||||
*/
|
|
||||||
$controllers->get('/path/', function (Application $app, Request $request) {
|
|
||||||
return $app->json(array(
|
|
||||||
'exists' => file_exists($request->query->get('path'))
|
|
||||||
, 'file' => is_file($request->query->get('path'))
|
|
||||||
, 'dir' => is_dir($request->query->get('path'))
|
|
||||||
, 'readable' => is_readable($request->query->get('path'))
|
|
||||||
, 'writeable' => is_writable($request->query->get('path'))
|
|
||||||
, 'executable' => is_executable($request->query->get('path'))
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
$controllers->get('/url/', function (Application $app, Request $request) {
|
|
||||||
return $app->json(array('code' => \http_query::getHttpCodeFromUrl($request->query->get('url'))));
|
|
||||||
});
|
|
||||||
|
|
||||||
return $controllers;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -32,11 +32,11 @@ class SessionManagerSubscriber implements EventSubscriberInterface
|
|||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
KernelEvents::REQUEST => array('onKernelRequest', -112),
|
KernelEvents::REQUEST => array('checkSessionActivity', -112),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onKernelRequest(GetResponseEvent $event)
|
public function checkSessionActivity(GetResponseEvent $event)
|
||||||
{
|
{
|
||||||
$modulesIds = array(
|
$modulesIds = array(
|
||||||
"prod" => 1,
|
"prod" => 1,
|
||||||
|
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Core\Provider;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Event\Subscriber\CookiesDisablerSubscriber;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Subscriber\LogoutSubscriber;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Subscriber\MaintenanceSubscriber;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Subscriber\PhraseaLocaleSubscriber;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Subscriber\SessionManagerSubscriber;
|
||||||
|
use Silex\Application;
|
||||||
|
use Silex\ServiceProviderInterface;
|
||||||
|
|
||||||
|
class PhraseaEventServiceProvider implements ServiceProviderInterface
|
||||||
|
{
|
||||||
|
public function register(Application $app)
|
||||||
|
{
|
||||||
|
$app['phraseanet.logout-subscriber'] = $app->share(function(Application $app) {
|
||||||
|
return new LogoutSubscriber();
|
||||||
|
});
|
||||||
|
$app['phraseanet.locale-subscriber'] = $app->share(function(Application $app) {
|
||||||
|
return new PhraseaLocaleSubscriber($app);
|
||||||
|
});
|
||||||
|
$app['phraseanet.maintenance-subscriber'] = $app->share(function(Application $app) {
|
||||||
|
return new MaintenanceSubscriber($app);
|
||||||
|
});
|
||||||
|
$app['phraseanet.cookie-disabler-subscriber'] = $app->share(function(Application $app) {
|
||||||
|
return new CookiesDisablerSubscriber($app);
|
||||||
|
});
|
||||||
|
$app['phraseanet.session-manager-subscriber'] = $app->share(function(Application $app) {
|
||||||
|
return new SessionManagerSubscriber($app);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function boot(Application $app)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
70
lib/Alchemy/Phrasea/Helper/DatabaseHelper.php
Normal file
70
lib/Alchemy/Phrasea/Helper/DatabaseHelper.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Helper;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class DatabaseHelper extends Helper
|
||||||
|
{
|
||||||
|
public function checkConnection()
|
||||||
|
{
|
||||||
|
$hostname = $this->request->query->get('hostname', '127.0.0.1');
|
||||||
|
$port = (int) $this->request->query->get('port', 3306);
|
||||||
|
$user = $this->request->query->get('user');
|
||||||
|
$password = $this->request->query->get('password');
|
||||||
|
$dbname = $this->request->query->get('dbname');
|
||||||
|
|
||||||
|
$connection_ok = $db_ok = $is_databox = $is_appbox = $empty = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, null, array(), false);
|
||||||
|
$connection_ok = true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($dbname && $connection_ok === true) {
|
||||||
|
try {
|
||||||
|
$conn = new \connection_pdo('test', $hostname, $port, $user, $password, $dbname, array(), false);
|
||||||
|
$db_ok = true;
|
||||||
|
|
||||||
|
$sql = "SHOW TABLE STATUS";
|
||||||
|
$stmt = $conn->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$empty = $stmt->rowCount() === 0;
|
||||||
|
|
||||||
|
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($rs as $row) {
|
||||||
|
if ($row["Name"] === 'sitepreff') {
|
||||||
|
$is_appbox = true;
|
||||||
|
}
|
||||||
|
if ($row["Name"] === 'pref') {
|
||||||
|
$is_databox = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'connection' => $connection_ok,
|
||||||
|
'database' => $db_ok,
|
||||||
|
'is_empty' => $empty,
|
||||||
|
'is_appbox' => $is_appbox,
|
||||||
|
'is_databox' => $is_databox
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
34
lib/Alchemy/Phrasea/Helper/PathHelper.php
Normal file
34
lib/Alchemy/Phrasea/Helper/PathHelper.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Helper;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class PathHelper extends Helper
|
||||||
|
{
|
||||||
|
public function checkPath()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'exists' => file_exists($this->request->query->get('path')),
|
||||||
|
'file' => is_file($this->request->query->get('path')),
|
||||||
|
'dir' => is_dir($this->request->query->get('path')),
|
||||||
|
'readable' => is_readable($this->request->query->get('path')),
|
||||||
|
'writeable' => is_writable($this->request->query->get('path')),
|
||||||
|
'executable' => is_executable($this->request->query->get('path')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkUrl()
|
||||||
|
{
|
||||||
|
return array('code' => \http_query::getHttpCodeFromUrl($this->request->query->get('url')));
|
||||||
|
}
|
||||||
|
}
|
@@ -48,7 +48,7 @@
|
|||||||
function pollNotifications(){
|
function pollNotifications(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "{{ path('get_notifications') }}",
|
url: "{{ path('list_notifications') }}",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: {
|
data: {
|
||||||
module : 3,
|
module : 3,
|
||||||
|
@@ -1025,7 +1025,7 @@
|
|||||||
function pollNotifications(){
|
function pollNotifications(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "{{ path('get_notifications') }}",
|
url: "{{ path('list_notifications') }}",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {
|
data: {
|
||||||
module : 1,
|
module : 1,
|
||||||
|
@@ -19,4 +19,104 @@ class RootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
self::$DI['client']->request('GET', '/admin/');
|
self::$DI['client']->request('GET', '/admin/');
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRouteMysql()
|
||||||
|
{
|
||||||
|
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
"hostname" => $connexion['host'],
|
||||||
|
"port" => $connexion['port'],
|
||||||
|
"user" => $connexion['user'],
|
||||||
|
"password" => $connexion['password'],
|
||||||
|
"dbname" => $connexion['dbname'],
|
||||||
|
);
|
||||||
|
|
||||||
|
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$this->assertTrue($response->isOk());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRouteMysqlFailed()
|
||||||
|
{
|
||||||
|
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
"hostname" => $connexion['host'],
|
||||||
|
"port" => $connexion['port'],
|
||||||
|
"user" => $connexion['user'],
|
||||||
|
"password" => "fakepassword",
|
||||||
|
"dbname" => $connexion['dbname'],
|
||||||
|
);
|
||||||
|
|
||||||
|
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
||||||
|
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||||
|
$this->assertTrue($response->isOk());
|
||||||
|
$this->assertTrue(is_object($content));
|
||||||
|
$this->assertObjectHasAttribute('connection', $content);
|
||||||
|
$this->assertObjectHasAttribute('database', $content);
|
||||||
|
$this->assertObjectHasAttribute('is_empty', $content);
|
||||||
|
$this->assertObjectHasAttribute('is_appbox', $content);
|
||||||
|
$this->assertObjectHasAttribute('is_databox', $content);
|
||||||
|
$this->assertFalse($content->connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRouteMysqlDbFailed()
|
||||||
|
{
|
||||||
|
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
"hostname" => $connexion['host'],
|
||||||
|
"port" => $connexion['port'],
|
||||||
|
"user" => $connexion['user'],
|
||||||
|
"password" => $connexion['password'],
|
||||||
|
"dbname" => "fake-DTABASE-name"
|
||||||
|
);
|
||||||
|
|
||||||
|
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
||||||
|
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||||
|
$this->assertTrue($response->isOk());
|
||||||
|
$this->assertTrue(is_object($content));
|
||||||
|
$this->assertObjectHasAttribute('connection', $content);
|
||||||
|
$this->assertObjectHasAttribute('database', $content);
|
||||||
|
$this->assertObjectHasAttribute('is_empty', $content);
|
||||||
|
$this->assertObjectHasAttribute('is_appbox', $content);
|
||||||
|
$this->assertObjectHasAttribute('is_databox', $content);
|
||||||
|
$this->assertFalse($content->database);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default route test
|
||||||
|
*/
|
||||||
|
public function testRoutePath()
|
||||||
|
{
|
||||||
|
$file = new \SplFileObject(__DIR__ . '/../../../../../files/cestlafete.jpg');
|
||||||
|
self::$DI['client']->request("GET", "/admin/tests/pathurl/path/", array('path' => $file->getPathname()));
|
||||||
|
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$this->assertTrue($response->isOk());
|
||||||
|
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||||
|
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
||||||
|
$this->assertTrue(is_object($content));
|
||||||
|
$this->assertObjectHasAttribute('exists', $content);
|
||||||
|
$this->assertObjectHasAttribute('file', $content);
|
||||||
|
$this->assertObjectHasAttribute('dir', $content);
|
||||||
|
$this->assertObjectHasAttribute('readable', $content);
|
||||||
|
$this->assertObjectHasAttribute('executable', $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRouteUrl()
|
||||||
|
{
|
||||||
|
self::$DI['client']->request("GET", "/admin/tests/pathurl/url/", array('url' => "www.google.com"));
|
||||||
|
|
||||||
|
$response = self::$DI['client']->getResponse();
|
||||||
|
$this->assertTrue($response->isOk());
|
||||||
|
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||||
|
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
||||||
|
$this->assertTrue(is_object($content));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,15 +2,13 @@
|
|||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Controller\Prod;
|
namespace Alchemy\Tests\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
class ControllerLanguageTest extends \PhraseanetWebTestCaseAbstract
|
class ControllerLanguageTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||||
{
|
{
|
||||||
protected $client;
|
protected $client;
|
||||||
|
|
||||||
public function testRootPost()
|
public function testRootPost()
|
||||||
{
|
{
|
||||||
$route = '/prod/language/';
|
self::$DI['client']->request("GET", '/prod/language/');
|
||||||
|
|
||||||
self::$DI['client']->request("GET", $route);
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
||||||
$pageContent = json_decode(self::$DI['client']->getResponse()->getContent());
|
$pageContent = json_decode(self::$DI['client']->getResponse()->getContent());
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
namespace Alchemy\Tests\Phrasea\Controller\Prod;
|
namespace Alchemy\Tests\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
|
use Alchemy\Phrasea\Border\Attribute\AttributeInterface;
|
||||||
|
use Alchemy\Phrasea\Core\Event\Subscriber\SessionManagerSubscriber;
|
||||||
use Symfony\Component\HttpKernel\Client;
|
use Symfony\Component\HttpKernel\Client;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
@@ -15,9 +16,11 @@ class LazaretTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
protected $client;
|
protected $client;
|
||||||
protected static $need_records = false;
|
protected static $need_records = false;
|
||||||
|
|
||||||
public function tearDown()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::tearDown();
|
parent::setUp();
|
||||||
|
|
||||||
|
self::$DI['app']['dispatcher']->removeSubscriber(self::$DI['app']['phraseanet.session-manager-subscriber']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Controller\Utils;
|
|
||||||
|
|
||||||
class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Default route test
|
|
||||||
*/
|
|
||||||
public function testRouteMysql()
|
|
||||||
{
|
|
||||||
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
|
||||||
|
|
||||||
$params = array(
|
|
||||||
"hostname" => $connexion['host'],
|
|
||||||
"port" => $connexion['port'],
|
|
||||||
"user" => $connexion['user'],
|
|
||||||
"password" => $connexion['password'],
|
|
||||||
"dbname" => $connexion['dbname'],
|
|
||||||
);
|
|
||||||
|
|
||||||
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRouteMysqlFailed()
|
|
||||||
{
|
|
||||||
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
|
||||||
|
|
||||||
$params = array(
|
|
||||||
"hostname" => $connexion['host'],
|
|
||||||
"port" => $connexion['port'],
|
|
||||||
"user" => $connexion['user'],
|
|
||||||
"password" => "fakepassword",
|
|
||||||
"dbname" => $connexion['dbname'],
|
|
||||||
);
|
|
||||||
|
|
||||||
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
|
||||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
|
||||||
$this->assertTrue($response->isOk());
|
|
||||||
$this->assertTrue(is_object($content));
|
|
||||||
$this->assertObjectHasAttribute('connection', $content);
|
|
||||||
$this->assertObjectHasAttribute('database', $content);
|
|
||||||
$this->assertObjectHasAttribute('is_empty', $content);
|
|
||||||
$this->assertObjectHasAttribute('is_appbox', $content);
|
|
||||||
$this->assertObjectHasAttribute('is_databox', $content);
|
|
||||||
$this->assertFalse($content->connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRouteMysqlDbFailed()
|
|
||||||
{
|
|
||||||
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
|
||||||
|
|
||||||
$params = array(
|
|
||||||
"hostname" => $connexion['host'],
|
|
||||||
"port" => $connexion['port'],
|
|
||||||
"user" => $connexion['user'],
|
|
||||||
"password" => $connexion['password'],
|
|
||||||
"dbname" => "fake-DTABASE-name"
|
|
||||||
);
|
|
||||||
|
|
||||||
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
|
||||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
|
||||||
$this->assertTrue($response->isOk());
|
|
||||||
$this->assertTrue(is_object($content));
|
|
||||||
$this->assertObjectHasAttribute('connection', $content);
|
|
||||||
$this->assertObjectHasAttribute('database', $content);
|
|
||||||
$this->assertObjectHasAttribute('is_empty', $content);
|
|
||||||
$this->assertObjectHasAttribute('is_appbox', $content);
|
|
||||||
$this->assertObjectHasAttribute('is_databox', $content);
|
|
||||||
$this->assertFalse($content->database);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Controller\Utils;
|
|
||||||
|
|
||||||
class ControllerPathFileTestTest extends \PhraseanetWebTestCaseAbstract
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Default route test
|
|
||||||
*/
|
|
||||||
public function testRoutePath()
|
|
||||||
{
|
|
||||||
$file = new \SplFileObject(__DIR__ . '/../../../../../files/cestlafete.jpg');
|
|
||||||
self::$DI['client']->request("GET", "/admin/tests/pathurl/path/", array('path' => $file->getPathname()));
|
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
|
||||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
|
||||||
$this->assertTrue(is_object($content));
|
|
||||||
$this->assertObjectHasAttribute('exists', $content);
|
|
||||||
$this->assertObjectHasAttribute('file', $content);
|
|
||||||
$this->assertObjectHasAttribute('dir', $content);
|
|
||||||
$this->assertObjectHasAttribute('readable', $content);
|
|
||||||
$this->assertObjectHasAttribute('executable', $content);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testRouteUrl()
|
|
||||||
{
|
|
||||||
self::$DI['client']->request("GET", "/admin/tests/pathurl/url/", array('url' => "www.google.com"));
|
|
||||||
|
|
||||||
$response = self::$DI['client']->getResponse();
|
|
||||||
$this->assertTrue($response->isOk());
|
|
||||||
$this->assertEquals("application/json", self::$DI['client']->getResponse()->headers->get("content-type"));
|
|
||||||
$content = json_decode(self::$DI['client']->getResponse()->getContent());
|
|
||||||
$this->assertTrue(is_object($content));
|
|
||||||
}
|
|
||||||
}
|
|
@@ -40,6 +40,7 @@ class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener
|
|||||||
|
|
||||||
public function startTest(PHPUnit_Framework_Test $test)
|
public function startTest(PHPUnit_Framework_Test $test)
|
||||||
{
|
{
|
||||||
|
echo $test->getName() . "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user