PR CI / ledger (pull_request) Successful in 3s
PR CI / flow (pull_request) Successful in 5s
PR CI / ui (pull_request) Successful in 18s
PR CI / test (lowest) (pull_request) Successful in 47s
PR CI / test (stable) (pull_request) Successful in 49s
PR CI / security (pull_request) Successful in 51s
PR CI / pr-ci (pull_request) Successful in 2s
PR CI / release-automerge (pull_request) Successful in 4s
26 lines
1.1 KiB
PHP
26 lines
1.1 KiB
PHP
<?php
|
|
|
|
use IriksIT\Manager\Models\AuditLog;
|
|
use IriksIT\Manager\Tests\AuditOnTestCase;
|
|
|
|
uses(AuditOnTestCase::class);
|
|
|
|
it('renders the preview the way the site does, with raw HTML escaped', function () {
|
|
$this->actingAs(makeUser(['posts.view']));
|
|
|
|
$html = $this->postJson('/manager/markdown', ['text' => "## Hi\n\n**bold** \n\n<script>alert(1)</script>"])->assertOk()->json('html');
|
|
|
|
expect($html)->toContain('<h2>Hi</h2>', '<strong>bold</strong>', '<img src="/media/a.jpg" alt="alt"')
|
|
->and($html)->not->toContain('<script>');
|
|
});
|
|
|
|
it('answers only to those who are logged in, and is not written in the audit log', function () {
|
|
$this->postJson('/manager/markdown', ['text' => 'x'])->assertUnauthorized();
|
|
|
|
$this->actingAs(makeUser(['posts.view']));
|
|
$this->postJson('/manager/markdown', ['text' => 'x'])->assertOk();
|
|
$this->postJson('/manager/markdown', ['text' => str_repeat('a', 200001)])->assertJsonValidationErrors(['text']);
|
|
|
|
expect(AuditLog::query()->where('action', 'markdown.preview')->count())->toBe(0);
|
|
});
|