This seems to work fine in a nix build
-sandbox as it doesn't depend on
getprotobyname
.
ZQLF4QLVKPCYHPJYAHKGCDTJ4CTE3UR5FLMIJ5LA76JIIFEVQAEAC
J52POHVCHGVLNGFBSKIR24UORLU3XNRQPZXLPDH533DZCQ72AHTQC
T3HCJYPLFFHHCBYWWIMKRF5HHDTVVPCQ24XINGILY3HVDYCVDV5AC
2G37UFZFPDTQOZGD2PFIL3D4FT53G4FJNSD43Y6MSZPBABLFD3IQC
RWNXH3H26EQHKJNMP4DUJCJKUYQBMV347234ZLE26SIFTVLSUWXQC
IH26BRUJQD2PPZJHYRDGSGETB4FS26UMXD63ACSRD4GW3V7EITCAC
KPWMZFHZXW5CEWXXTB4JDAJLOX42UNGKFULA3FAGQJAPSTSTFNKAC
LYO7KK3JD3PBYBWSLAO6UKEPVCBUGZ2PWDBPDCY3W7TH3HFOL7TAC
2JJP76737U2JWJWQ6UDFEAQCGWRAQH46HC6OCIKWMB5QYRXF6DQQC
};
};
HTTPParser = final.perlPackages.buildPerlPackage {
pname = "HTTP-Parser";
version = "0.06";
src = final.fetchurl {
url = "mirror://cpan/authors/id/E/ED/EDECA/HTTP-Parser-0.06.tar.gz";
sha256 = "sha256-+MWh4cvY8ndb09HOX6zIQx8FkQi/V1oMjb2kMuXAvEU=";
};
buildInputs = with final.perlPackages; [ TestMore URI HTTPMessage ];
meta = {
homepage = https://metacpan.org/pod/HTTP::Parser;
description = "HTTP::Parser - parse HTTP/1.1 request into HTTP::Request/Response object";
license = final.lib.licenses.artistic1;
};
};
TestHTTPMockServer = final.perlPackages.buildPerlModule {
pname = "Test-HTTP-MockServer";
version = "0.0.1";
src = final.fetchurl {
url = "mirror://cpan/authors/id/D/DR/DRUOSO/Test-HTTP-MockServer-v0.0.1.tar.gz";
sha256 = "sha256-cnVjaKGgOxA0IcJiuzk/a2nxQGbhKD3vpaLFWIqINDg=";
#!/usr/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer
from sys import argv
def factory(file):
h = handler
h.file = file
return h
class handler(BaseHTTPRequestHandler):
def do_POST(self):
self.send_response(200)
self.send_header('Content-type', 'application/json')
with open(self.file, 'w+') as f:
f.write(f"{self.path}\n")
length = int(self.headers.get('content-length', 0))
body = str(self.rfile.read(length).decode("utf-8"))
f.write(f"{body}")
self.end_headers()
message = "{}"
self.wfile.write(bytes(message, "utf8"))
if __name__ == '__main__':
try:
assert len(argv) > 1
with HTTPServer(('localhost', 8282), factory(argv[1])) as server:
server.serve_forever()
except KeyboardInterrupt:
pass
my $handle = sub {
my ($request, $response) = @_;
open(FH, ">", $filename) or die("Can't open(): $!\n");
print FH $request->uri . "\n";
print FH $request->content . "\n";
close(FH);
return $response;
};
$server->start_mock_server($handle);
my $newbuild = $db->resultset('Builds')->find($build->id);
is($newbuild->finished, 1, "Build should be finished.");
is($newbuild->buildstatus, 0, "Build should have buildstatus 0.");
ok(sendNotifications(), "Sent notifications");
my $pid;
if (!defined($pid = fork())) {
die "Cannot fork(): $!";
} elsif ($pid == 0) {
exec("python3 $ctx{jobsdir}/server.py $filename");
} else {
my $newbuild = $db->resultset('Builds')->find($build->id);
is($newbuild->finished, 1, "Build should be finished.");
is($newbuild->buildstatus, 0, "Build should have buildstatus 0.");
ok(sendNotifications(), "Sent notifications");