public function NagiosCheckTest::testStatuspage in Nagios Monitoring 8
File
- tests/
src/ Kernel/ NagiosCheckTest.php, line 64
Class
- NagiosCheckTest
- Tests the functionality to monitor cron.
Namespace
Drupal\Tests\nagios\KernelCode
public function testStatuspage() {
$statuspage_controller = new StatuspageController();
$_SERVER['HTTP_USER_AGENT'] = 'Test';
self::assertStringContainsString("nagios=UNKNOWN, DRUPAL:UNKNOWN=Unauthorized |", $statuspage_controller
->content()
->getContent());
$config = \Drupal::configFactory()
->getEditable('nagios.settings');
foreach ([
'cron',
'maintenance',
'watchdog',
] as $check) {
$config
->set('nagios.function.' . $check, FALSE);
}
$config
->save();
$_SERVER['HTTP_USER_AGENT'] = 'Nagios';
self::assertStringContainsString("nagios=OK,", $statuspage_controller
->content()
->getContent());
$config
->set('nagios.statuspage.getparam', TRUE);
$config
->save();
$_SERVER['HTTP_USER_AGENT'] = 'Test';
self::assertStringContainsString("nagios=UNKNOWN, DRUPAL:UNKNOWN=Unauthorized |", $statuspage_controller
->content()
->getContent());
$_GET['unique_id'] = 'Nagios';
self::assertStringContainsString("nagios=OK,", $statuspage_controller
->content()
->getContent());
self::assertInstanceOf(AccessResultNeutral::class, $statuspage_controller
->access());
self::assertFalse($statuspage_controller
->access()
->isAllowed());
$config
->set('nagios.statuspage.enabled', TRUE);
$config
->save();
self::assertTrue($statuspage_controller
->access()
->isAllowed());
}