Skip to content
Snippets Groups Projects
Commit 666434b8 authored by Lucas Hedding's avatar Lucas Hedding Committed by Lucas Hedding
Browse files

Issue #3046857 by heddn, eiriksm: Add entry to site status page when PSAs are posted

parent 3b477434
No related branches found
No related tags found
No related merge requests found
......@@ -4,3 +4,5 @@ description: 'Drupal Automatic Updates'
core: 8.x
package: 'Security'
configure: automatic_updates.admin_form
dependencies:
- drupal:update
<?php
/**
* @file
* Automatic updates install file.
*/
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
/**
* Requirements checks for automatic updates.
*/
function automatic_updates_requirements() {
$requirements = [];
if (!\Drupal::config('automatic_updates.settings')->get('enable_psa')) {
return $requirements;
}
/** @var \Drupal\automatic_updates\Services\AutomaticUpdatesPsa $psa */
$psa = \Drupal::service('automatic_updates.psa');
$messages = $psa->getPublicServiceMessages();
$requirements['automatic_updates_psa'] = [
'title' => t('Drupal public service announcements'),
'severity' => REQUIREMENT_OK,
'value' => t('No announcements requiring attention.'),
];
if (!empty($messages)) {
$requirements['automatic_updates_psa']['severity'] = REQUIREMENT_ERROR;
$requirements['automatic_updates_psa']['value'] = new PluralTranslatableMarkup(count($messages), '@count urgent announcement requiring your attention:', '@count urgent announcements requiring your attention:');
$requirements['automatic_updates_psa']['description'] = [
'#theme' => 'item_list',
'#items' => $messages,
];
}
return $requirements;
}
......@@ -20,6 +20,7 @@ class AutomaticUpdatesTest extends BrowserTestBase {
public static $modules = [
'automatic_updates',
'test_automatic_updates',
'update',
];
/**
......@@ -56,6 +57,10 @@ class AutomaticUpdatesTest extends BrowserTestBase {
$this->assertSession()->pageTextContains('Drupal Contrib Project PSA: Seven - Moderately critical - Access bypass - SA-CONTRIB-2019');
$this->assertSession()->pageTextContains('Drupal Contrib Project PSA: Standard - Moderately critical - Access bypass - SA-CONTRIB-2019');
// Test site status report.
$this->drupalGet(Url::fromRoute('system.status'));
$this->assertSession()->pageTextContains('4 announcements requiring your attention:');
// Test cache.
$end_point = 'http://localhost/automatic_updates/test-json-denied';
$this->config('automatic_updates.settings')
......@@ -78,6 +83,8 @@ class AutomaticUpdatesTest extends BrowserTestBase {
drupal_flush_all_caches();
$this->drupalGet(Url::fromRoute('system.admin'));
$this->assertSession()->pageTextNotContains('Drupal Core PSA: Critical Release - PSA-2019-02-19');
$this->drupalGet(Url::fromRoute('system.status'));
$this->assertSession()->pageTextNotContains('4 announcements requiring your attention:');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment