-
Notifications
You must be signed in to change notification settings - Fork 26
/
test.nix
51 lines (43 loc) · 1.63 KB
/
test.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{
name = "leaps";
machine.nixcloud.reverse-proxy.enable = true;
machine.nixcloud.reverse-proxy.extendEtcHosts = true;
machine.nixcloud.webservices.leaps = {
foo.enable = true;
foo.proxyOptions.domain = "example.com";
foo.proxyOptions.http.mode = "on";
foo.proxyOptions.https.mode = "off";
foo.proxyOptions.port = 8080;
bar.enable = true;
bar.proxyOptions.domain = "example.org";
bar.proxyOptions.http.mode = "on";
bar.proxyOptions.https.mode = "off";
bar.proxyOptions.port = 8081;
};
testScript = ''
# XXX: This is copied from tests/directories.nix, make it DRY!
sub ensureStat ($$$$) {
my ($path, $expect, $desc, $flag) = @_;
my $result = $machine->succeed('stat -c %'.$flag.' '.$path);
chomp $result;
die "$desc for path $path is $result but expected $expect"
unless $result eq $expect;
}
sub ensureOwner ($$) {
ensureStat $_[0], $_[1], 'owner', 'U';
}
sub ensureGroup ($$) {
ensureStat $_[0], $_[1], 'group', 'G';
}
$machine->waitForUnit('multi-user.target');
$machine->waitForOpenPort(80);
$machine->waitForOpenPort(8080);
$machine->waitForOpenPort(8081);
$machine->succeed('curl http://example.com/ | grep -qF leaps_logo.png');
$machine->succeed('curl http://example.org/ | grep -qF leaps_logo.png');
ensureOwner "/var/lib/nixcloud/webservices/leaps-foo/www", "leaps-foo";
ensureGroup "/var/lib/nixcloud/webservices/leaps-foo/www", "leaps-foo";
ensureOwner "/var/lib/nixcloud/webservices/leaps-bar/www", "leaps-bar";
ensureGroup "/var/lib/nixcloud/webservices/leaps-bar/www", "leaps-bar";
'';
}