From ee64e91b29d4237c38f572ce91574e8e4b7b3218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janne=20He=C3=9F?= Date: Tue, 27 Aug 2024 19:45:28 +0200 Subject: [PATCH] fixup! Eval auth --- src/lib/Hydra/Helper/CatalystUtils.pm | 2 +- t/Hydra/Controller/API/checks.t | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 3e568ce39..6ccdbc4d5 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -193,7 +193,7 @@ sub hasEvalJobsetRole { } sub mayEvalJobset { - my ($c, $project) = $_; + my ($c, $project) = @_; return $c->user_exists && (isAdmin($c) || diff --git a/t/Hydra/Controller/API/checks.t b/t/Hydra/Controller/API/checks.t index 783bec797..a12d1b56c 100644 --- a/t/Hydra/Controller/API/checks.t +++ b/t/Hydra/Controller/API/checks.t @@ -22,14 +22,10 @@ sub is_json { } my $ctx = test_context(); - Catalyst::Test->import('Hydra'); -my $db = Hydra::Model::DB->new; -hydra_setup($db); - # Create a user to log in to -my $user = $db->resultset('Users')->create({ username => 'alice', emailaddress => 'alice@example.com', password => '!' }); +my $user = $ctx->db->resultset('Users')->create({ username => 'alice', emailaddress => 'alice@example.com', password => '!' }); $user->setPassword('foobar'); $user->userroles->update_or_create({ role => 'admin' }); @@ -128,7 +124,10 @@ subtest "/api/push" => sub { my $jobsetName = $jobset->name; is($jobset->forceeval, undef, "The existing jobset is not set to be forced to eval"); - my $response = request(POST "/api/push?jobsets=$projectName:$jobsetName&force=1", Cookie => $cookie); + my $response = request(POST "/api/push?jobsets=$projectName:$jobsetName&force=1", + Cookie => $cookie, + Referer => 'http://localhost/', + ); ok($response->is_success, "The API enpdoint for triggering jobsets returns 200."); my $data = is_json($response); @@ -147,7 +146,10 @@ subtest "/api/push" => sub { print STDERR $repo; - my $response = request(POST "/api/push?repos=$repo&force=1", Cookie => $cookie); + my $response = request(POST "/api/push?repos=$repo&force=1", + Cookie => $cookie, + Referer => 'http://localhost/', + ); ok($response->is_success, "The API enpdoint for triggering jobsets returns 200."); my $data = is_json($response);