From 1e7152bbda865a7579248368e21a800dcde17fa0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 21 Mar 2024 10:23:04 +0100 Subject: [PATCH] MigrateCommandTest: Add mysterious case --- .../clicommands/MigrateCommandTest.php | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/test/php/application/clicommands/MigrateCommandTest.php b/test/php/application/clicommands/MigrateCommandTest.php index 2f591acac..d9a56675b 100644 --- a/test/php/application/clicommands/MigrateCommandTest.php +++ b/test/php/application/clicommands/MigrateCommandTest.php @@ -306,7 +306,7 @@ class MigrateCommandTest extends TestCase 'filter' => 'host_name=%2Afoo%2A', 'owner' => 'test' ], - 'hosts_encoded_params' => [ + 'shared-hosts_encoded_params' => [ 'type' => 'host-action', 'url' => 'monitoring/list/hosts?host_name=%28foo%29&sort=_host_%28foo%29', 'filter' => '_host_%28foo%29=bar', @@ -326,7 +326,7 @@ class MigrateCommandTest extends TestCase 'filter' => 'host.name~%2Afoo%2A', 'owner' => 'test' ], - 'hosts_encoded_params' => [ + 'shared-hosts_encoded_params' => [ 'type' => 'icingadb-host-action', 'url' => 'icingadb/hosts?host.name=%28foo%29&sort=host.vars.%28foo%29', 'filter' => 'host.vars.%28foo%29=bar', @@ -960,6 +960,29 @@ public function testNavigationMigrationTransformsAlreadyExistingIcingaDBActions( $this->assertSame($services, $servicesAfterSecondRun); } + /** + * Checks the following: + * - Whether existing Icinga DB Actions are transformed regarding wildcard filters + */ + public function testTest() + { + [$legacyHostActions, $expectedMigrated] = $this->getConfig('host-actions'); + + $this->createConfig('navigation/host-actions.ini', $legacyHostActions); + $this->createConfig('preferences/test/icingadb-host-actions.ini', $expectedMigrated); + + $command = $this->createCommandInstance('--user', 'test'); + $command->navigationAction(); + + $legacyConfig = $this->loadConfig('navigation/host-actions.ini'); + $shouldBeEmpty = $this->loadConfig('navigation/icingadb-host-actions.ini'); + $expectedConfig = $this->loadConfig('preferences/test/icingadb-host-actions.ini'); + + $this->assertSame($legacyHostActions, $legacyConfig); + $this->assertSame($expectedMigrated, $expectedConfig); + $this->assertEmpty($shouldBeEmpty); + } + /** * Checks the following: * - Whether legacy host/service macros are migrated