Skip to content

Commit

Permalink
Delete legacy home page
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienClairembault authored Oct 29, 2024
1 parent 6481fc9 commit 5a6b43a
Show file tree
Hide file tree
Showing 22 changed files with 168 additions and 447 deletions.
14 changes: 0 additions & 14 deletions front/helpdesk.html

This file was deleted.

111 changes: 0 additions & 111 deletions front/helpdesk.public.php

This file was deleted.

109 changes: 0 additions & 109 deletions front/tracking.injector.php

This file was deleted.

3 changes: 0 additions & 3 deletions phpunit/functional/Glpi/Http/FirewallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function testComputeFallbackStrategy(): void
'cron.php' => '',
'css.php' => '',
'document.send.php' => '',
'helpdesk.php' => '',
'helpdesk.faq.php' => '',
'inventory.php' => '',
'locale.php' => '',
Expand Down Expand Up @@ -200,13 +199,11 @@ public function testComputeFallbackStrategy(): void
'/front/cron.php',
'/front/css.php',
'/front/document.send.php',
'/front/helpdesk.php',
'/front/inventory.php',
'/front/locale.php',
'/front/login.php',
'/front/logout.php',
'/front/lostpassword.php',
'/front/tracking.injector.php',
'/front/updatepassword.php',
];
foreach ($legacy_no_check_urls as $no_check_url) {
Expand Down
85 changes: 85 additions & 0 deletions phpunit/functional/Glpi/Http/RedirectLegacyRouteListenerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2024 Teclib' and contributors.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/

namespace tests\units\Glpi\Http;

use Glpi\Http\RedirectLegacyRouteListener;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelInterface;

final class RedirectLegacyRouteListenerTest extends TestCase
{
public static function provideLegacyUrl(): iterable
{
foreach (['', '/glpi', '/support/glpi'] as $root_doc) {
yield [
'root_doc' => $root_doc,
'path' => $root_doc . '/front/helpdesk.public.php',
'expected' => $root_doc . '/Helpdesk',
];

yield [
'root_doc' => $root_doc,
'path' => $root_doc . '/front/not.redirected.php',
'expected' => null,
];
}
}

#[DataProvider('provideLegacyUrl')]
public function testRedirection(string $root_doc, string $path, ?string $expected): void
{
$request = new Request();
$request->server->set('SCRIPT_FILENAME', $root_doc . '/index.php');
$request->server->set('SCRIPT_NAME', $root_doc . '/index.php');
$request->server->set('REQUEST_URI', $path);

$event = new RequestEvent($this->createMock(KernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST);

$listener = new RedirectLegacyRouteListener();
$listener->onKernelRequest($event);

if ($expected === null) {
$this->assertNull($event->getResponse());
} else {
$this->assertInstanceOf(RedirectResponse::class, $event->getResponse());
$this->assertEquals($expected, $event->getResponse()->getTargetUrl());
}
}
}
2 changes: 1 addition & 1 deletion src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ public static function redirectIfAuthenticated($redirect = null)
if ($_SESSION['glpiactiveprofile']['create_ticket_on_login']) {
Html::redirect($CFG_GLPI['root_doc'] . "/ServiceCatalog");
}
Html::redirect($CFG_GLPI['root_doc'] . "/front/helpdesk.public.php");
Html::redirect($CFG_GLPI['root_doc'] . "/Helpdesk");
} else {
if ($_SESSION['glpiactiveprofile']['create_ticket_on_login']) {
Html::redirect(Ticket::getFormURL());
Expand Down
2 changes: 1 addition & 1 deletion src/Glpi/Application/View/Extension/RoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function indexPath(): string
$index = '/index.php';
if (Session::getLoginUserID() !== false) {
$index = Session::getCurrentInterface() == 'helpdesk'
? 'front/helpdesk.public.php'
? 'Helpdesk'
: 'front/central.php';
}
return Html::getPrefixedUrl($index);
Expand Down
Loading

0 comments on commit 5a6b43a

Please sign in to comment.