Files
cacti/tests/Unit/Security/Auth/SamlCallbackValidationTest.php
Thomas Vincent ce6ab6e0b3 fix(auth): [develop] preserve SAML POST callback sessions (#8333)
* fix(auth): preserve SAML POST callback sessions

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(auth): filter SAML inputs before bootstrap

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-10-12 15:42:00 -07:00

20 lines
1008 B
PHP

<?php
test('SAML callback exemption preserves signature and request-ID validation', function (string $mode) {
$root = dirname(__DIR__, 4);
$process = proc_open([PHP_BINARY, $root . '/tests/fixtures/SamlCallbackProbe.php', $mode], [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
$output = stream_get_contents($pipes[1]);
$error = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
expect(proc_close($process))->toBe(0)->and($error)->toBe('');
$result = json_decode($output, true, 512, JSON_THROW_ON_ERROR);
$exempt = !in_array($mode, ['inactive', 'disabled', 'openid', 'other-page'], true);
expect($result['exempt'])->toBe($exempt)->and($result['csrf'])->toBe($exempt);
expect($result['login'])->toBe($mode === 'success')->and($result['replay'])->toBeFalse();
if ($mode === 'success') {
expect($result['username'])->toBe('alice@example.test');
}
})->with(['success', 'mismatch', 'missing', 'unsigned', 'tampered', 'inactive', 'disabled', 'openid', 'other-page']);