XNXX4WCQ7KIP24TIF6KQVZLCHM4R25MSSL4IFLFHNUBW5FQSTPWQC
5ZAU6N4YGFE6SOEZ4HDBBBYAUBZXLUY2YFHO5XUTT5Q7F3PXKDNAC
LZVO64YG43JD7YMZSCTZNOBS5ROZA4FMPKJW2YOMHX2V5PTGBVWQC
MMHOJIGD2SP24TV2TYGNLW7OUQ3ISSKRVCSWNDMXEKUXIJH247TAC
XWEWQOHVHXRAEZRIV7PZ4HKU5EEJ35SKDKHY5RPQDKSMMSIATLJQC
GLJD3PG2EYSB7EWYWEU57TYJQB6VDP2CJF6OLFEFIWZAY7OBXMMAC
SYLVCTT64DMSUBWROO5USFBSK2OCNB2NB72SSGM4MOEHMUQONEPQC
TZEDUWFXDA4O6ZVE7VC5TYSOPRVVSSSLUG3BERASO2KGHIWZZL3AC
4VYSDP4IAWIIVLXCKXJEYWIHZV3PUD3VACX3K4EIQKPFGWLZK6HQC
YI3BZG5NWMKBT7T2HEOHVHSZBQ5KPDWSI3VRYOMQ346LRFB4MR2AC
Q3VTDUSQ75JD5L55VWQV6MGAS6IC4AWGSADL2ISMX5E7R3LBVBHAC
5QYMALGUFECBH44BDVLFRZR5CQ24UTSEELVMAGDNKY2JAKBZKQ3AC
WQ2VQ7H3CTHM47EOW3F3BB2OUAI7ZXX5FBBAD2DODQOFO5LRM4WAC
4YCF3KBGI4VYKHJXAREJLCJLY3UWB2FX447CJ4XQWFRKRFKG5WCQC
MQYHIUEEIMJHLABLHRJTJSHITJMHRHMF7NACHRD7QRBJCA3GQPRQC
NP7IOJ4QI25BLULQEYBACUR4KXWMYLNTM2K5VNPX2FAFGHZ37WYAC
MIMHJSZKFRNIKCYWQQDITZFPY6L2P43BSBPFERK3633CFDQY7YDAC
my $result = request_json({ uri => "/login", method => "POST", data => { username => "root", password => "wrong" } });
is($result->code(), 403, "Incorrect password rejected.");
subtest "login" => sub {
subtest "bad password" => sub {
my $result = request_json({ uri => "/login", method => "POST", data => { username => "root", password => "wrong" } });
is($result->code(), 403, "Incorrect password rejected.");
};
my $result = request_json({ uri => "/login", method => "POST", data => { username => "root", password => "foobar" } });
my $result = request_json({ uri => "/login", method => "POST", data => { username => "root", password => "foobar" } });
is($user->{username}, "root", "The root user is named root");
is($user->{userroles}->[0], "admin", "The root user is an admin");
$cookie = $result->header("set-cookie");
is($user->{username}, "root", "The root user is named root");
is($user->{userroles}->[0], "admin", "The root user is an admin");
$cookie = $result->header("set-cookie");
$user = decode_json(request_json({ uri => "/current-user" })->content());
is($user->{username}, "root", "The current user is named root");
is($user->{userroles}->[0], "admin", "The current user is an admin");
$user = decode_json(request_json({ uri => "/current-user" })->content());
is($user->{username}, "root", "The current user is named root");
is($user->{userroles}->[0], "admin", "The current user is an admin");
};
$result = request_json({ uri => '/project/sample', method => 'PUT', data => { displayname => "Sample", enabled => "1", visible => "1", } });
is($result->code(), 201, "PUTting a new project creates it");
my $result = request_json({ uri => '/project/sample', method => 'PUT', data => { displayname => "Sample", enabled => "1", visible => "1", } });
is($result->code(), 201, "PUTting a new project creates it");
$result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", jobsetinputs => { "my-src" => { type => "path", value => $jobsetdir } }, enabled => "1", visible => "1", checkinterval => "3600"} });
is($result->code(), 201, "PUTting a new jobset creates it");
subtest "jobsets" => sub {
my $result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", jobsetinputs => { "my-src" => { type => "path", value => $jobsetdir } }, enabled => "1", visible => "1", checkinterval => "3600"} });
is($result->code(), 201, "PUTting a new jobset creates it");
ok(evalSucceeds($db->resultset('Jobsets')->find({ name => 'default' })), "Evaluating should exit with return code 0");
subtest "evaluation" => sub {
subtest "initial evaluaton" => sub {
ok(evalSucceeds($db->resultset('Jobsets')->find({ name => 'default' })), "Evaluating should exit with return code 0");
$result = request_json({ uri => '/jobset/sample/default/evals' });
is($result->code(), 200, "Can get evals of a jobset");
my $evals = decode_json($result->content())->{evals};
my $eval = $evals->[0];
is($eval->{hasnewbuilds}, 1, "The first eval of a jobset has new builds");
my $result = request_json({ uri => '/jobset/sample/default/evals' });
is($result->code(), 200, "Can get evals of a jobset");
my $evals = decode_json($result->content())->{evals};
my $eval = $evals->[0];
is($eval->{hasnewbuilds}, 1, "The first eval of a jobset has new builds");
};
open(my $fh, ">>", "${jobsetdir}/default.nix") or die "didn't open?";
say $fh "\n";
close $fh;
ok(evalSucceeds($db->resultset('Jobsets')->find({ name => 'default' })), "Evaluating should exit with return code 0");
subtest "second evaluation" => sub {
open(my $fh, ">>", "${jobsetdir}/default.nix") or die "didn't open?";
say $fh "\n";
close $fh;
ok(evalSucceeds($db->resultset('Jobsets')->find({ name => 'default' })), "Evaluating should exit with return code 0");
my $evals = decode_json(request_json({ uri => '/jobset/sample/default/evals' })->content())->{evals};
is(scalar(@$evals), 2, "Changing a jobset source creates the second evaluation");
isnt($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision}, $evals->[1]->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");
my $evals = decode_json(request_json({ uri => '/jobset/sample/default/evals' })->content())->{evals};
is(scalar(@$evals), 2, "Changing a jobset source creates the second evaluation");
isnt($evals->[0]->{jobsetevalinputs}->{"my-src"}->{revision}, $evals->[1]->{jobsetevalinputs}->{"my-src"}->{revision}, "Changing a jobset source changes its revision");
my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content());
is($build->{job}, "job", "The build's job name is job");
is($build->{finished}, 0, "The build isn't finished yet");
ok($build->{buildoutputs}->{out}->{path} =~ /\/nix\/store\/[a-zA-Z0-9]{32}-job$/, "The build's outpath is in the Nix store and named 'job'");
my $build = decode_json(request_json({ uri => "/build/" . $evals->[0]->{builds}->[0] })->content());
is($build->{job}, "job", "The build's job name is job");
is($build->{finished}, 0, "The build isn't finished yet");
ok($build->{buildoutputs}->{out}->{path} =~ /\/nix\/store\/[a-zA-Z0-9]{32}-job$/, "The build's outpath is in the Nix store and named 'job'");
my $search_project = decode_json(request_json({ uri => "/search/?query=sample" })->content());
is($search_project->{projects}[0]->{name}, "sample", "Search for project 'sample' works");
my $search_build = decode_json(request_json({ uri => "/search/?query=" . $build->{buildoutputs}->{out}->{path} })->content());
is($search_build->{builds}[0]->{buildoutputs}->{out}->{path}, $build->{buildoutputs}->{out}->{path}, "Search for builds work");
};
};
};
my $search_build = decode_json(request_json({ uri => "/search/?query=" . $build->{buildoutputs}->{out}->{path} })->content());
is($search_build->{builds}[0]->{buildoutputs}->{out}->{path}, $build->{buildoutputs}->{out}->{path}, "Search for builds work");