... | ... |
@@ -9,6 +9,8 @@ |
9 | 9 |
my $git = app->git; |
10 | 10 |
my $sh = app->smart_http; |
11 | 11 |
|
12 |
+ warn $service; |
|
13 |
+ |
|
12 | 14 |
# Smart HTTP |
13 | 15 |
if ($service eq 'git-upload-pack' || $service eq 'git-receive-pack') { |
14 | 16 |
|
... | ... |
@@ -40,7 +42,7 @@ |
40 | 42 |
close $cout; |
41 | 43 |
close $cerr; |
42 | 44 |
waitpid($pid, 0); |
43 |
- |
|
45 |
+ |
|
44 | 46 |
if ($err) { |
45 | 47 |
app->log->error($err); |
46 | 48 |
$self->render_exception($err); |
... | ... |
@@ -15,8 +15,6 @@ |
15 | 15 |
my $rep_dir = $git->rep($user, $project); |
16 | 16 |
my @cmd = $git->cmd($user, $project, $service, '--stateless-rpc', $rep_dir); |
17 | 17 |
|
18 |
- warn 'a'; |
|
19 |
- |
|
20 | 18 |
# Command |
21 | 19 |
my ($cout, $cerr) = (Symbol::gensym, Symbol::gensym); |
22 | 20 |
my $pid = IPC::Open3::open3(my $cin, $cout, $cerr, @cmd); |
... | ... |
@@ -33,8 +31,6 @@ |
33 | 31 |
} |
34 | 32 |
close $cin; |
35 | 33 |
|
36 |
- warn 'b'; |
|
37 |
- |
|
38 | 34 |
# Response |
39 | 35 |
$self->res->headers->content_type("application/x-git-$service-result"); |
40 | 36 |
$self->render_later; |
... | ... |
@@ -45,7 +41,6 @@ |
45 | 41 |
my $buffer_size = $sh->buffer_size; |
46 | 42 |
my $cb; |
47 | 43 |
$cb = sub { |
48 |
- warn 'c'; |
|
49 | 44 |
my $c = shift; |
50 | 45 |
if (my @ready = $s->can_read) { |
51 | 46 |
my $error; |
... | ... |
@@ -9,6 +9,7 @@ use lib "$FindBin::Bin/../lib"; |
9 | 9 |
use lib "$FindBin::Bin/../extlib/lib/perl5"; |
10 | 10 |
use File::Path 'rmtree'; |
11 | 11 |
use Encode qw/encode decode/; |
12 |
+use MIME::Base64 'encode_base64'; |
|
12 | 13 |
|
13 | 14 |
use Test::Mojo; |
14 | 15 |
|
... | ... |
@@ -71,15 +72,56 @@ note 'Smart HTTP'; |
71 | 72 |
$t->content_type_is('application/x-git-loose-object'); |
72 | 73 |
|
73 | 74 |
# /info/pack |
74 |
- $t->get_ok("/kimoto/t1.git/objects/info/packs"); |
|
75 |
+ $t->get_ok('/kimoto/t1.git/objects/info/packs'); |
|
75 | 76 |
$t->status_is(200); |
76 | 77 |
$t->content_type_is('text/plain; charset=UTF-8'); |
77 | 78 |
|
78 | 79 |
# /HEAD |
79 |
- $t->get_ok("/kimoto/t1.git/HEAD"); |
|
80 |
+ $t->get_ok('/kimoto/t1.git/HEAD'); |
|
80 | 81 |
$t->status_is(200); |
81 | 82 |
$t->content_type_is('text/plain'); |
82 | 83 |
$t->content_like(qr#ref: refs/heads/master#); |
83 | 84 |
|
85 |
+ # /info/refs upload-pack request |
|
86 |
+ $t->get_ok('/kimoto/t1.git/info/refs?service=git-upload-pack'); |
|
87 |
+ $t->status_is(200); |
|
88 |
+ $t->header_is('Content-Type', 'application/x-git-upload-pack-advertisement'); |
|
89 |
+ $t->content_like(qr/^001e# service=git-upload-pack/); |
|
90 |
+ $t->content_like(qr/multi_ack_detailed/); |
|
91 |
+ |
|
92 |
+ # /git-upload-pack |
|
93 |
+ { |
|
94 |
+ my $content = <<EOS; |
|
95 |
+006fwant 6410316f2ed260666a8a6b9a223ad3c95d7abaed multi_ack_detailed no-done side-band-64k thin-pack ofs-delta |
|
96 |
+0032want 6410316f2ed260666a8a6b9a223ad3c95d7abaed |
|
97 |
+00000009done |
|
98 |
+EOS |
|
99 |
+ $t->post_ok( |
|
100 |
+ '/kimoto/t1.git/git-upload-pack', |
|
101 |
+ { |
|
102 |
+ 'Content-Type' => 'application/x-git-upload-pack-request', |
|
103 |
+ 'Content-Length' => 174, |
|
104 |
+ 'Content' => $content |
|
105 |
+ } |
|
106 |
+ ); |
|
107 |
+ $t->status_is(200); |
|
108 |
+ $t->content_type_is('application/x-git-upload-pack-result'); |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ # /info/refs recieve-pack request(Basic authentication) |
|
112 |
+ $t->get_ok('/kimoto/t1.git/info/refs?service=git-receive-pack'); |
|
113 |
+ $t->status_is(401); |
|
84 | 114 |
|
115 |
+ # /info/refs recieve-pack request |
|
116 |
+ $t->get_ok( |
|
117 |
+ '/kimoto/t1.git/info/refs?service=git-receive-pack', |
|
118 |
+ { |
|
119 |
+ Authorization => 'Basic ' . encode_base64('kimoto:a') |
|
120 |
+ } |
|
121 |
+ ); |
|
122 |
+ $t->header_is("Content-Type", "application/x-git-receive-pack-advertisement"); |
|
123 |
+ $t->content_like(qr/^001f# service=git-receive-pack/); |
|
124 |
+ $t->content_like(qr/report-status/); |
|
125 |
+ $t->content_like(qr/delete-refs/); |
|
126 |
+ $t->content_like(qr/ofs-delta/); |
|
85 | 127 |
} |