summary refs log tree commit diff
path: root/nixos/tests/subversion.nix
blob: 6175155cdfc9cc502cd967960d0a1a4ed7cd0807 (plain) (blame)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import ./make-test.nix ({ pkgs, ...} : 

let

  # Build some packages with coverage instrumentation.
  overrides = pkgs:
    with pkgs.stdenvAdapters;
    let
      do = pkg: pkg.override (args: {
        stdenv = addCoverageInstrumentation args.stdenv;
      });
    in
      rec {
        apr = do pkgs.apr;
        aprutil = do pkgs.aprutil;
        apacheHttpd = do pkgs.apacheHttpd;
        mod_python = do pkgs.mod_python;
        subversion = do pkgs.subversion;

        # To build the kernel with coverage instrumentation, we need a
        # special patch to make coverage data available under /proc.
        linux = pkgs.linux.override (orig: {
          stdenv = overrideInStdenv pkgs.stdenv [ pkgs.keepBuildTree ];
          extraConfig =
            ''
              GCOV_KERNEL y
              GCOV_PROFILE_ALL y
            '';
        });
      };

in

{
  name = "subversion";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ eelco chaoflow ];
  };

  nodes =
    { webserver =
        { ... }:

        {
          services.httpd.enable = true;
          services.httpd.adminAddr = "e.dolstra@tudelft.nl";
          services.httpd.extraSubservices =
            [ { function = import <services/subversion>;
                urlPrefix = "";
                dataDir = "/data/subversion";
                userCreationDomain = "192.168.0.0/16";
              }
            ];
          nixpkgs.config.packageOverrides = overrides;
        };

      client =
        { pkgs, ... }:

        {
          environment.systemPackages = [ pkgs.subversion ];
          nixpkgs.config.packageOverrides = overrides;
        };

    };

  testScript =
    ''
      startAll;

      $webserver->waitForOpenPort(80);

      print STDERR $client->succeed("svn --version");

      print STDERR $client->succeed("curl --fail http://webserver/");

      # Create a new user through the web interface.
      $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");

      # Let Alice create a new repository.
      $client->succeed("curl --fail -u alice:foobar --form repo=xyzzy --form description=Xyzzy http://webserver/repoman/create");

      $client->succeed("curl --fail http://webserver/") =~ /alice/ or die;

      # Let Alice do a checkout.
      my $svnFlags = "--non-interactive --username alice --password foobar";
      $client->succeed("svn co $svnFlags http://webserver/repos/xyzzy wc");
      $client->succeed("echo hello > wc/world");
      $client->succeed("svn add wc/world");
      $client->succeed("svn ci $svnFlags -m 'Added world.' wc/world");

      # Create a new user on the server through the create-user.pl script.
      $webserver->execute("svn-server-create-user.pl bob bob\@example.org Bob");
      $webserver->succeed("svn-server-resetpw.pl bob fnord");
      $client->succeed("curl --fail http://webserver/") =~ /bob/ or die;

      # Bob should not have access to the repo.
      my $svnFlagsBob = "--non-interactive --username bob --password fnord";
      $client->fail("svn co $svnFlagsBob http://webserver/repos/xyzzy wc2");

      # Bob should not be able change the ACLs of the repo.
      # !!! Repoman should really return a 403 here.
      $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")
          =~ /not authorised/ or die;

      # Give Bob access.
      $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");

      # So now his checkout should succeed.
      $client->succeed("svn co $svnFlagsBob http://webserver/repos/xyzzy wc2");

      # Test ViewVC and WebSVN
      $client->succeed("curl --fail -u alice:foobar http://webserver/viewvc/xyzzy");
      $client->succeed("curl --fail -u alice:foobar http://webserver/websvn/xyzzy");
      $client->succeed("curl --fail -u alice:foobar http://webserver/repos-xml/xyzzy");

      # Stop Apache to gather all the coverage data.
      $webserver->stopJob("httpd");
    '';

})