mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 00:02:17 +02:00
N°9567 - Extension Mgmt : Run setup (#912)
* N°9144 - correct next button in audit page * N°9567 - WIP code style * N°9412 - Screen Analysis results wip + test endpoint * N°9412 - next button label * N°9412 - Mask CI pbs * N°9412 - Analysis results screen wip * N°9412 - Analysis results screen wip * N°9567 - fix extension map init of installation choices * N°9567 - fix test * N°9567 - link from ext mgt to setup WIP * N°9567 - add enc_type in UIForm to be able to change content type in twigs * N°9412 - wip * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup (fix post-deletion button inputs) * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup --------- Co-authored-by: Eric Espie <eric.espie@combodo.com>
This commit is contained in:
@@ -107,6 +107,59 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
$this->AssertSummaryEquals($aExpected, $aRes);
|
||||
}
|
||||
|
||||
public function testExecuteCleanup_CheckSummaryIsEnrichedAfterEachPass()
|
||||
{
|
||||
$aExecutionSummary = [];
|
||||
|
||||
$this->GivenDFRTreeInDB(
|
||||
<<<EOF
|
||||
DFRToRemoveLeaf_1 <- DFRToUpdate_1
|
||||
DFRToRemoveLeaf_1 <- DFRRemovedCollateral_1
|
||||
DFRRemovedCollateral_1 <- DFRRemovedCollateralCascade_1
|
||||
|
||||
DFRToRemoveLeaf_2 <- DFRToUpdate_2
|
||||
DFRToRemoveLeaf_2 <- DFRRemovedCollateral_2
|
||||
DFRRemovedCollateral_2 <- DFRRemovedCollateralCascade_2
|
||||
|
||||
DFRToRemoveLeaf_3 <- DFRToUpdate_3
|
||||
DFRToRemoveLeaf_3 <- DFRRemovedCollateral_3
|
||||
DFRRemovedCollateral_3 <- DFRRemovedCollateralCascade_3
|
||||
EOF
|
||||
);
|
||||
|
||||
$aClasses = ['DFRToRemoveLeaf'];
|
||||
$oService = new DataCleanupService();
|
||||
$aExecutionSummary = $oService->ExecuteCleanup($aClasses);
|
||||
|
||||
$aExpected = [
|
||||
['DFRToUpdate', 3, 0 ],
|
||||
['DFRToRemoveLeaf', 0, 3 ],
|
||||
['DFRRemovedCollateral', 0, 3 ],
|
||||
['DFRRemovedCollateralCascade', 0, 3 ],
|
||||
];
|
||||
$this->AssertSummaryEquals($aExpected, $aExecutionSummary);
|
||||
|
||||
$this->GivenDFRTreeInDB(
|
||||
<<<EOF
|
||||
DFRToRemoveLeaf_4 <- DFRToUpdate_4
|
||||
DFRToRemoveLeaf_4 <- DFRRemovedCollateral_4
|
||||
DFRRemovedCollateral_4 <- DFRRemovedCollateralCascade_4
|
||||
EOF
|
||||
);
|
||||
|
||||
$aClasses = ['DFRToRemoveLeaf'];
|
||||
$oService = new DataCleanupService();
|
||||
$aExecutionSummary = $oService->ExecuteCleanup($aClasses);
|
||||
|
||||
$aExpected = [
|
||||
['DFRToUpdate', 1, 0, 0, 4 ],
|
||||
['DFRToRemoveLeaf', 0, 1, 0, 0, 4 ],
|
||||
['DFRRemovedCollateral', 0, 1, 0, 0, 4 ],
|
||||
['DFRRemovedCollateralCascade', 0, 1, 0, 0, 4 ],
|
||||
];
|
||||
$this->AssertSummaryEquals($aExpected, $aExecutionSummary);
|
||||
}
|
||||
|
||||
public function testGetCleanupSummary_DeleteManyObjPerClassWithoutLimit()
|
||||
{
|
||||
$this->GivenDFRTreeInDB(<<<EOF
|
||||
@@ -174,11 +227,16 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
$iUpdate = $line[1];
|
||||
$iDelete = $line[2];
|
||||
$iIssue = $line[3] ?? 0;
|
||||
$iTotalUpdate = $line[4] ?? $iUpdate;
|
||||
$iTotalDelete = $line[5] ?? $iDelete;
|
||||
|
||||
$oCleanupSummaryEntity = new DataCleanupSummaryEntity($sClass);
|
||||
$oCleanupSummaryEntity->iUpdateCount = $iUpdate;
|
||||
$oCleanupSummaryEntity->iDeleteCount = $iDelete;
|
||||
$oCleanupSummaryEntity->iIssueCount = $iIssue;
|
||||
$oCleanupSummaryEntity->iTotalUpdateCount = $iTotalUpdate;
|
||||
$oCleanupSummaryEntity->iTotalDeleteCount = $iTotalDelete;
|
||||
|
||||
$aExpected[$sClass] = $oCleanupSummaryEntity;
|
||||
}
|
||||
$this->assertEquals($aExpected, $actual, $sMessage);
|
||||
@@ -270,18 +328,18 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
private array $aIdByObjectName = [];
|
||||
private function GivenDFRTreeLineInDB(string $sLine)
|
||||
{
|
||||
list($sLeft, $sRight) = explode('<-', $sLine);
|
||||
[$sLeft, $sRight] = explode('<-', $sLine);
|
||||
$sLeft = trim($sLeft);
|
||||
|
||||
$iLeftId = $this->aIdByObjectName[$sLeft] ?? 0;
|
||||
if ($iLeftId === 0) {
|
||||
list($sChildClass, ) = explode('_', $sLeft, 2);
|
||||
[$sChildClass, ] = explode('_', $sLeft, 2);
|
||||
$iLeftId = $this->GivenObjectInDB($sChildClass, ['name' => $sLeft]);
|
||||
$this->aIdByObjectName[$sLeft] = $iLeftId;
|
||||
}
|
||||
|
||||
$sRight = trim($sRight);
|
||||
list($sChildClass, ) = explode('_', $sRight, 2);
|
||||
[$sChildClass, ] = explode('_', $sRight, 2);
|
||||
$iRightId = $this->GivenObjectInDB($sChildClass, ['name' => $sRight, 'extkey_id' => $iLeftId]);
|
||||
$this->aIdByObjectName[$sRight] = $iRightId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
use Combodo\iTop\Application\WebPage\NiceWebPage;
|
||||
|
||||
require_once(dirname(__DIR__, 6).'/approot.inc.php');
|
||||
require_once(APPROOT.'application/startup.inc.php');
|
||||
require_once(APPROOT.'setup/setuputils.class.inc.php');
|
||||
|
||||
$aParams = [
|
||||
"exec_module" => "combodo-data-feature-removal",
|
||||
"exec_page" => "index.php",
|
||||
'exec_env' => 'production',
|
||||
];
|
||||
|
||||
new ContextTag(ContextTag::TAG_SETUP);
|
||||
$sToken = SetupUtils::CreateSetupToken();
|
||||
|
||||
$aSelectedModules = [
|
||||
'authent-cas',
|
||||
'authent-external',
|
||||
'authent-ldap',
|
||||
'authent-local',
|
||||
'combodo-backoffice-darkmoon-theme',
|
||||
'combodo-backoffice-fullmoon-high-contrast-theme',
|
||||
'combodo-backoffice-fullmoon-protanopia-deuteranopia-theme',
|
||||
'combodo-backoffice-fullmoon-tritanopia-theme',
|
||||
'combodo-data-feature-removal',
|
||||
'itop-backup',
|
||||
'itop-config',
|
||||
'itop-files-information',
|
||||
'itop-portal-base',
|
||||
'itop-profiles-itil',
|
||||
'itop-sla-computation',
|
||||
'itop-structure',
|
||||
'itop-welcome-itil',
|
||||
'itop-config-mgmt',
|
||||
'itop-attachments',
|
||||
'itop-tickets',
|
||||
'combodo-db-tools',
|
||||
'itop-core-update',
|
||||
'itop-hub-connector',
|
||||
'itop-oauth-client',
|
||||
'itop-themes-compat',
|
||||
'combodo-my-account',
|
||||
'combodo-my-account-user-info',
|
||||
'combodo-oauth2-client',
|
||||
'itop-attribute-class-set',
|
||||
'itop-attribute-encrypted-password',
|
||||
'itop-ui-copypaste',
|
||||
'itop-datacenter-mgmt',
|
||||
'itop-endusers-devices',
|
||||
'itop-storage-mgmt',
|
||||
'itop-virtualization-mgmt',
|
||||
'itop-bridge-cmdb-ticket',
|
||||
'itop-bridge-virtualization-storage',
|
||||
'itop-service-mgmt',
|
||||
'itop-bridge-cmdb-services',
|
||||
'itop-bridge-datacenter-mgmt-services',
|
||||
'itop-bridge-endusers-devices-services',
|
||||
'itop-bridge-storage-mgmt-services',
|
||||
'itop-bridge-virtualization-mgmt-services',
|
||||
'itop-request-mgmt',
|
||||
'itop-portal',
|
||||
'itop-change-mgmt',
|
||||
'itop-faq-light',
|
||||
'itop-knownerror-mgmt',
|
||||
'itop-problem-mgmt',
|
||||
'itop-system-information',
|
||||
'itop-log-mgmt',
|
||||
];
|
||||
|
||||
$aSelectedExtensions = [
|
||||
'itop-config-mgmt-core',
|
||||
'itop-config-mgmt-datacenter',
|
||||
'itop-config-mgmt-end-user',
|
||||
'itop-config-mgmt-storage',
|
||||
'itop-config-mgmt-virtualization',
|
||||
'itop-service-mgmt-enterprise',
|
||||
'itop-ticket-mgmt-simple-ticket',
|
||||
'itop-ticket-mgmt-simple-ticket-enhanced-portal',
|
||||
'itop-change-mgmt-simple',
|
||||
'itop-kown-error-mgmt',
|
||||
'itop-problem-mgmt',
|
||||
'itop-system-information',
|
||||
'itop-log-mgmt',
|
||||
];
|
||||
|
||||
$aRemovedExtensions = ['itop-container-mgmt' => 'Containerization'];
|
||||
|
||||
$aPostParams = [
|
||||
"auth_user" => 'admin',
|
||||
"auth_pwd" => 'admin',
|
||||
'login_mode' => 'form',
|
||||
'operation' => 'AnalysisResult',
|
||||
'setup_token' => $sToken,
|
||||
'selected_modules' => utils::HtmlEntities(json_encode($aSelectedModules)),
|
||||
'selected_extensions' => utils::HtmlEntities(json_encode($aSelectedExtensions)),
|
||||
'removed_extensions' => utils::HtmlEntities(json_encode($aRemovedExtensions)),
|
||||
];
|
||||
|
||||
$sHiddenPostedInput = "";
|
||||
foreach ($aPostParams as $sKey => $sVal) {
|
||||
$sHiddenPostedInput .= <<<INPUT
|
||||
<input type="hidden" name="$sKey" value="$sVal">
|
||||
INPUT;
|
||||
}
|
||||
|
||||
$sRedirectURL = utils::GetAbsoluteUrlModulePage('combodo-data-feature-removal', 'index.php');
|
||||
|
||||
$sDiv = <<<DIV
|
||||
<div id="_test" style="display: none;">
|
||||
<form id="_form" action="$sRedirectURL" method="post">
|
||||
$sHiddenPostedInput
|
||||
</form>
|
||||
</div>
|
||||
DIV;
|
||||
|
||||
$sReadyJs = <<<JS
|
||||
$("#_form").trigger("submit");
|
||||
JS;
|
||||
|
||||
$oP = new NiceWebPage("Simulate Audit From Setup");
|
||||
$oP->add($sDiv);
|
||||
$oP->add_ready_script($sReadyJs);
|
||||
$oP->output();
|
||||
Reference in New Issue
Block a user