First version of the security module

This commit is contained in:
2026-06-22 13:19:05 +02:00
parent 0392043ee3
commit 498afc7840
64 changed files with 7581 additions and 4 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace MintyPHP\Tests\Module\Security\Service;
use MintyPHP\Module\Security\Service\SecurityMarkdownGateway;
use PHPUnit\Framework\TestCase;
class SecurityMarkdownGatewayTest extends TestCase
{
public function testRendersBasicMarkdownToHtml(): void
{
$html = (new SecurityMarkdownGateway())->toHtml("**bold** text\n\n- one\n- two");
$this->assertStringContainsString('<strong>bold</strong>', $html);
$this->assertStringContainsString('<li>one</li>', $html);
$this->assertStringContainsString('<li>two</li>', $html);
}
public function testEscapesRawHtmlSoItCannotInjectMarkup(): void
{
$html = (new SecurityMarkdownGateway())->toHtml('<script>alert(1)</script>');
$this->assertStringNotContainsString('<script>', $html);
$this->assertStringContainsString('&lt;script&gt;', $html);
}
public function testEmptyOrWhitespaceInputReturnsEmptyString(): void
{
$gateway = new SecurityMarkdownGateway();
$this->assertSame('', $gateway->toHtml(''));
$this->assertSame('', $gateway->toHtml(" \n "));
}
}