git-lighttp 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +90 -0
- data/README.pt-BR.md +96 -0
- data/doc/releases/{v0.1.0.rdoc → v0.1.0.md} +4 -4
- data/doc/releases/{v0.2.0.rdoc → v0.2.0.md} +3 -5
- data/doc/releases/{v0.3.0.rdoc → v0.3.0.md} +3 -3
- data/doc/releases/v0.3.1.md +12 -0
- data/git-lighttp.gemspec +34 -21
- data/lib/git/lighttp.rb +100 -97
- data/lib/git/lighttp/extensions.rb +26 -30
- data/lib/git/lighttp/http_backend.rb +20 -20
- data/lib/git/lighttp/treeish.rb +2 -2
- data/lib/git/lighttp/version.rb +3 -3
- metadata +79 -71
- data/Gemfile +0 -11
- data/Makefile +0 -41
- data/README.pt-BR.rdoc +0 -81
- data/README.rdoc +0 -75
- data/Rakefile +0 -50
- data/test/all.rb +0 -12
- data/test/config_test.rb +0 -43
- data/test/fixtures/config.yml +0 -13
- data/test/fixtures/htgroup +0 -3
- data/test/fixtures/htpasswd +0 -4
- data/test/fixtures/mycode.git/HEAD +0 -1
- data/test/fixtures/mycode.git/config +0 -4
- data/test/fixtures/mycode.git/description +0 -1
- data/test/fixtures/mycode.git/hooks/applypatch-msg.sample +0 -15
- data/test/fixtures/mycode.git/hooks/commit-msg.sample +0 -24
- data/test/fixtures/mycode.git/hooks/post-commit.sample +0 -8
- data/test/fixtures/mycode.git/hooks/post-receive.sample +0 -15
- data/test/fixtures/mycode.git/hooks/post-update.sample +0 -8
- data/test/fixtures/mycode.git/hooks/pre-applypatch.sample +0 -14
- data/test/fixtures/mycode.git/hooks/pre-commit.sample +0 -46
- data/test/fixtures/mycode.git/hooks/pre-rebase.sample +0 -169
- data/test/fixtures/mycode.git/hooks/prepare-commit-msg.sample +0 -36
- data/test/fixtures/mycode.git/hooks/update.sample +0 -128
- data/test/fixtures/mycode.git/info/exclude +0 -6
- data/test/fixtures/mycode.git/info/refs +0 -3
- data/test/fixtures/mycode.git/objects/02/83eb96425444e17b97182e1ba9f216cc67c132 +0 -0
- data/test/fixtures/mycode.git/objects/03/9927042df267a1bc606fc4485b7a79b6a9e3cd +0 -1
- data/test/fixtures/mycode.git/objects/0d/eed0a56fa8f5f2a788d58b3ea235afd547b828 +0 -2
- data/test/fixtures/mycode.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/mycode.git/objects/5e/54a0767e0c380f3baab17938d68c7f464cf171 +0 -1
- data/test/fixtures/mycode.git/objects/63/9b96262e7e19ca2169575e797b234098b8a72e +0 -0
- data/test/fixtures/mycode.git/objects/71/6e9568eed27d5ee4378b3ecf6dd095a547bde9 +0 -1
- data/test/fixtures/mycode.git/objects/b6/f3f0fabeaaaaf2db22b8ef98f59115baec7ef9 +0 -0
- data/test/fixtures/mycode.git/objects/be/118435b9d908fd4a689cd8b0cc98059911a31a +0 -0
- data/test/fixtures/mycode.git/objects/db/aefcb5bde664671c73b99515c386dcbc7f22b6 +0 -0
- data/test/fixtures/mycode.git/objects/eb/669b878d2013ac70aa5dee75e6357ea81d16ea +0 -0
- data/test/fixtures/mycode.git/objects/ed/10cfcf72862e140c97fe899cba2a55f4cb4c20 +0 -0
- data/test/fixtures/mycode.git/objects/ed/1c3a255ab3fce056dc31cd82df9f61a4d9fa22 +0 -0
- data/test/fixtures/mycode.git/objects/info/alternates +0 -0
- data/test/fixtures/mycode.git/objects/info/http-alternates +0 -0
- data/test/fixtures/mycode.git/objects/info/packs +0 -2
- data/test/fixtures/mycode.git/objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.idx +0 -0
- data/test/fixtures/mycode.git/objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.pack +0 -0
- data/test/fixtures/mycode.git/packed-refs +0 -4
- data/test/fixtures/mycode.git/refs/heads/master +0 -1
- data/test/fixtures/mycode.git/refs/tags/v0.1.0 +0 -1
- data/test/helpers.rb +0 -53
- data/test/htgroup_test.rb +0 -29
- data/test/htpasswd_test.rb +0 -63
- data/test/http_backend_authentication_test.rb +0 -61
- data/test/http_backend_test.rb +0 -123
- data/test/project_handler_test.rb +0 -45
- data/test/treeish_test.rb +0 -33
data/test/htgroup_test.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
describe 'HTTP group handler' do
|
2
|
-
before do
|
3
|
-
@groups = {
|
4
|
-
'writers' => %w[mark matthew luke john],
|
5
|
-
'disciples' => %w[john peter],
|
6
|
-
'prophets' => %w[malachi jeremiah]
|
7
|
-
}
|
8
|
-
|
9
|
-
@htgroup = Git::Lighttp::Htgroup.new(fixtures('htgroup'))
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'find member' do
|
13
|
-
@groups.each do |group, members|
|
14
|
-
members.each do |username|
|
15
|
-
found = @htgroup.members(group).include? username
|
16
|
-
assert found
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'find member' do
|
22
|
-
@groups.each do |group, members|
|
23
|
-
members.each do |username|
|
24
|
-
found = @htgroup.groups(username).include? group
|
25
|
-
assert found
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/test/htpasswd_test.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
describe 'HTTP password handler' do
|
2
|
-
before do
|
3
|
-
@passwords = {
|
4
|
-
'matthew' => 'zKOzsdCzE.mEE',
|
5
|
-
'mark' => 'V5.e7XhcXHmQc',
|
6
|
-
'luke' => '1y687odVzuFJs',
|
7
|
-
'john' => 'BInD5.JEyr5Ng'
|
8
|
-
}
|
9
|
-
@htpasswd = Git::Lighttp::Htpasswd.new(fixtures('htpasswd'))
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
File.delete fixtures('htpasswd.tmp') if File.exist? fixtures('htpasswd.tmp')
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'find user' do
|
17
|
-
@passwords.each do |username, password|
|
18
|
-
assert_equal password, @htpasswd.find(username)
|
19
|
-
@htpasswd.find username do |pass, salt|
|
20
|
-
assert_equal password, pass
|
21
|
-
assert_equal password[0,2], salt
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'check authentication of the user' do
|
27
|
-
@passwords.keys.each do |user|
|
28
|
-
assert !@htpasswd.authenticated?(user, 'invalid')
|
29
|
-
assert @htpasswd.authenticated?(user, 's3kr3t')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'create or update user' do
|
34
|
-
Git::Lighttp::Htpasswd.new fixtures('htpasswd.tmp') do |htpasswd|
|
35
|
-
htpasswd.create 'judas', 'hanged'
|
36
|
-
assert htpasswd.include?('judas')
|
37
|
-
assert htpasswd.authenticated?('judas', 'hanged')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'list users' do
|
42
|
-
assert_equal 4, @htpasswd.size
|
43
|
-
@passwords.keys.each do |user|
|
44
|
-
assert @htpasswd.include?(user)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'destroy user' do
|
49
|
-
Git::Lighttp::Htpasswd.new fixtures('htpasswd.tmp') do |htpasswd|
|
50
|
-
htpasswd.create 'judas', 'hanged'
|
51
|
-
assert htpasswd.include?('judas')
|
52
|
-
|
53
|
-
htpasswd.destroy 'judas'
|
54
|
-
|
55
|
-
assert !htpasswd.include?('judas')
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'check invalid user' do
|
60
|
-
assert !@htpasswd.authenticated?('nobody', 'empty')
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
include Rack::Test::Methods
|
2
|
-
|
3
|
-
alias request last_request
|
4
|
-
|
5
|
-
alias response last_response
|
6
|
-
|
7
|
-
describe 'HTTP Backend server authentication' do
|
8
|
-
def app
|
9
|
-
Git::Lighttp::HttpBackend.configure do |server|
|
10
|
-
server.project_root = fixtures
|
11
|
-
server.git_path = '/usr/bin/git'
|
12
|
-
server.authenticate = true
|
13
|
-
end
|
14
|
-
Git::Lighttp::HttpBackend
|
15
|
-
end
|
16
|
-
|
17
|
-
before do
|
18
|
-
# return 500 objects/info/http-alternates
|
19
|
-
# objects/info/alternates
|
20
|
-
@paths = [
|
21
|
-
[ :get, 'HEAD' ],
|
22
|
-
[ :get, 'info/refs' ],
|
23
|
-
[ :get, 'objects/info/packs' ],
|
24
|
-
[ :get, 'objects/02/83eb96425444e17b97182e1ba9f216cc67c132' ],
|
25
|
-
[ :get, 'objects/03/9927042df267a1bc606fc4485b7a79b6a9e3cd' ],
|
26
|
-
[ :get, 'objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904' ],
|
27
|
-
[ :get, 'objects/5e/54a0767e0c380f3baab17938d68c7f464cf171' ],
|
28
|
-
[ :get, 'objects/71/6e9568eed27d5ee4378b3ecf6dd095a547bde9' ],
|
29
|
-
[ :get, 'objects/be/118435b9d908fd4a689cd8b0cc98059911a31a' ],
|
30
|
-
[ :get, 'objects/db/aefcb5bde664671c73b99515c386dcbc7f22b6' ],
|
31
|
-
[ :get, 'objects/eb/669b878d2013ac70aa5dee75e6357ea81d16ea' ],
|
32
|
-
[ :get, 'objects/ed/10cfcf72862e140c97fe899cba2a55f4cb4c20' ],
|
33
|
-
[ :get, 'objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.idx' ],
|
34
|
-
[ :get, 'objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.pack' ],
|
35
|
-
[ :get, 'info/refs', { :service => 'git-upload-pack' } ],
|
36
|
-
[ :get, 'info/refs', { :service => 'git-receive-pack' } ],
|
37
|
-
[ :post, 'git-upload-pack', {}, { 'CONTENT_TYPE' => 'application/x-git-upload-pack-request' } ],
|
38
|
-
[ :post, 'git-receive-pack', {}, { 'CONTENT_TYPE' => 'application/x-git-receive-pack-request' } ]
|
39
|
-
]
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'unauthorize repository paths' do
|
43
|
-
@paths.each do |params|
|
44
|
-
verb = params.shift
|
45
|
-
path = params.shift
|
46
|
-
send verb, "/mycode.git/#{path}", *params
|
47
|
-
assert_equal 401, response.status
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'authorize repository paths' do
|
52
|
-
authorize('john', 's3kr3t')
|
53
|
-
@paths.each do |params|
|
54
|
-
verb = params.shift
|
55
|
-
path = params.shift
|
56
|
-
send verb, "/mycode.git/#{path}", *params
|
57
|
-
assert_equal 200, response.status, request.env['sinatra.error']
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
data/test/http_backend_test.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
include Rack::Test::Methods
|
2
|
-
|
3
|
-
alias response last_response
|
4
|
-
|
5
|
-
describe 'HTTP Backend server' do
|
6
|
-
def app
|
7
|
-
Git::Lighttp::HttpBackend.configure do |server|
|
8
|
-
server.project_root = fixtures
|
9
|
-
server.git_path = '/usr/bin/git'
|
10
|
-
server.get_any_file = true
|
11
|
-
server.upload_pack = true
|
12
|
-
server.receive_pack = true
|
13
|
-
server.authenticate = false
|
14
|
-
end
|
15
|
-
Git::Lighttp::HttpBackend
|
16
|
-
end
|
17
|
-
|
18
|
-
before do
|
19
|
-
@objects = [
|
20
|
-
'02/83eb96425444e17b97182e1ba9f216cc67c132',
|
21
|
-
'03/9927042df267a1bc606fc4485b7a79b6a9e3cd',
|
22
|
-
'4b/825dc642cb6eb9a060e54bf8d69288fbee4904',
|
23
|
-
'5e/54a0767e0c380f3baab17938d68c7f464cf171',
|
24
|
-
'71/6e9568eed27d5ee4378b3ecf6dd095a547bde9',
|
25
|
-
'be/118435b9d908fd4a689cd8b0cc98059911a31a',
|
26
|
-
'db/aefcb5bde664671c73b99515c386dcbc7f22b6',
|
27
|
-
'eb/669b878d2013ac70aa5dee75e6357ea81d16ea',
|
28
|
-
'ed/10cfcf72862e140c97fe899cba2a55f4cb4c20'
|
29
|
-
]
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'get head file content' do
|
33
|
-
get '/mycode.git/HEAD' do
|
34
|
-
assert_equal 200, response.status
|
35
|
-
assert_equal "ref: refs/heads/master\n", response.body
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'get info refs' do
|
40
|
-
get '/mycode.git/info/refs' do
|
41
|
-
assert_equal 200, response.status
|
42
|
-
assert_match 'refs/heads/master', response.body
|
43
|
-
assert_match 'refs/tags/v0.1.0', response.body
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'get info alternates' do
|
48
|
-
get '/mycode.git/objects/info/alternates' do
|
49
|
-
assert_equal 200, response.status
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'get info http alternates' do
|
54
|
-
get '/mycode.git/objects/info/http-alternates' do
|
55
|
-
assert_equal 200, response.status
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'get object info packs' do
|
60
|
-
get '/mycode.git/objects/info/packs' do
|
61
|
-
assert_equal 200, response.status
|
62
|
-
assert_equal 'P pack-40a8636b62258fffd78ec1e8d254116e72d385a9.pack',
|
63
|
-
response.body.split("\n").first
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'get loose objects' do
|
68
|
-
@objects.each do |object|
|
69
|
-
get "/mycode.git/objects/#{object}" do
|
70
|
-
assert_equal 200, response.status
|
71
|
-
assert_equal 'application/x-git-loose-object', response.content_type
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'get pack file' do
|
77
|
-
get '/mycode.git/objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.idx' do
|
78
|
-
assert_equal 200, response.status
|
79
|
-
assert_equal 'application/x-git-packed-objects-toc', response.content_type
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'get index file' do
|
84
|
-
get '/mycode.git/objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.pack' do
|
85
|
-
assert_equal 200, response.status
|
86
|
-
assert_equal 'application/x-git-packed-objects', response.content_type
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'upload advertisement' do
|
91
|
-
get '/mycode.git/info/refs', :service => 'git-upload-pack' do
|
92
|
-
assert_equal 200, response.status
|
93
|
-
assert_equal 'application/x-git-upload-pack-advertisement', response.content_type
|
94
|
-
assert_equal '001e# service=git-upload-pack', response.body.split("\n").first
|
95
|
-
assert_match 'multi_ack_detailed', response.body
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'receive advertisement' do
|
100
|
-
get '/mycode.git/info/refs', :service => 'git-receive-pack' do
|
101
|
-
assert_equal 200, response.status
|
102
|
-
assert_equal 'application/x-git-receive-pack-advertisement', response.content_type
|
103
|
-
assert_equal '001f# service=git-receive-pack', response.body.split("\n").first
|
104
|
-
assert_match 'report-status', response.body
|
105
|
-
assert_match 'delete-refs', response.body
|
106
|
-
assert_match 'ofs-delta', response.body
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# this test use mock in IO.popen. See in test/helpers.rb.
|
111
|
-
it 'RPC for upload packets' do
|
112
|
-
post '/mycode.git/git-upload-pack', {}, {'CONTENT_TYPE' => 'application/x-git-upload-pack-request'}
|
113
|
-
assert_equal 200, response.status
|
114
|
-
assert_equal 'application/x-git-upload-pack-result', response.content_type
|
115
|
-
end
|
116
|
-
|
117
|
-
# this test use mock in IO.popen. See in test/helpers.rb.
|
118
|
-
it 'RPC for receive packets' do
|
119
|
-
post '/mycode.git/git-receive-pack', {}, {'CONTENT_TYPE' => 'application/x-git-receive-pack-request'}
|
120
|
-
assert_equal 200, response.status
|
121
|
-
assert_equal 'application/x-git-receive-pack-result', response.content_type
|
122
|
-
end
|
123
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
describe 'Project handler' do
|
2
|
-
before do
|
3
|
-
@git = Git::Lighttp::ProjectHandler.new(fixtures, '/usr/bin/git')
|
4
|
-
@objects = [
|
5
|
-
'HEAD',
|
6
|
-
'info/refs',
|
7
|
-
'objects/info/packs',
|
8
|
-
'objects/02/83eb96425444e17b97182e1ba9f216cc67c132',
|
9
|
-
'objects/03/9927042df267a1bc606fc4485b7a79b6a9e3cd',
|
10
|
-
'objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904',
|
11
|
-
'objects/5e/54a0767e0c380f3baab17938d68c7f464cf171',
|
12
|
-
'objects/71/6e9568eed27d5ee4378b3ecf6dd095a547bde9',
|
13
|
-
'objects/be/118435b9d908fd4a689cd8b0cc98059911a31a',
|
14
|
-
'objects/db/aefcb5bde664671c73b99515c386dcbc7f22b6',
|
15
|
-
'objects/eb/669b878d2013ac70aa5dee75e6357ea81d16ea',
|
16
|
-
'objects/ed/10cfcf72862e140c97fe899cba2a55f4cb4c20',
|
17
|
-
'objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.idx',
|
18
|
-
'objects/pack/pack-40a8636b62258fffd78ec1e8d254116e72d385a9.pack'
|
19
|
-
]
|
20
|
-
@git.repository = 'mycode.git'
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'check basic attributes' do
|
24
|
-
assert_equal fixtures, @git.project_root
|
25
|
-
assert_equal '/usr/bin/git', @git.path
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'config repository path' do
|
29
|
-
assert_equal fixtures('mycode.git'), @git.repository
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'find repository objects' do
|
33
|
-
@objects.each do |object|
|
34
|
-
assert_equal fixtures('mycode.git', object), @git.path_to(object)
|
35
|
-
assert File.exist?(@git.path_to(object))
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'list tree files' do
|
40
|
-
assert_equal 3, @git.tree.size
|
41
|
-
assert_equal 'README.txt', @git.tree[1][:fname]
|
42
|
-
assert_equal 'lib', @git.tree.last[:fname]
|
43
|
-
assert_equal 'mycode.rb', @git.tree('HEAD', 'lib').first[:fname]
|
44
|
-
end
|
45
|
-
end
|
data/test/treeish_test.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
include Rack::Test::Methods
|
2
|
-
|
3
|
-
alias request last_request
|
4
|
-
|
5
|
-
alias response last_response
|
6
|
-
|
7
|
-
describe 'Project tree' do
|
8
|
-
def app
|
9
|
-
Git::Lighttp::Treeish.configure do |server|
|
10
|
-
server.project_root = fixtures
|
11
|
-
end
|
12
|
-
Git::Lighttp::Treeish
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'get tree of project from reference' do
|
16
|
-
get '/mycode.git/HEAD' do
|
17
|
-
assert_equal 200, response.status, request.env['sinatra.error']
|
18
|
-
assert_match 'application/json', response.content_type
|
19
|
-
assert_match 'README.txt', response.body
|
20
|
-
assert_equal 3, JSON.parse(response.body).size
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'get tree of project from reference and path' do
|
25
|
-
get '/mycode.git/HEAD/lib' do
|
26
|
-
assert_equal 200, response.status, request.env['sinatra.error']
|
27
|
-
assert_match 'application/json', response.content_type
|
28
|
-
assert_match 'mycode.rb', response.body
|
29
|
-
assert_equal 'mycode.rb', JSON.parse(response.body).first['fname']
|
30
|
-
assert_equal 1, JSON.parse(response.body).size
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|