debmirrorapi 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/debmirrorapi +0 -0
- data/lib/debmirrorapi.rb +4 -1
- data/spec/api_spec.rb +7 -0
- data/spec/fixtures/mirror.index +10 -0
- data/spec/spec_helper.rb +24 -0
- metadata +6 -2
data/bin/debmirrorapi
CHANGED
File without changes
|
data/lib/debmirrorapi.rb
CHANGED
@@ -81,7 +81,7 @@ class DebmirrorApi < Sinatra::Base
|
|
81
81
|
requested_mirror = params[:splat][0]
|
82
82
|
requested_dist = params[:splat][1]
|
83
83
|
requested_tag = params[:splat][2]
|
84
|
-
if params['version']
|
84
|
+
if params['version']
|
85
85
|
requested_tag_version = params['version']
|
86
86
|
else
|
87
87
|
body 'missing version in patch data'.to_json
|
@@ -91,6 +91,9 @@ class DebmirrorApi < Sinatra::Base
|
|
91
91
|
tag_dir = File.join("/var/lib/debmirror/", requested_mirror, "dists", requested_dist)
|
92
92
|
if mirror_list.include?(requested_mirror) and requested_dist !=~ /\/..\// and File.symlink?(requested_tag_file)
|
93
93
|
requested_tag_version_file = File.join("/var/lib/debmirror/", requested_mirror, "dists", requested_dist, requested_tag_version)
|
94
|
+
if requested_tag_version !~ /^\d+$/
|
95
|
+
halt 405
|
96
|
+
end
|
94
97
|
if File.exists?(requested_tag_version_file) and not File.symlink?(requested_tag_version_file)
|
95
98
|
File.link(requested_tag_version_file, requested_tag_file)
|
96
99
|
response = {}
|
data/spec/api_spec.rb
CHANGED
@@ -181,6 +181,13 @@ describe "Debmirror-API" do
|
|
181
181
|
last_response.status.should == 405
|
182
182
|
end
|
183
183
|
|
184
|
+
it "should respond with method not allowed if version is not an integer" do
|
185
|
+
File.stub(:exists?).with('/var/lib/debmirror/repo.percona.com/apt/dists/squeeze/20') { false }
|
186
|
+
patch '/tag/repo.percona.com/apt/dist/squeeze/stable', :version => '20i'
|
187
|
+
last_response.should_not be_ok
|
188
|
+
last_response.status.should == 405
|
189
|
+
end
|
190
|
+
|
184
191
|
it "should respond with 404 if release_tag is not a valid tag" do
|
185
192
|
patch '/tag/repo.percona.com/apt/dist/squeeze/bullshit', :version => 4
|
186
193
|
last_response.should_not be_ok
|
@@ -0,0 +1,10 @@
|
|
1
|
+
repo.percona.com/apt/debian/dists/squeeze
|
2
|
+
downloads-distro.mongodb.org/repo/debian-sysvinit
|
3
|
+
packages.vpn.jimdo-server.com/
|
4
|
+
deb.theforeman.org/
|
5
|
+
ftp.uk.debian.org/debian-backports
|
6
|
+
security.debian.org/
|
7
|
+
ftp.uk.debian.org/debian
|
8
|
+
repo.percona.com/apt
|
9
|
+
archive.debian.org/debian-archive/debian
|
10
|
+
apt.newrelic.com/debian
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start do
|
3
|
+
add_filter '/spec/'
|
4
|
+
end
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'debmirrorapi.rb')
|
7
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'debmirrorapihelpers.rb')
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'rack/test'
|
11
|
+
|
12
|
+
# setup test environment
|
13
|
+
set :environment, :test
|
14
|
+
set :run, false
|
15
|
+
set :raise_errors, true
|
16
|
+
set :logging, false
|
17
|
+
|
18
|
+
def app
|
19
|
+
DebmirrorApi
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.include Rack::Test::Methods
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debmirrorapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -144,6 +144,8 @@ files:
|
|
144
144
|
- config.ru
|
145
145
|
- spec/api_spec.rb
|
146
146
|
- spec/debmirrorapihelpers_spec.rb
|
147
|
+
- spec/fixtures/mirror.index
|
148
|
+
- spec/spec_helper.rb
|
147
149
|
homepage: http://github.com/Jimdo/debmirror-api
|
148
150
|
licenses: []
|
149
151
|
post_install_message:
|
@@ -171,3 +173,5 @@ summary: Simple API to provide an interface to debmirror.
|
|
171
173
|
test_files:
|
172
174
|
- spec/api_spec.rb
|
173
175
|
- spec/debmirrorapihelpers_spec.rb
|
176
|
+
- spec/fixtures/mirror.index
|
177
|
+
- spec/spec_helper.rb
|