1import ./make-test.nix ({ pkgs, ...} :
2
3let
4
5 # Build some packages with coverage instrumentation.
6 overrides = pkgs:
7 with pkgs.stdenvAdapters;
8 let
9 do = pkg: pkg.override (args: {
10 stdenv = addCoverageInstrumentation args.stdenv;
11 });
12 in
13 rec {
14 apr = do pkgs.apr;
15 aprutil = do pkgs.aprutil;
16 apacheHttpd = do pkgs.apacheHttpd;
17 mod_python = do pkgs.mod_python;
18 subversion = do pkgs.subversion;
19
20 # To build the kernel with coverage instrumentation, we need a
21 # special patch to make coverage data available under /proc.
22 linux = pkgs.linux.override (orig: {
23 stdenv = overrideInStdenv pkgs.stdenv [ pkgs.keepBuildTree ];
24 extraConfig =
25 ''
26 GCOV_KERNEL y
27 GCOV_PROFILE_ALL y
28 '';
29 });
30 };
31
32in
33
34{
35 name = "subversion";
36 meta = with pkgs.stdenv.lib.maintainers; {
37 maintainers = [ eelco chaoflow ];
38 };
39
40 nodes =
41 { webserver =
42 { config, pkgs, ... }:
43
44 {
45 services.httpd.enable = true;
46 services.httpd.adminAddr = "e.dolstra@tudelft.nl";
47 services.httpd.extraSubservices =
48 [ { function = import <services/subversion>;
49 urlPrefix = "";
50 dataDir = "/data/subversion";
51 userCreationDomain = "192.168.0.0/16";
52 }
53 ];
54 nixpkgs.config.packageOverrides = overrides;
55 };
56
57 client =
58 { config, pkgs, ... }:
59
60 {
61 environment.systemPackages = [ pkgs.subversion ];
62 nixpkgs.config.packageOverrides = overrides;
63 };
64
65 };
66
67 testScript =
68 ''
69 startAll;
70
71 $webserver->waitForOpenPort(80);
72
73 print STDERR $client->succeed("svn --version");
74
75 print STDERR $client->succeed("curl --fail http://webserver/");
76
77 # Create a new user through the web interface.
78 $client->succeed("curl --fail -F username=alice -F fullname='Alice Lastname' -F address=alice\@example.org -F password=foobar -F password_again=foobar http://webserver/repoman/adduser");
79
80 # Let Alice create a new repository.
81 $client->succeed("curl --fail -u alice:foobar --form repo=xyzzy --form description=Xyzzy http://webserver/repoman/create");
82
83 $client->succeed("curl --fail http://webserver/") =~ /alice/ or die;
84
85 # Let Alice do a checkout.
86 my $svnFlags = "--non-interactive --username alice --password foobar";
87 $client->succeed("svn co $svnFlags http://webserver/repos/xyzzy wc");
88 $client->succeed("echo hello > wc/world");
89 $client->succeed("svn add wc/world");
90 $client->succeed("svn ci $svnFlags -m 'Added world.' wc/world");
91
92 # Create a new user on the server through the create-user.pl script.
93 $webserver->execute("svn-server-create-user.pl bob bob\@example.org Bob");
94 $webserver->succeed("svn-server-resetpw.pl bob fnord");
95 $client->succeed("curl --fail http://webserver/") =~ /bob/ or die;
96
97 # Bob should not have access to the repo.
98 my $svnFlagsBob = "--non-interactive --username bob --password fnord";
99 $client->fail("svn co $svnFlagsBob http://webserver/repos/xyzzy wc2");
100
101 # Bob should not be able change the ACLs of the repo.
102 # !!! Repoman should really return a 403 here.
103 $client->succeed("curl --fail -u bob:fnord -F description=Xyzzy -F readers=alice,bob -F writers=alice -F watchers= -F tardirs= http://webserver/repoman/update/xyzzy")
104 =~ /not authorised/ or die;
105
106 # Give Bob access.
107 $client->succeed("curl --fail -u alice:foobar -F description=Xyzzy -F readers=alice,bob -F writers=alice -F watchers= -F tardirs= http://webserver/repoman/update/xyzzy");
108
109 # So now his checkout should succeed.
110 $client->succeed("svn co $svnFlagsBob http://webserver/repos/xyzzy wc2");
111
112 # Test ViewVC and WebSVN
113 $client->succeed("curl --fail -u alice:foobar http://webserver/viewvc/xyzzy");
114 $client->succeed("curl --fail -u alice:foobar http://webserver/websvn/xyzzy");
115 $client->succeed("curl --fail -u alice:foobar http://webserver/repos-xml/xyzzy");
116
117 # Stop Apache to gather all the coverage data.
118 $webserver->stopJob("httpd");
119 '';
120
121})