From 559801c39bb1a39f1a47b5ba8834d5f16e9dcd57 Mon Sep 17 00:00:00 2001 From: Fritz Zaucker Date: Tue, 28 Feb 2023 15:39:53 +0100 Subject: [PATCH] Use latest JsonRpcController to hide exceptions from frontend/user (#213) * Use latest JsonRpcController to hide exceptions from frontend/user * Add Test::Fatal to requirements --- Makefile.PL | 3 ++- t/basic.t | 2 +- t/invalidPlugin.t | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 t/invalidPlugin.t diff --git a/Makefile.PL b/Makefile.PL index cab3f1c1..89da85b1 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,7 +13,7 @@ WriteMakefile( LICENSE => 'gpl_3', PREREQ_PM => { 'Mojolicious' => '9.12', - 'Mojolicious::Plugin::Qooxdoo' => '1.0.13', + 'Mojolicious::Plugin::Qooxdoo' => '1.0.14', 'Config::Grammar' => '1.13', 'XS::Parse::Keyword' => '0.21', 'Future::AsyncAwait' => '0.54', @@ -23,6 +23,7 @@ WriteMakefile( 'YAML::XS' => 0.83, 'Text::CSV' => 0, 'Excel::Writer::XLSX' => 0, + 'Test::Fatal' => 0, }, BUILD_REQUIRES => { 'CPAN::Uploader' => 0 diff --git a/t/basic.t b/t/basic.t index 1bd3daa5..7b067046 100644 --- a/t/basic.t +++ b/t/basic.t @@ -35,7 +35,7 @@ for (1..2){ } $ENV{CALLBACKERY_RPC_LOG}=0; -my $c = p1->new; +my $c = p1->new(app => $t->app); my $data = { k => { lalala => '123' } diff --git a/t/invalidPlugin.t b/t/invalidPlugin.t new file mode 100644 index 00000000..5a90a9b9 --- /dev/null +++ b/t/invalidPlugin.t @@ -0,0 +1,39 @@ +use FindBin; + +use lib $FindBin::Bin.'/../thirdparty/lib/perl5'; +use lib $FindBin::Bin.'/../lib'; + +use Mojo::Base -strict; + +use Test::More; +use Test::Mojo; + +$ENV{CALLBACKERY_CONF} = $FindBin::Bin.'/callbackery.cfg'; + +my $t = Test::Mojo->new('CallBackery'); + +$t->post_ok('/QX-JSON-RPC' => json => { + service => 'default', + method=> 'processPluginData', + id => 1, + params => [ + "undefinedPlugin", { + key => 'randomKey', + formData => { + } + }, + { qxLocale => 'de' } + ] +}) + ->status_is(200, 'processPluginData of undefinedPlugin returns 200') + ->json_is('' => { + id => 1, + error => { + origin => 2, + code => 9999, + message => "Couldn't process request", + } + }, 'Got correct error handling from JsonRPcController'); + +done_testing; +exit;