Commit 5e35f21605a15414258c5a857f75679f9df2c102
1 parent
79bea312
Exists in
master
and in
4 other branches
allow all git-upload-* commands for deploy keys
Showing
2 changed files
with
37 additions
and
1 deletions
Show diff stats
lib/api/internal.rb
@@ -26,7 +26,7 @@ module API | @@ -26,7 +26,7 @@ module API | ||
26 | 26 | ||
27 | 27 | ||
28 | if key.is_a? DeployKey | 28 | if key.is_a? DeployKey |
29 | - key.projects.include?(project) && git_cmd == 'git-upload-pack' | 29 | + key.projects.include?(project) && git_cmd.starts_with?('git-upload-') |
30 | else | 30 | else |
31 | user = key.user | 31 | user = key.user |
32 | 32 |
spec/requests/api/internal_spec.rb
@@ -100,6 +100,32 @@ describe API::API do | @@ -100,6 +100,32 @@ describe API::API do | ||
100 | end | 100 | end |
101 | end | 101 | end |
102 | end | 102 | end |
103 | + | ||
104 | + context "deploy key" do | ||
105 | + let(:key) { create(:deploy_key) } | ||
106 | + | ||
107 | + context "added to project" do | ||
108 | + before do | ||
109 | + key.projects << project | ||
110 | + end | ||
111 | + | ||
112 | + it do | ||
113 | + archive(key, project) | ||
114 | + | ||
115 | + response.status.should == 200 | ||
116 | + response.body.should == 'true' | ||
117 | + end | ||
118 | + end | ||
119 | + | ||
120 | + context "not added to project" do | ||
121 | + it do | ||
122 | + archive(key, project) | ||
123 | + | ||
124 | + response.status.should == 200 | ||
125 | + response.body.should == 'false' | ||
126 | + end | ||
127 | + end | ||
128 | + end | ||
103 | end | 129 | end |
104 | 130 | ||
105 | def pull(key, project) | 131 | def pull(key, project) |
@@ -121,4 +147,14 @@ describe API::API do | @@ -121,4 +147,14 @@ describe API::API do | ||
121 | action: 'git-receive-pack' | 147 | action: 'git-receive-pack' |
122 | ) | 148 | ) |
123 | end | 149 | end |
150 | + | ||
151 | + def archive(key, project) | ||
152 | + get( | ||
153 | + api("/internal/allowed"), | ||
154 | + ref: 'master', | ||
155 | + key_id: key.id, | ||
156 | + project: project.path_with_namespace, | ||
157 | + action: 'git-upload-archive' | ||
158 | + ) | ||
159 | + end | ||
124 | end | 160 | end |