From 36c6c69d9039eb8cd2474e593cf3777b45bf617d Mon Sep 17 00:00:00 2001 From: johannes85 Date: Thu, 16 Mar 2017 10:39:24 +0000 Subject: [PATCH 1/2] Moved chain call to position outside of the error handling. --- src/main/php/scriptlet/AuthenticationFilter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/php/scriptlet/AuthenticationFilter.class.php b/src/main/php/scriptlet/AuthenticationFilter.class.php index cd286923..98338342 100755 --- a/src/main/php/scriptlet/AuthenticationFilter.class.php +++ b/src/main/php/scriptlet/AuthenticationFilter.class.php @@ -34,11 +34,11 @@ public function __construct(RequestAuthenticator $auth) { public function filter($request, $response, $invocation) { try { $r= $this->auth->authenticate($request, $response, null); - return false === $r ? $r : $invocation->proceed($request, $response); } catch (ScriptletException $e) { throw $e; } catch (Throwable $e) { throw new ScriptletException('Authentication failed: '.$e->getMessage(), HttpConstants::STATUS_FORBIDDEN, $e); } + return false === $r ? $r : $invocation->proceed($request, $response); } } From 0a6edf69a61f41d6fbc69967589ac905c5b93c35 Mon Sep 17 00:00:00 2001 From: johannes85 Date: Fri, 17 Mar 2017 11:22:20 +0000 Subject: [PATCH 2/2] Added regression testcase for error handling in AuthenticationFilter --- .../AuthenticationFilterTest.class.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/php/scriptlet/unittest/AuthenticationFilterTest.class.php diff --git a/src/test/php/scriptlet/unittest/AuthenticationFilterTest.class.php b/src/test/php/scriptlet/unittest/AuthenticationFilterTest.class.php new file mode 100644 index 00000000..822a44d4 --- /dev/null +++ b/src/test/php/scriptlet/unittest/AuthenticationFilterTest.class.php @@ -0,0 +1,33 @@ + function($request, $response, $context) { + return true; + } + ]); + $mockInvocation= new Invocation(function() { + throw new IllegalArgumentException('Test'); + }, [new AuthenticationFilter($mockAuthenticator)]); + $mockInvocation->proceed(null, null); + } + +} \ No newline at end of file