diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fb4812e..7db598dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,7 @@ * feature: Restyle the interfaces and dot1x status legends as rounded, evenly-spaced solid-colour chips with theme-appropriate colours * feature: Ship a dedicated per-theme stylesheet for every Cacti theme * feature: Show on the Process Status page what MacTrack is doing now (scan phase, maintenance step, upgrade rebuild or conversion), why the poller last skipped a run, how long each step of the last maintenance took, and the size of each MacTrack table +* issue: Show the Cancel and Continue buttons of the Utilities confirmation side by side, head each confirmation with the name of its action (such as Rebuild IEEE Vendor MAC/OUI Database) instead of Are You Sure?, and rename Configure Port Partitioning and the Port Partition Size setting to cover the IP address table too --- 4.8 --- diff --git a/README.md b/README.md index bc2c58ce..50dc069b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ partitions created ahead of collection. Nothing needs to be done. **Existing installs** keep their tables as they are until you rebuild them. Pick the size, then run the rebuild once: -1. Open **Console > Settings > Mactrack** and set **Port Partition Size**: +1. Open **Console > Settings > Mactrack** and set **Port and IP Address Partition Size**: *Weekly* (the default, fewest partitions), *Daily*, *Hourly* or *One per Scan* (maintained by the poller; the rebuild script cannot build these two), or *Disabled* for unpartitioned tables. It sets the size of the partitions @@ -81,7 +81,7 @@ the size, then run the rebuild once: maintenance, so with weekly partitions up to one extra week of history can stay. 3. Rebuild the existing history to match, either with **MacTrack Utilities > - Configure Port Partitioning** or from the Cacti installation directory: + Configure Port and IP Address Partitioning** or from the Cacti installation directory: ```sh php plugins/mactrack/cli/upgrade_partitioning.php @@ -97,11 +97,11 @@ Run it as the user that runs the Cacti poller, off hours (see below). `cli/upgrade_partitioning.php` checks both tables against the scheme and rebuilds only the ones that have drifted: -- Without `--partition` the scheme is the **Port Partition Size** setting. This +- Without `--partition` the scheme is the **Port and IP Address Partition Size** setting. This is the command to run after changing the setting, after an upgrade, or from time to time to make sure the tables are as they should be. - With `--partition=daily|weekly|disabled` that scheme is used and saved as the - **Port Partition Size** setting. + **Port and IP Address Partition Size** setting. - `--debug` prints every scan date copied. `--version` and `--help` print the version and the usage (`-v` and `-h` still work). diff --git a/cli/upgrade_partitioning.php b/cli/upgrade_partitioning.php index 1bc9d190..abc37e35 100644 --- a/cli/upgrade_partitioning.php +++ b/cli/upgrade_partitioning.php @@ -201,7 +201,7 @@ function display_help(): void { mactrack_upart_out('usage: upgrade_partitioning.php [--partition=daily|weekly|disabled] [--debug] [--version] [--help]'); mactrack_upart_out(''); mactrack_upart_out('Checks how the MAC address (mac_track_ports) and IP address (mac_track_ips)'); - mactrack_upart_out('tables are partitioned. Without --partition, the Port Partition Size setting'); + mactrack_upart_out('tables are partitioned. Without --partition, the Port and IP Address Partition Size setting'); mactrack_upart_out('is the scheme; a table that already follows it is left alone and reported.'); mactrack_upart_out('A table that has drifted from the scheme, or is not partitioned as asked, is'); mactrack_upart_out('rebuilt: renamed aside, created again with the retention and partitioning'); @@ -212,7 +212,7 @@ function display_help(): void { mactrack_upart_out('until it finishes, which can take hours on a large history. Run it off hours.'); mactrack_upart_out(''); mactrack_upart_out('--partition=SCHEME - Rebuild to daily, weekly or disabled (unpartitioned) and'); - mactrack_upart_out(' save it as the Port Partition Size setting'); + mactrack_upart_out(' save it as the Port and IP Address Partition Size setting'); mactrack_upart_out('--debug - Report every scan date copied'); mactrack_upart_out('--version - Display the version'); mactrack_upart_out('--help - Display this help message'); @@ -240,7 +240,7 @@ function mactrack_upart_signal(int $signo): void { // @codeCoverageIgnoreEnd /** - * Maps the Port Partition Size setting to a rebuild scheme. + * Maps the Port and IP Address Partition Size setting to a rebuild scheme. * * @return string|null day, week or disabled; null for the per-scan and hourly * sizes, which the poller maintains and this tool cannot build. @@ -298,7 +298,7 @@ function mactrack_upart_main(array $argv): int { $scheme = $options['scheme'] ?? mactrack_upart_setting_scheme(); if ($scheme === null) { - mactrack_upart_out('NOTE: The Port Partition Size setting is one per scan or hourly, which the poller maintains and this tool does not build. Nothing was changed; use --partition to choose daily, weekly or disabled.'); + mactrack_upart_out('NOTE: The Port and IP Address Partition Size setting is one per scan or hourly, which the poller maintains and this tool does not build. Nothing was changed; use --partition to choose daily, weekly or disabled.'); return 0; } @@ -334,7 +334,7 @@ function mactrack_upart_upgrade_active(): bool { * * @param string $scheme day, week or disabled. * @param bool $explicit True when --partition chose it, so it is saved as - * the Port Partition Size setting. + * the Port and IP Address Partition Size setting. * @param int $pause Seconds between DDL retries; tests pass 0. * * @return int Exit status. @@ -398,7 +398,7 @@ function mactrack_upart_run(string $scheme, bool $explicit, int $pause = 1): int } /** - * Saves the scheme as the Port Partition Size setting. + * Saves the scheme as the Port and IP Address Partition Size setting. * * @param string $scheme day, week or disabled. * @@ -406,7 +406,7 @@ function mactrack_upart_run(string $scheme, bool $explicit, int $pause = 1): int */ function mactrack_upart_save_setting(string $scheme): void { if (mactrack_upart_setting_scheme() !== $scheme) { - mactrack_upart_out('NOTE: Saving the Port Partition Size setting as ' . mactrack_upart_scheme_name($scheme) . '.'); + mactrack_upart_out('NOTE: Saving the Port and IP Address Partition Size setting as ' . mactrack_upart_scheme_name($scheme) . '.'); } set_config_option('mt_partition_granularity', $scheme); diff --git a/lib/mactrack_functions.php b/lib/mactrack_functions.php index 1ff37faa..e38afe32 100644 --- a/lib/mactrack_functions.php +++ b/lib/mactrack_functions.php @@ -6044,7 +6044,26 @@ function mactrack_utilities_post_actions(): array { 'mactrack_refresh_oui_database' => __('Are you sure you want to download and import the IEEE Vendor MAC/OUI database now?', 'mactrack'), 'mactrack_utilities_rebuild_scan_dates' => __('Are you sure you want to rebuild the scan date list from the stored Port to MAC to IP results now?', 'mactrack'), 'mactrack_utilities_optimize_ports' => __('Rebuild and analyze the partition containing the latest port observation, which is the current week with weekly partitions. An unpartitioned table is optimized in full. Scheduled scans are skipped while this runs. Continue?', 'mactrack'), - 'mactrack_utilities_convert_ports' => __('Run this maintenance off hours. The rebuild copies the full history of the port (MAC address) and IP address tables one after the other and can take hours. Scheduled scans are skipped, database maintenance waits, and MAC and IP address searching shows a maintenance message until it finishes. Allow free disk space for a second copy of each table and its indexes. Continue?', 'mactrack'), + 'mactrack_utilities_convert_partitions' => __('Run this maintenance off hours. The rebuild copies the full history of the port (MAC address) and IP address tables one after the other and can take hours. Scheduled scans are skipped, database maintenance waits, and MAC and IP address searching shows a maintenance message until it finishes. Allow free disk space for a second copy of each table and its indexes. Continue?', 'mactrack'), + ]; +} + +/** + * The heading of each Utilities action's confirmation form. + * + * @return array Action name => confirmation heading. + */ +function mactrack_utilities_post_titles(): array { + return [ + 'mactrack_utilities_truncate_ports_table' => __('Remove All Scan Results', 'mactrack'), + 'mactrack_utilities_perform_db_maint' => __('Perform Database Maintenance', 'mactrack'), + 'mactrack_utilities_purge_scanning_funcs' => __('Refresh Scanning Functions', 'mactrack'), + 'mactrack_utilities_purge_aggregated_data' => __('Remove All Aggregated Results', 'mactrack'), + 'mactrack_utilities_recreate_aggregated_data' => __('Perform Aggregate Table Rebuild', 'mactrack'), + 'mactrack_refresh_oui_database' => __('Rebuild IEEE Vendor MAC/OUI Database', 'mactrack'), + 'mactrack_utilities_rebuild_scan_dates' => __('Rebuild Scan Dates', 'mactrack'), + 'mactrack_utilities_optimize_ports' => __('Optimize Port Table', 'mactrack'), + 'mactrack_utilities_convert_partitions' => __('Configure Port and IP Address Partitioning', 'mactrack'), ]; } diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index e912f74a..ffdce1a7 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Cacti\n" "Report-Msgid-Bugs-To: developers@cacti.net\n" -"POT-Creation-Date: 2026-11-17 09:32-0500\n" +"POT-Creation-Date: 2026-11-17 11:55-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Cacti Developers \n" "Language-Team: Cacti Developers \n" @@ -477,6 +477,42 @@ msgstr "" msgid "Run this maintenance off hours. The rebuild copies the full history of the port (MAC address) and IP address tables one after the other and can take hours. Scheduled scans are skipped, database maintenance waits, and MAC and IP address searching shows a maintenance message until it finishes. Allow free disk space for a second copy of each table and its indexes. Continue?" msgstr "" +#: lib/mactrack_functions.php mactrack_utilities.php +msgid "Remove All Scan Results" +msgstr "" + +#: lib/mactrack_functions.php mactrack_utilities.php setup.php +msgid "Perform Database Maintenance" +msgstr "" + +#: lib/mactrack_functions.php mactrack_utilities.php setup.php +msgid "Refresh Scanning Functions" +msgstr "" + +#: lib/mactrack_functions.php mactrack_utilities.php +msgid "Remove All Aggregated Results" +msgstr "" + +#: lib/mactrack_functions.php mactrack_utilities.php +msgid "Perform Aggregate Table Rebuild" +msgstr "" + +#: lib/mactrack_functions.php +msgid "Rebuild IEEE Vendor MAC/OUI Database" +msgstr "" + +#: lib/mactrack_functions.php mactrack_utilities.php +msgid "Rebuild Scan Dates" +msgstr "" + +#: lib/mactrack_functions.php mactrack_utilities.php +msgid "Optimize Port Table" +msgstr "" + +#: lib/mactrack_functions.php mactrack_utilities.php +msgid "Configure Port and IP Address Partitioning" +msgstr "" + #: lib/mactrack_partition_rebuild.php msgid "The port and IP tables are being repartitioned, or a rebuild did not finish, so their history cannot be changed now. Try again when cli/upgrade_partitioning.php has finished." msgstr "" @@ -1662,7 +1698,7 @@ msgid "%s, coarser than the setting because %d partitions would exceed the limit msgstr "" #: mactrack_utilities.php setup.php -msgid "Port Partition Size" +msgid "Port and IP Address Partition Size" msgstr "" #: mactrack_utilities.php @@ -1737,10 +1773,6 @@ msgstr "" msgid "Mactrack scanning functions have been purged. They will be recreated once you either edit a device or device type." msgstr "" -#: mactrack_utilities.php -msgid "Are You Sure?" -msgstr "" - #: mactrack_utilities.php msgid "Cacti Mactrack System Utilities" msgstr "" @@ -1761,10 +1793,6 @@ msgstr "" msgid "Database Administration" msgstr "" -#: mactrack_utilities.php setup.php -msgid "Perform Database Maintenance" -msgstr "" - #: mactrack_utilities.php msgid "Deletes expired Port to MAC to IP associations from the database. Only records that have expired, based upon your criteria are removed." msgstr "" @@ -1777,26 +1805,14 @@ msgstr "" msgid "This function will download and install the latest OIU database from the IEEE Website. Each Network Interface Card (NIC) has a MAC Address. The MAC Address can be broken into two parts. The first part of the MAC Address contains the Vendor MAC. The Vendor MAC identifies who manufactured the part. This will be helpful in spot checking for rogue devices on your network." msgstr "" -#: mactrack_utilities.php setup.php -msgid "Refresh Scanning Functions" -msgstr "" - #: mactrack_utilities.php msgid "Deletes old and potentially stale Mactrack scanning functions from the drop-down you receive when you edit a device type." msgstr "" -#: mactrack_utilities.php -msgid "Remove All Scan Results" -msgstr "" - #: mactrack_utilities.php msgid "Deletes ALL Port to MAC to IP associations from the database all IP Addresses, IP Ranges, and VLANS. This utility is good when you want to start over. DANGER: All prior data is deleted." msgstr "" -#: mactrack_utilities.php -msgid "Rebuild Scan Dates" -msgstr "" - #: mactrack_utilities.php msgid "Rebuilds the list of scan dates from the stored Port to MAC to IP results, reading each partition once. Scans and maintenance keep the list current, so this is only needed after results were removed outside of maintenance, for example by deleting devices." msgstr "" @@ -1809,18 +1825,10 @@ msgstr "" msgid "Shows how the Port to MAC to IP results are partitioned, the partition size in use and why, and what the last database maintenance did." msgstr "" -#: mactrack_utilities.php -msgid "Optimize Port Table" -msgstr "" - #: mactrack_utilities.php msgid "Rebuilds and analyzes only the partition containing the latest port observation to reclaim deleted space; with weekly partitions that is the current week. Unpartitioned tables are optimized in full. Scheduled scans are skipped until it finishes." msgstr "" -#: mactrack_utilities.php -msgid "Configure Port Partitioning" -msgstr "" - #: mactrack_utilities.php msgid "Choose daily or weekly partitions, or disable partitioning, for the port (MAC address) and IP address tables. The rebuild copies the full history in the background; scheduled scans are skipped and MAC and IP address searching shows a maintenance message meanwhile." msgstr "" @@ -1829,18 +1837,10 @@ msgstr "" msgid "Aggregated Table Administration" msgstr "" -#: mactrack_utilities.php -msgid "Remove All Aggregated Results" -msgstr "" - #: mactrack_utilities.php msgid "Deletes ALL Aggregated (Not Scan Results) Port to MAC to IP associations from the database. Data will again be collected on the basis of only new scanned data in the next mactrack poller run." msgstr "" -#: mactrack_utilities.php -msgid "Perform Aggregate Table Rebuild" -msgstr "" - #: mactrack_utilities.php msgid "Deletes ALL Aggregated (Not Scan Results) Port to MAC to IP associations from the database and their re-creation based on All scanned data now." msgstr "" @@ -2629,7 +2629,7 @@ msgid "How long should discovered IPs details be retained in the database." msgstr "" #: setup.php -msgid "Size of the partitions of the port and IP tables, or Disabled for unpartitioned tables. Changing it affects new partitions only; to rebuild the existing history to match, use Configure Port Partitioning in MacTrack Utilities or run cli/upgrade_partitioning.php." +msgid "Size of the partitions of the port and IP tables, or Disabled for unpartitioned tables. Changing it affects new partitions only; to rebuild the existing history to match, use Configure Port and IP Address Partitioning in MacTrack Utilities or run cli/upgrade_partitioning.php." msgstr "" #: setup.php diff --git a/mactrack_utilities.php b/mactrack_utilities.php index 965a8e50..e51f7b14 100644 --- a/mactrack_utilities.php +++ b/mactrack_utilities.php @@ -108,8 +108,8 @@ mactrack_utilities_optimize_ports(); break; - case 'mactrack_utilities_convert_ports': - mactrack_utilities_convert_ports(); + case 'mactrack_utilities_convert_partitions': + mactrack_utilities_convert_partitions(); break; case 'mactrack_utilities_purge_scanning_funcs': @@ -784,7 +784,7 @@ function mactrack_utilities_partition_status(): void { $size = __('%s, coarser than the setting because %d partitions would exceed the limit', $size, $r['projected'], 'mactrack'); } - $row(__('Port Partition Size', 'mactrack'), $size); + $row(__('Port and IP Address Partition Size', 'mactrack'), $size); $row(__('Pending Exchange', 'mactrack'), $r['pending'] !== '' ? $r['pending'] : $none); $row(__('Load Path', 'mactrack'), __('PHP batches', 'mactrack')); $row(__('Last Scan Note', 'mactrack'), $r['last_scan_reason'] !== '' ? $r['last_scan_reason'] : $none); @@ -874,7 +874,7 @@ function mactrack_utilities_optimize_ports(): void { * @global array $config Cacti global configuration array; used to build * the script's path. */ -function mactrack_utilities_convert_ports(): void { +function mactrack_utilities_convert_partitions(): void { global $config; $scheme = get_request_var('partition_scheme'); @@ -932,14 +932,16 @@ function mactrack_utilities_purge_scanning_funcs(): void { * * @param string $action Action to post. * @param string $label Button label. + * @param bool $cancel Whether to put a Cancel link beside the button. * * @return string */ -function mactrack_utilities_post_form(string $action, string $label): string { +function mactrack_utilities_post_form(string $action, string $label, bool $cancel = false): string { + // The Cancel link sits inside the form so it and the submit button share a line. return '
' . '' - . ($action === 'mactrack_utilities_convert_ports' ? mactrack_utilities_conversion_fields() - . '' . html_escape(__('Cancel', 'mactrack')) . ' ' : '') + . ($action === 'mactrack_utilities_convert_partitions' ? mactrack_utilities_conversion_fields() : '') + . ($cancel ? '' . html_escape(__('Cancel', 'mactrack')) . ' ' : '') . '' . '
'; } @@ -955,7 +957,7 @@ function mactrack_utilities_post_form(string $action, string $label): string { * @return string */ function mactrack_utilities_action_link(string $action, string $label): string { - if ($action === 'mactrack_utilities_convert_ports' || read_config_option('mt_maint_confirm') == 'on') { + if ($action === 'mactrack_utilities_convert_partitions' || read_config_option('mt_maint_confirm') == 'on') { return "" . html_escape($label) . ''; } @@ -975,15 +977,12 @@ function mactrack_utilities_confirm(string $action): void { top_header(); - html_start_box(__('Are You Sure?', 'mactrack'), '60%', '', '3', 'center', ''); + html_start_box(mactrack_utilities_post_titles()[$action], '60%', '', '3', 'center', ''); print '' . html_escape($message) . ''; - if ($action === 'mactrack_utilities_convert_ports') { - print '' . mactrack_utilities_post_form($action, __('Continue', 'mactrack')) . ''; - } else { - print '' . html_escape(__('Cancel', 'mactrack')) . ' ' - . mactrack_utilities_post_form($action, __('Continue', 'mactrack')) . ''; - } + $class = $action === 'mactrack_utilities_convert_partitions' ? 'textArea' : 'right'; + + print '' . mactrack_utilities_post_form($action, __('Continue', 'mactrack'), true) . ''; html_end_box(); @@ -1084,7 +1083,7 @@ function mactrack_utilities(): void { - + @@ -1117,7 +1116,7 @@ function mactrack_utilities(): void { /** * Options shared with the rebuild CLI, submitted through Cacti's CSRF form. - * The CLI saves the choice as the Port Partition Size setting. + * The CLI saves the choice as the Port and IP Address Partition Size setting. * * @return string */ diff --git a/setup.php b/setup.php index c993db8f..19f0bb68 100644 --- a/setup.php +++ b/setup.php @@ -899,8 +899,8 @@ function mactrack_config_settings() { 'array' => $mactrack_data_retention, ], 'mt_partition_granularity' => [ - 'friendly_name' => __('Port Partition Size', 'mactrack'), - 'description' => __('Size of the partitions of the port and IP tables, or Disabled for unpartitioned tables. Changing it affects new partitions only; to rebuild the existing history to match, use Configure Port Partitioning in MacTrack Utilities or run cli/upgrade_partitioning.php.', 'mactrack'), + 'friendly_name' => __('Port and IP Address Partition Size', 'mactrack'), + 'description' => __('Size of the partitions of the port and IP tables, or Disabled for unpartitioned tables. Changing it affects new partitions only; to rebuild the existing history to match, use Configure Port and IP Address Partitioning in MacTrack Utilities or run cli/upgrade_partitioning.php.', 'mactrack'), 'method' => 'drop_array', 'default' => 'week', 'array' => [ diff --git a/tests/Unit/PartitionRebuildTest.php b/tests/Unit/PartitionRebuildTest.php index a539fba7..3bafa9cd 100644 --- a/tests/Unit/PartitionRebuildTest.php +++ b/tests/Unit/PartitionRebuildTest.php @@ -697,7 +697,7 @@ function mt_ur_full_run_exists(): void { [$rc, $out] = mt_ur_capture(fn () => mactrack_upart_run('disabled', true, 0)); expect($rc)->toBe(0); - expect($out)->toContain('Saving the Port Partition Size setting as disabled'); + expect($out)->toContain('Saving the Port and IP Address Partition Size setting as disabled'); expect($GLOBALS['__test_config_options']['mt_partition_granularity'])->toBe('disabled'); }); @@ -708,7 +708,7 @@ function mt_ur_full_run_exists(): void { [, $out] = mt_ur_capture(fn () => mactrack_upart_run('disabled', true, 0)); - expect($out)->not->toContain('Saving the Port Partition Size'); + expect($out)->not->toContain('Saving the Port and IP Address Partition Size'); expect($GLOBALS['__test_config_options']['mt_partition_granularity'])->toBe('disabled'); }); diff --git a/tests/Unit/PartitionWebTest.php b/tests/Unit/PartitionWebTest.php index 483136df..d20b69d2 100644 --- a/tests/Unit/PartitionWebTest.php +++ b/tests/Unit/PartitionWebTest.php @@ -20,7 +20,7 @@ mactrack_test_load(dirname(__DIR__, 2) . '/lib/mactrack_functions.php'); }); -foreach (['conversion_fields', 'post_form', 'action_link', 'convert_ports', 'confirm', 'rebuild_scan_dates', 'busy_message'] as $function) { +foreach (['conversion_fields', 'post_form', 'action_link', 'convert_partitions', 'confirm', 'rebuild_scan_dates', 'busy_message'] as $function) { mactrack_test_load_function('mactrack_utilities.php', 'mactrack_utilities_' . $function); } mactrack_test_load_function('mactrack_utilities.php', 'mactrack_utilities'); @@ -48,7 +48,7 @@ function form_alternate_row($id = '', $selected = false) { }); it('offers daily weekly and disabled in a POST form without a backup option', function () { - $html = mactrack_utilities_post_form('mactrack_utilities_convert_ports', 'Continue'); + $html = mactrack_utilities_post_form('mactrack_utilities_convert_partitions', 'Continue'); $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); @@ -65,18 +65,35 @@ function form_alternate_row($id = '', $selected = false) { expect(mactrack_utilities_post_form('mactrack_utilities_perform_db_maint', 'Continue'))->not->toContain('partition_scheme'); })->with([['day', 'daily'], ['week', 'weekly'], ['disabled', 'disabled'], ['hour', 'weekly']]); +it('puts Cancel and Continue in the one form so they sit side by side', function () { + ob_start(); + mactrack_utilities_confirm('mactrack_refresh_oui_database'); + $html = ob_get_clean(); + + $dom = new DOMDocument(); + $dom->loadHTML($html); + $xpath = new DOMXPath($dom); + + expect($xpath->query('//form//a[@href="mactrack_utilities.php"]'))->toHaveCount(1); + expect($xpath->query('//form//input[@type="submit"]'))->toHaveCount(1); +}); + +it('offers no Cancel link on the direct action button', function () { + expect(mactrack_utilities_post_form('mactrack_utilities_perform_db_maint', 'Run'))->not->toContain('Cancel'); +}); + it('always opens partition options even when routine confirmations are disabled', function () { $GLOBALS['__test_config_options']['mt_maint_confirm'] = ''; - $link = mactrack_utilities_action_link('mactrack_utilities_convert_ports', 'Configure'); + $link = mactrack_utilities_action_link('mactrack_utilities_convert_partitions', 'Configure'); - expect($link)->toContain('toContain('not->toContain(' $scheme]; ob_start(); - mactrack_utilities_convert_ports(); + mactrack_utilities_convert_partitions(); $html = ob_get_clean(); $launches = array_values(array_filter($GLOBALS['__test_db_calls'], fn ($c) => $c['fn'] === 'exec_background')); @@ -91,7 +108,7 @@ function form_alternate_row($id = '', $selected = false) { $GLOBALS['__test_request_vars'] = ['partition_scheme' => 'weekly']; mactrack_test_queue_return_for('db_fetch_row_prepared', 'FROM processes', ['pid' => (string) getmypid(), 'started' => '99000', 'now' => '100000', 'timeout' => '86400']); ob_start(); - mactrack_utilities_convert_ports(); + mactrack_utilities_convert_partitions(); $html = ob_get_clean(); expect(array_filter($GLOBALS['__test_db_calls'], fn ($c) => $c['fn'] === 'exec_background'))->toBe([]); @@ -102,7 +119,7 @@ function form_alternate_row($id = '', $selected = false) { $GLOBALS['__test_request_vars'] = ['partition_scheme' => 'weekly']; $GLOBALS['__test_config_options']['mt_partition_converting'] = (string) time(); ob_start(); - mactrack_utilities_convert_ports(); + mactrack_utilities_convert_partitions(); $html = ob_get_clean(); expect(array_filter($GLOBALS['__test_db_calls'], fn ($c) => $c['fn'] === 'exec_background'))->toHaveCount(1); @@ -113,7 +130,7 @@ function form_alternate_row($id = '', $selected = false) { it('rejects missing or unrecognized schemes without launching a process', function ($scheme) { $GLOBALS['__test_request_vars'] = ['partition_scheme' => $scheme]; ob_start(); - mactrack_utilities_convert_ports(); + mactrack_utilities_convert_partitions(); $html = ob_get_clean(); expect(array_filter($GLOBALS['__test_db_calls'], fn ($c) => $c['fn'] === 'exec_background'))->toBe([]); @@ -122,7 +139,7 @@ function form_alternate_row($id = '', $selected = false) { it('warns about the maintenance window and offers a cancel link before launching', function () { ob_start(); - mactrack_utilities_confirm('mactrack_utilities_convert_ports'); + mactrack_utilities_confirm('mactrack_utilities_convert_partitions'); $html = ob_get_clean(); expect($html)->toContain('off hours', 'disk space', 'Scheduled scans are skipped', 'maintenance message', 'href="mactrack_utilities.php"', 'name="partition_scheme"'); diff --git a/tests/Unit/UtilitiesRequirePostTest.php b/tests/Unit/UtilitiesRequirePostTest.php index 63566a66..d0f80286 100644 --- a/tests/Unit/UtilitiesRequirePostTest.php +++ b/tests/Unit/UtilitiesRequirePostTest.php @@ -31,7 +31,7 @@ 'mactrack_refresh_oui_database', 'mactrack_utilities_rebuild_scan_dates', 'mactrack_utilities_optimize_ports', - 'mactrack_utilities_convert_ports', + 'mactrack_utilities_convert_partitions', ]; it('lists every Utilities action that changes data', function () { @@ -44,6 +44,17 @@ } }); +it('gives each such action its own heading instead of a generic question', function () { + $titles = mactrack_utilities_post_titles(); + + expect(array_keys($titles))->toEqualCanonicalizing(MT_UP_ACTIONS); + expect($titles['mactrack_refresh_oui_database'])->toBe('Rebuild IEEE Vendor MAC/OUI Database'); + + foreach ($titles as $title) { + expect($title)->toBeString()->not->toBe('')->not->toBe('Are You Sure?'); + } +}); + it('runs a data-changing action only on a POST', function (string $method, bool $runs) { foreach (MT_UP_ACTIONS as $action) { expect(mactrack_utilities_may_run($action, $method))->toBe($runs);