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