api: Require POST for /api/push
This commit is contained in:
parent
b1a0501520
commit
916531dc9c
@ -70,7 +70,7 @@ paths:
|
|||||||
$ref: '#/components/examples/projects-success'
|
$ref: '#/components/examples/projects-success'
|
||||||
|
|
||||||
/api/push:
|
/api/push:
|
||||||
put:
|
post:
|
||||||
summary: trigger jobsets
|
summary: trigger jobsets
|
||||||
parameters:
|
parameters:
|
||||||
- in: query
|
- in: query
|
||||||
|
@ -239,6 +239,8 @@ sub triggerJobset {
|
|||||||
sub push : Chained('api') PathPart('push') Args(0) {
|
sub push : Chained('api') PathPart('push') Args(0) {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
requirePost($c);
|
||||||
|
|
||||||
$c->{stash}->{json}->{jobsetsTriggered} = [];
|
$c->{stash}->{json}->{jobsetsTriggered} = [];
|
||||||
|
|
||||||
my $force = exists $c->request->query_params->{force};
|
my $force = exists $c->request->query_params->{force};
|
||||||
|
@ -272,7 +272,7 @@ sub requireAdmin {
|
|||||||
|
|
||||||
sub requirePost {
|
sub requirePost {
|
||||||
my ($c) = @_;
|
my ($c) = @_;
|
||||||
error($c, "Request must be POSTed.") if $c->request->method ne "POST";
|
error($c, "Request must be POSTed.", 405) if $c->request->method ne "POST";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,6 +205,7 @@
|
|||||||
if (!c) return;
|
if (!c) return;
|
||||||
requestJSON({
|
requestJSON({
|
||||||
url: "[% HTML.escape(c.uri_for('/api/push', { jobsets = project.name _ ':' _ jobset.name, force = "1" })) %]",
|
url: "[% HTML.escape(c.uri_for('/api/push', { jobsets = project.name _ ':' _ jobset.name, force = "1" })) %]",
|
||||||
|
type: 'POST',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
bootbox.alert("The jobset has been scheduled for evaluation.");
|
bootbox.alert("The jobset has been scheduled for evaluation.");
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ subtest "/api/push" => sub {
|
|||||||
my $jobsetName = $jobset->name;
|
my $jobsetName = $jobset->name;
|
||||||
is($jobset->forceeval, undef, "The existing jobset is not set to be forced to eval");
|
is($jobset->forceeval, undef, "The existing jobset is not set to be forced to eval");
|
||||||
|
|
||||||
my $response = request(GET "/api/push?jobsets=$projectName:$jobsetName&force=1");
|
my $response = request(POST "/api/push?jobsets=$projectName:$jobsetName&force=1");
|
||||||
ok($response->is_success, "The API enpdoint for triggering jobsets returns 200.");
|
ok($response->is_success, "The API enpdoint for triggering jobsets returns 200.");
|
||||||
|
|
||||||
my $data = is_json($response);
|
my $data = is_json($response);
|
||||||
@ -128,7 +128,7 @@ subtest "/api/push" => sub {
|
|||||||
|
|
||||||
print STDERR $repo;
|
print STDERR $repo;
|
||||||
|
|
||||||
my $response = request(GET "/api/push?repos=$repo&force=1");
|
my $response = request(POST "/api/push?repos=$repo&force=1");
|
||||||
ok($response->is_success, "The API enpdoint for triggering jobsets returns 200.");
|
ok($response->is_success, "The API enpdoint for triggering jobsets returns 200.");
|
||||||
|
|
||||||
my $data = is_json($response);
|
my $data = is_json($response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user