puppet-forge-server 1.4.2 → 1.4.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.
- checksums.yaml +4 -4
- data/lib/puppet_forge_server/backends/directory.rb +3 -1
- data/lib/puppet_forge_server/logger.rb +7 -1
- data/lib/puppet_forge_server/version.rb +1 -1
- data/spec/unit/app/version2_spec.rb +43 -0
- data/spec/unit/backends/directory_spec.rb +64 -0
- data/spec/unit/logger_spec.rb +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a52acbf7c0c982ac11d22101fad03ebfc4b013e2
|
4
|
+
data.tar.gz: 3893b0a073c6122880c9488dcbf1f24a056c43bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4603163ac0d1c51a41beaa6f6b3c118b2c90c80590af9afb10a57f831d8a27aabb548673a2c479aaba34c3a312539f46e4c534f9b14acce4ab0ed89f50db6a1c
|
7
|
+
data.tar.gz: 59725a047ab27ff5dfea353fb0d3801d336cb47034f66a9d165ef623e686513520982080afa25d32c2aea2ab22c758d8a3c0645a9be572d9f30271adc8269cb8
|
@@ -44,7 +44,9 @@ module PuppetForgeServer::Backends
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def upload(file_data)
|
47
|
-
File.
|
47
|
+
filename = File.join(@module_dir, file_data[:filename])
|
48
|
+
return false if File.exist?(filename)
|
49
|
+
File.open(filename, 'w') do |f|
|
48
50
|
f.write(file_data[:tempfile].read)
|
49
51
|
end
|
50
52
|
true
|
@@ -38,6 +38,8 @@ module PuppetForgeServer
|
|
38
38
|
method_name = case method_name
|
39
39
|
when :write, :puts
|
40
40
|
'<<'
|
41
|
+
when :flush
|
42
|
+
''
|
41
43
|
else
|
42
44
|
method_name
|
43
45
|
end
|
@@ -45,7 +47,11 @@ module PuppetForgeServer
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def respond_to?(method_name, include_private = false)
|
48
|
-
@loggers.each { |logger| return false unless (logger.respond_to?(method_name) || %w(write puts).include?(method_name.to_s)) }
|
50
|
+
@loggers.each { |logger| return false unless (logger.respond_to?(method_name) || %w(write puts flush).include?(method_name.to_s)) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def flush
|
54
|
+
# ignore
|
49
55
|
end
|
50
56
|
|
51
57
|
class << self
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2015 North Development AB
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
module PuppetForgeServer::App
|
20
|
+
describe Version2 do
|
21
|
+
let(:directory) { double() }
|
22
|
+
let(:app) { PuppetForgeServer::App::Version2.new([directory]) }
|
23
|
+
let(:file_name_true) { 'bogus_file_true' }
|
24
|
+
let(:file_name_false) { 'bogus_file_false' }
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
allow(directory).to receive(:upload).with(file_name_true) { true }
|
28
|
+
allow(directory).to receive(:upload).with(file_name_false) { false }
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#post /v2/releases' do
|
32
|
+
it 'file upload should succeed' do
|
33
|
+
post '/v2/releases', params={ :file => file_name_true }
|
34
|
+
expect(last_response).to be_ok
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'file upload should fail' do
|
38
|
+
post '/v2/releases', params={ :file => file_name_false }
|
39
|
+
expect(last_response.status).to eq(412)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2015 North Development AB
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'spec_helper'
|
18
|
+
|
19
|
+
module PuppetForgeServer::Backends
|
20
|
+
describe Directory do
|
21
|
+
let(:url) { 'bogus_url' }
|
22
|
+
let(:name) { 'bogus_name' }
|
23
|
+
let(:author) { 'bogus_author' }
|
24
|
+
let(:version) { 'bogus_version' }
|
25
|
+
let(:directory) { PuppetForgeServer::Backends::Directory.new(url) }
|
26
|
+
let(:file_metadata) { { :metadata => nil, :checksum => nil, :path => nil} }
|
27
|
+
let(:file_data) { { :filename => 'bogus_filename' } }
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
allow(directory).to receive(:get_file_metadata).with("*#{name}*.tar.gz", {}) { file_metadata }
|
31
|
+
allow(directory).to receive(:get_file_metadata).with("#{author}-#{name}-*.tar.gz", {}) { file_metadata }
|
32
|
+
allow(directory).to receive(:get_file_metadata).with("#{author}-#{name}-#{version}.tar.gz", {:version => version}) { file_metadata }
|
33
|
+
allow(File).to receive(:open).with("#{url}/#{file_data[:filename]}", 'w')
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#query_metadata' do
|
37
|
+
it 'query metadata should return file metadata array' do
|
38
|
+
expect(directory.query_metadata(name)).to eq(file_metadata)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#get_metadata' do
|
43
|
+
it 'get_metadata without version should return file metadata array' do
|
44
|
+
expect(directory.get_metadata(author, name)).to eq(file_metadata)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'get_metadata with version should return file metadata array' do
|
48
|
+
expect(directory.get_metadata(author, name, {:version => version})).to eq(file_metadata)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#upload' do
|
53
|
+
it 'upload when file does not exist should return true' do
|
54
|
+
allow(File).to receive(:exist?).with("#{url}/#{file_data[:filename]}") { false }
|
55
|
+
expect(directory.upload(file_data)).to be
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'upload when file exists should return false' do
|
59
|
+
allow(File).to receive(:exist?).with("#{url}/#{file_data[:filename]}") { true }
|
60
|
+
expect(directory.upload(file_data)).not_to be
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/spec/unit/logger_spec.rb
CHANGED
@@ -70,6 +70,12 @@ module PuppetForgeServer
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
describe '#flush' do
|
74
|
+
it 'should respond to flush' do
|
75
|
+
expect(logger).to respond_to('flush')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
73
79
|
describe '#non_existing' do
|
74
80
|
it 'should fail on non existing method' do
|
75
81
|
expect { logger.non_existing }.to raise_error(NoMethodError)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-forge-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilja Bobkevic
|
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: sinatra
|
@@ -199,6 +199,8 @@ files:
|
|
199
199
|
- lib/puppet_forge_server/version.rb
|
200
200
|
- puppet-forge-server.gemspec
|
201
201
|
- spec/spec_helper.rb
|
202
|
+
- spec/unit/app/version2_spec.rb
|
203
|
+
- spec/unit/backends/directory_spec.rb
|
202
204
|
- spec/unit/logger_spec.rb
|
203
205
|
- spec/unit/models/metadata_spec.rb
|
204
206
|
- spec/unit/server_spec.rb
|
@@ -228,6 +230,8 @@ specification_version: 4
|
|
228
230
|
summary: Private Puppet forge server
|
229
231
|
test_files:
|
230
232
|
- spec/spec_helper.rb
|
233
|
+
- spec/unit/app/version2_spec.rb
|
234
|
+
- spec/unit/backends/directory_spec.rb
|
231
235
|
- spec/unit/logger_spec.rb
|
232
236
|
- spec/unit/models/metadata_spec.rb
|
233
237
|
- spec/unit/server_spec.rb
|