-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
65 additions
and
7 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 |
---|---|---|
|
@@ -22,9 +22,24 @@ sub is_json { | |
} | ||
|
||
my $ctx = test_context(); | ||
|
||
Catalyst::Test->import('Hydra'); | ||
|
||
# Create a user to log in to | ||
my $user = $ctx->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, "The login redirects"); | ||
my $cookie = $req->header("set-cookie"); | ||
|
||
my $finishedBuilds = $ctx->makeAndEvaluateJobset( | ||
expression => "one-job.nix", | ||
build => 1 | ||
|
@@ -109,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"); | ||
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); | ||
|
@@ -128,7 +146,10 @@ 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, | ||
Referer => 'http://localhost/', | ||
); | ||
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