-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create eval-jobset role and guard /api/push route
- Loading branch information
Showing
9 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,25 @@ 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 => '[email protected]', password => '!' }); | ||
$user->setPassword('foobar'); | ||
$user->userroles->update_or_create({ role => 'admin' }); | ||
|
||
# Login and save cookie for future requests | ||
my $req = request(POST '/login', | ||
Referer => 'http://localhost/', | ||
Content => { | ||
username => 'alice', | ||
password => 'foobar' | ||
} | ||
); | ||
is($req->code, 302); | ||
my $cookie = $req->header("set-cookie"); | ||
|
||
my $finishedBuilds = $ctx->makeAndEvaluateJobset( | ||
expression => "one-job.nix", | ||
build => 1 | ||
|
@@ -109,7 +128,7 @@ 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"); | ||
my $response = request(POST "/api/push?jobsets=$projectName:$jobsetName&force=1", Cookie => $cookie); | ||
ok($response->is_success, "The API enpdoint for triggering jobsets returns 200."); | ||
|
||
my $data = is_json($response); | ||
|
@@ -128,7 +147,7 @@ subtest "/api/push" => sub { | |
|
||
print STDERR $repo; | ||
|
||
my $response = request(POST "/api/push?repos=$repo&force=1"); | ||
my $response = request(POST "/api/push?repos=$repo&force=1", Cookie => $cookie); | ||
ok($response->is_success, "The API enpdoint for triggering jobsets returns 200."); | ||
|
||
my $data = is_json($response); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters