Commit | Line | Data |
89de6a33 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
a38862e5 |
4 | use Test::More; |
5 | use FindBin qw/$Bin/; |
89de6a33 |
6 | |
a38862e5 |
7 | BEGIN { |
8 | $ENV{GITALIST_CONFIG} = $Bin; |
9 | use_ok 'Catalyst::Test', 'Gitalist' |
10 | } |
28e35997 |
11 | |
89de6a33 |
12 | ok( request('/')->is_success, 'Request should succeed' ); |
f2338f4f |
13 | |
10af354d |
14 | for my $p (qw/ repo1 nodescription /) { |
5fd1f586 |
15 | my $path = '/summary?p=' . $p; |
16 | ok( request($path)->is_success, "$path should succeed"); |
17 | } |
28e35997 |
18 | |
b4439022 |
19 | my $response = request('/summary?p=DoesNotExist'); |
20 | is $response->code, 404, 'invalid project 404s'; |
21 | like $response->content, qr/Page not found/, 'invalid project handled correctly'; |
22 | |
23 | is request('/summary?p=../../../')->code, 404, 'directory traversal failed'; |
24 | |
f9466a6c |
25 | { |
f2338f4f |
26 | # URI tests for repo1 |
f9466a6c |
27 | local *test = curry_test_uri('repo1'); |
28 | test('/summary'); |
29 | test('/shortlog'); |
30 | test('/log'); |
d8abdf1c |
31 | test('/reflog'); |
f9466a6c |
32 | test('/commit'); |
33 | test('/commitdiff', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); |
34 | test('/tree', 'h=145dc3ef5d307be84cb9b325d70bd08aeed0eceb;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); |
d8abdf1c |
35 | test('/search', 'h=36c6c6708b8360d7023e8a1649c45bcf9b3bd818&f=&type=commit&text=added'); |
6cfcd548 |
36 | test('/blobdiff', 'f=file1;h=5716ca5987cbf97d6bb54920bea6adde242d87e6;hp=257cc5642cb1a054f08cc83f2d943e56fd3ebe99;hb=refs/heads/master;hpb=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); |
8bb7649b |
37 | test('/blob', 'f=dir1/file2;hb=36c6c6708b8360d7023e8a1649c45bcf9b3bd818'); |
377bf360 |
38 | test('/patch'); |
39 | test('/patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e'); |
40 | test('/patch', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); |
61ba8635 |
41 | test('/patches'); |
42 | test('/patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e'); |
43 | test('/patches', 'h=3f7567c7bdf7e7ebf410926493b92d398333116e;hp=3bc0634310b9c62222bb0e724c11ffdfb297b4ac'); |
f9466a6c |
44 | } |
e8b87f6b |
45 | |
a38862e5 |
46 | done_testing; |
47 | |
f2338f4f |
48 | sub test_uri { |
49 | my ($p, $uri, $qs) = @_; |
50 | $qs ||= ''; |
51 | my $request = "$uri?p=repo1;$qs"; |
f2338f4f |
52 | my $response = request($request); |
6cfcd548 |
53 | ok($response->is_success, "ok $p - $uri - $qs"); |
f2338f4f |
54 | } |
55 | |
56 | sub curry_test_uri { |
57 | my $p = shift; |
58 | sub { |
46aab84d |
59 | my ($uri, $qs) = @_; |
60 | test_uri($p, $uri, $qs); |
f2338f4f |
61 | }; |
62 | }; |