Skip to content

Commit

Permalink
Test redirections also work
Browse files Browse the repository at this point in the history
  • Loading branch information
estringana committed Jan 7, 2025
1 parent 60b486e commit 7c8f668
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions appsec/tests/extension/push_params_redirect_02.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--TEST--
Push address gets blocked
--INI--
extension=ddtrace.so
datadog.appsec.enabled=1
--FILE--
<?php
use function datadog\appsec\testing\{rinit,rshutdown};
use function datadog\appsec\push_address;

include __DIR__ . '/inc/mock_helper.php';

$helper = Helper::createInitedRun([
response_list(response_request_init([[['ok', []]]])),
response_list(response_request_exec([[['redirect', ['status_code' => '303', 'location' => 'https://datadoghq.com']]], []])),
]);
rinit();

class SomeIntegration {
public function init()
{
DDTrace\install_hook("ltrim", self::hooked_function(), null);
}

private static function hooked_function()
{
return static function (DDTrace\HookData $hook) {
push_address("server.request.path_params", ["some" => "params", "more" => "parameters"]);
var_dump("This should be executed");
};
}
}

$integration = new SomeIntegration();
$integration->init();
var_dump(ltrim(" Calling wrapped function"));
var_dump("THIS SHOULD NOT GET IN THE OUTPUT");
?>
--EXPECTHEADERS--
Status: 303 See Other
Content-type: text/html; charset=UTF-8
--EXPECTF--

0 comments on commit 7c8f668

Please sign in to comment.