Beispiel #1
0
 /**
  * @depends testLoggingToFile
  */
 public function testHTMLEncoding($logFileIsReadable)
 {
     $failMessage = null;
     if (ESAPI::getSecurityConfiguration()->getLogEncodingRequired() === false) {
         $failMessage = 'HTML encoding cannot be tested until the LogEncodingRequired' . ' property is set to true. This test has not actually failed.';
     } elseif ($logFileIsReadable === false) {
         $failMessage = 'HTML encoding could not be tested because we' . ' could not read the logfile.';
     }
     $testMsg = null;
     $r = getRandomAlphaNumString(16);
     $expected = $this->getExpected('FATAL', 'SECURITY', true, "{$r}&{$r}");
     $this->testLogger->fatal(Auditor::SECURITY, true, "{$r}&{$r}");
     $result = $this->verifyLogEntry($expected, $testMsg);
     $this->assertTrue($result, $failMessage);
 }
 /**
  * Test of addException method of class DefaultIntrusionDetector.
  *
  * @return bool True on Pass.
  */
 public function testAddException()
 {
     if ($this->_logFileLoc === false) {
         $this->fail('Cannot perform this test because the log file cannot be found.');
     }
     $logMsg = 'testAddException_';
     $logMsg .= getRandomAlphaNumString(32);
     ESAPI::getIntrusionDetector()->addException(new Exception($logMsg));
     $m = 'Test attempts to detect exception log message in logfile - %s';
     $this->assertTrue(fileContainsExpected($this->_logFileLoc, $logMsg), $m);
 }