Fix API tests

POST requests require a referrer now.

http://hydra.nixos.org/build/42775011
This commit is contained in:
Eelco Dolstra 2016-10-27 13:15:09 +02:00
parent 3b84d4711b
commit cc866bff1e

View file

@ -11,6 +11,7 @@ sub request_json {
$req->method($opts->{method} or "GET"); $req->method($opts->{method} or "GET");
$req->uri("http://localhost:3000$opts->{uri}"); $req->uri("http://localhost:3000$opts->{uri}");
$req->header(Accept => "application/json"); $req->header(Accept => "application/json");
$req->header(Referer => "http://localhost:3000/") if $opts->{method} eq "POST";
$req->content(encode_json($opts->{data})) if defined $opts->{data}; $req->content(encode_json($opts->{data})) if defined $opts->{data};
my $res = $ua->request($req); my $res = $ua->request($req);
print $res->as_string(); print $res->as_string();