gitlab-grack 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.gitmodules +3 -0
- data/.travis.yml +3 -2
- data/CHANGELOG +4 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +0 -4
- data/lib/grack/server.rb +5 -10
- data/lib/grack/version.rb +1 -1
- data/tests/main_test.rb +34 -34
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fc5bcb451c40e574630cae0bdc3558f12a02740
|
4
|
+
data.tar.gz: 00a192537b9aa1d4de99aedb9cb57df5337c6db6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec553c2ff9f16b50fec324fb84a17e7d135e257c546376f3251d338b7f4b1f77cebcc9e6687e2277e0aabd03c22ff520ce61b6a182d40e6f53e6f1b913220986
|
7
|
+
data.tar.gz: d58e809fb002214c54431cff78a50979e0d4e33eebdb61538f919e16fe745cc30d62d58519b4eaaebe9dd1584b25c1117a81c339514112676e8dc7565be388d0
|
data/.gitignore
CHANGED
data/.gitmodules
ADDED
data/.travis.yml
CHANGED
@@ -5,9 +5,10 @@ branches:
|
|
5
5
|
only:
|
6
6
|
- 'master'
|
7
7
|
rvm:
|
8
|
+
- 1.9.3-p327
|
8
9
|
- 2.0.0
|
9
10
|
before_script:
|
10
11
|
- "bundle install"
|
11
|
-
- "git
|
12
|
-
- "
|
12
|
+
- "git submodule init"
|
13
|
+
- "git submodule update"
|
13
14
|
script: "bundle exec rake"
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -5,13 +5,9 @@ task :default => :test
|
|
5
5
|
|
6
6
|
desc "Run the tests."
|
7
7
|
task :test do
|
8
|
-
system "git clone --bare git://github.com/schacon/simplegit.git tests/example.git"
|
9
|
-
# We could put this in a chdir block but we should keep it consistent with Travis
|
10
|
-
system "cd tests/example.git && git repack && cd ../.."
|
11
8
|
Dir.glob("tests/*_test.rb").each do |f|
|
12
9
|
system "ruby #{f}"
|
13
10
|
end
|
14
|
-
system "rm -rf tests/example.git"
|
15
11
|
end
|
16
12
|
|
17
13
|
desc "Run test coverage."
|
data/lib/grack/server.rb
CHANGED
@@ -82,8 +82,7 @@ module Grack
|
|
82
82
|
pipe.write(input)
|
83
83
|
pipe.close_write
|
84
84
|
|
85
|
-
while
|
86
|
-
block = pipe.read(8192) # 8KB at a time
|
85
|
+
while block = pipe.read(8192) # 8KB at a time
|
87
86
|
@res.write encode_chunk(block) # stream it to the client
|
88
87
|
end
|
89
88
|
|
@@ -103,14 +102,13 @@ module Grack
|
|
103
102
|
|
104
103
|
def get_info_refs
|
105
104
|
service_name = get_service_type
|
106
|
-
return dumb_info_refs unless
|
107
|
-
return render_no_access unless has_access?(service_name)
|
105
|
+
return dumb_info_refs unless has_access?(service_name)
|
108
106
|
|
109
107
|
refs = git.execute([service_name, '--stateless-rpc', '--advertise-refs', git.repo])
|
110
108
|
|
111
109
|
@res = Rack::Response.new
|
112
110
|
@res.status = 200
|
113
|
-
@res["Content-Type"] = "application/x-git
|
111
|
+
@res["Content-Type"] = "application/x-git-%s-advertisement" % service_name
|
114
112
|
hdr_nocache
|
115
113
|
|
116
114
|
@res.write(pkt_write("# service=git-#{service_name}\n"))
|
@@ -228,13 +226,10 @@ module Grack
|
|
228
226
|
nil
|
229
227
|
end
|
230
228
|
|
231
|
-
def smart_http?(rpc = @rpc)
|
232
|
-
@req.content_type == "application/x-git-#{rpc}-request"
|
233
|
-
end
|
234
|
-
|
235
229
|
def has_access?(rpc, check_content_type = false)
|
236
230
|
if check_content_type
|
237
|
-
|
231
|
+
conten_type = "application/x-git-%s-request" % rpc
|
232
|
+
return false unless @req.content_type == conten_type
|
238
233
|
end
|
239
234
|
|
240
235
|
return false unless ['upload-pack', 'receive-pack'].include?(rpc)
|
data/lib/grack/version.rb
CHANGED
data/tests/main_test.rb
CHANGED
@@ -25,7 +25,7 @@ class GitHttpTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_upload_pack_advertisement
|
28
|
-
get "/example
|
28
|
+
get "/example/info/refs?service=git-upload-pack"
|
29
29
|
assert_equal 200, r.status
|
30
30
|
assert_equal "application/x-git-upload-pack-advertisement", r.headers["Content-Type"]
|
31
31
|
assert_equal "001e# service=git-upload-pack", r.body.split("\n").first
|
@@ -33,22 +33,22 @@ class GitHttpTest < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_no_access_wrong_content_type_up
|
36
|
-
post "/example
|
36
|
+
post "/example/git-upload-pack"
|
37
37
|
assert_equal 403, r.status
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_no_access_wrong_content_type_rp
|
41
|
-
post "/example
|
41
|
+
post "/example/git-receive-pack"
|
42
42
|
assert_equal 403, r.status
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_no_access_wrong_method_rcp
|
46
|
-
get "/example
|
46
|
+
get "/example/git-upload-pack"
|
47
47
|
assert_equal 400, r.status
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_no_access_wrong_command_rcp
|
51
|
-
post "/example
|
51
|
+
post "/example/git-upload-packfile"
|
52
52
|
assert_equal 404, r.status
|
53
53
|
end
|
54
54
|
|
@@ -61,13 +61,13 @@ class GitHttpTest < Test::Unit::TestCase
|
|
61
61
|
def test_upload_pack_rpc
|
62
62
|
Grack::Git.any_instance.stubs(:valid_repo?).returns(true)
|
63
63
|
IO.stubs(:popen).returns(MockProcess.new)
|
64
|
-
post "/example
|
64
|
+
post "/example/git-upload-pack", {}, {"CONTENT_TYPE" => "application/x-git-upload-pack-request"}
|
65
65
|
assert_equal 200, r.status
|
66
66
|
assert_equal "application/x-git-upload-pack-result", r.headers["Content-Type"]
|
67
67
|
end
|
68
68
|
|
69
69
|
def test_receive_pack_advertisement
|
70
|
-
get "/example
|
70
|
+
get "/example/info/refs?service=git-receive-pack"
|
71
71
|
assert_equal 200, r.status
|
72
72
|
assert_equal "application/x-git-receive-pack-advertisement", r.headers["Content-Type"]
|
73
73
|
assert_equal "001f# service=git-receive-pack", r.body.split("\n").first
|
@@ -79,25 +79,25 @@ class GitHttpTest < Test::Unit::TestCase
|
|
79
79
|
def test_recieve_pack_rpc
|
80
80
|
Grack::Git.any_instance.stubs(:valid_repo?).returns(true)
|
81
81
|
IO.stubs(:popen).yields(MockProcess.new)
|
82
|
-
post "/example
|
82
|
+
post "/example/git-receive-pack", {}, {"CONTENT_TYPE" => "application/x-git-receive-pack-request"}
|
83
83
|
assert_equal 200, r.status
|
84
84
|
assert_equal "application/x-git-receive-pack-result", r.headers["Content-Type"]
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_info_refs_dumb
|
88
|
-
get "/example
|
88
|
+
get "/example/.git/info/refs"
|
89
89
|
assert_equal 200, r.status
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_info_packs
|
93
|
-
get "/example
|
93
|
+
get "/example/.git/objects/info/packs"
|
94
94
|
assert_equal 200, r.status
|
95
95
|
assert_match /P pack-(.*?).pack/, r.body
|
96
96
|
end
|
97
97
|
|
98
98
|
def test_loose_objects
|
99
99
|
path, content = write_test_objects
|
100
|
-
get "/example
|
100
|
+
get "/example/.git/objects/#{path}"
|
101
101
|
assert_equal 200, r.status
|
102
102
|
assert_equal content, r.body
|
103
103
|
remove_test_objects
|
@@ -105,7 +105,7 @@ class GitHttpTest < Test::Unit::TestCase
|
|
105
105
|
|
106
106
|
def test_pack_file
|
107
107
|
path, content = write_test_objects
|
108
|
-
get "/example
|
108
|
+
get "/example/.git/objects/pack/pack-#{content}.pack"
|
109
109
|
assert_equal 200, r.status
|
110
110
|
assert_equal content, r.body
|
111
111
|
remove_test_objects
|
@@ -113,44 +113,44 @@ class GitHttpTest < Test::Unit::TestCase
|
|
113
113
|
|
114
114
|
def test_index_file
|
115
115
|
path, content = write_test_objects
|
116
|
-
get "/example
|
116
|
+
get "/example/.git/objects/pack/pack-#{content}.idx"
|
117
117
|
assert_equal 200, r.status
|
118
118
|
assert_equal content, r.body
|
119
119
|
remove_test_objects
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_text_file
|
123
|
-
get "/example
|
123
|
+
get "/example/.git/HEAD"
|
124
124
|
assert_equal 200, r.status
|
125
|
-
assert_equal
|
125
|
+
assert_equal 41, r.body.size # submodules have detached head
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_no_size_avail
|
129
129
|
File.stubs('size?').returns(false)
|
130
|
-
get "/example
|
130
|
+
get "/example/.git/HEAD"
|
131
131
|
assert_equal 200, r.status
|
132
|
-
assert_equal
|
132
|
+
assert_equal 46, r.body.size # submodules have detached head
|
133
133
|
end
|
134
134
|
|
135
135
|
def test_config_upload_pack_off
|
136
136
|
a1 = app
|
137
137
|
a1.set_config_setting(:upload_pack, false)
|
138
138
|
session = Rack::Test::Session.new(a1)
|
139
|
-
session.get "/example
|
140
|
-
assert_equal
|
139
|
+
session.get "/example/info/refs?service=git-upload-pack"
|
140
|
+
assert_equal 404, session.last_response.status
|
141
141
|
end
|
142
142
|
|
143
143
|
def test_config_receive_pack_off
|
144
144
|
a1 = app
|
145
145
|
a1.set_config_setting(:receive_pack, false)
|
146
146
|
session = Rack::Test::Session.new(a1)
|
147
|
-
session.get "/example
|
148
|
-
assert_equal
|
147
|
+
session.get "/example/info/refs?service=git-receive-pack"
|
148
|
+
assert_equal 404, session.last_response.status
|
149
149
|
end
|
150
150
|
|
151
151
|
def test_config_bad_service
|
152
|
-
get "/example
|
153
|
-
assert_equal
|
152
|
+
get "/example/info/refs?service=git-receive-packfile"
|
153
|
+
assert_equal 404, r.status
|
154
154
|
end
|
155
155
|
|
156
156
|
def test_git_config_receive_pack
|
@@ -159,16 +159,16 @@ class GitHttpTest < Test::Unit::TestCase
|
|
159
159
|
session = Rack::Test::Session.new(app1)
|
160
160
|
git = Grack::Git
|
161
161
|
git.any_instance.stubs(:config).with('http.receivepack').returns('')
|
162
|
-
session.get "/example
|
163
|
-
assert_equal
|
162
|
+
session.get "/example/info/refs?service=git-receive-pack"
|
163
|
+
assert_equal 404, session.last_response.status
|
164
164
|
|
165
165
|
git.any_instance.stubs(:config).with('http.receivepack').returns('true')
|
166
|
-
session.get "/example
|
166
|
+
session.get "/example/info/refs?service=git-receive-pack"
|
167
167
|
assert_equal 200, session.last_response.status
|
168
168
|
|
169
169
|
git.any_instance.stubs(:config).with('http.receivepack').returns('false')
|
170
|
-
session.get "/example
|
171
|
-
assert_equal
|
170
|
+
session.get "/example/info/refs?service=git-receive-pack"
|
171
|
+
assert_equal 404, session.last_response.status
|
172
172
|
end
|
173
173
|
|
174
174
|
def test_git_config_upload_pack
|
@@ -177,16 +177,16 @@ class GitHttpTest < Test::Unit::TestCase
|
|
177
177
|
session = Rack::Test::Session.new(app1)
|
178
178
|
git = Grack::Git
|
179
179
|
git.any_instance.stubs(:config).with('http.uploadpack').returns('')
|
180
|
-
session.get "/example
|
180
|
+
session.get "/example/info/refs?service=git-upload-pack"
|
181
181
|
assert_equal 200, session.last_response.status
|
182
182
|
|
183
183
|
git.any_instance.stubs(:config).with('http.uploadpack').returns('true')
|
184
|
-
session.get "/example
|
184
|
+
session.get "/example/info/refs?service=git-upload-pack"
|
185
185
|
assert_equal 200, session.last_response.status
|
186
186
|
|
187
187
|
git.any_instance.stubs(:config).with('http.uploadpack').returns('false')
|
188
|
-
session.get "/example
|
189
|
-
assert_equal
|
188
|
+
session.get "/example/info/refs?service=git-upload-pack"
|
189
|
+
assert_equal 404, session.last_response.status
|
190
190
|
end
|
191
191
|
|
192
192
|
def test_send_file
|
@@ -215,7 +215,7 @@ class GitHttpTest < Test::Unit::TestCase
|
|
215
215
|
|
216
216
|
def write_test_objects
|
217
217
|
content = Digest::SHA1.hexdigest('gitrocks')
|
218
|
-
base = File.join(File.expand_path(File.dirname(__FILE__)), 'example.git', 'objects')
|
218
|
+
base = File.join(File.expand_path(File.dirname(__FILE__)), 'example', '.git', 'objects')
|
219
219
|
obj = File.join(base, '20')
|
220
220
|
Dir.mkdir(obj) rescue nil
|
221
221
|
file = File.join(obj, content[0, 38])
|
@@ -229,7 +229,7 @@ class GitHttpTest < Test::Unit::TestCase
|
|
229
229
|
|
230
230
|
def remove_test_objects
|
231
231
|
content = Digest::SHA1.hexdigest('gitrocks')
|
232
|
-
base = File.join(File.expand_path(File.dirname(__FILE__)), 'example.git', 'objects')
|
232
|
+
base = File.join(File.expand_path(File.dirname(__FILE__)), 'example', '.git', 'objects')
|
233
233
|
obj = File.join(base, '20')
|
234
234
|
file = File.join(obj, content[0, 38])
|
235
235
|
pack = File.join(base, 'pack', "pack-#{content}.pack")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-grack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chacon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -48,6 +48,7 @@ extensions: []
|
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
50
|
- ".gitignore"
|
51
|
+
- ".gitmodules"
|
51
52
|
- ".travis.yml"
|
52
53
|
- CHANGELOG
|
53
54
|
- Gemfile
|