puppet-forge-server 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +4 -0
- data/Rakefile +32 -0
- data/lib/puppet_forge_server/api/v3/modules.rb +1 -1
- data/lib/puppet_forge_server/app/generic.rb +5 -3
- data/lib/puppet_forge_server/app/version1.rb +10 -17
- data/lib/puppet_forge_server/app/version2.rb +5 -4
- data/lib/puppet_forge_server/app/version3.rb +30 -22
- data/lib/puppet_forge_server/backends/proxy_v3.rb +6 -1
- data/lib/puppet_forge_server/logger.rb +3 -3
- data/lib/puppet_forge_server/patches.rb +13 -2
- data/lib/puppet_forge_server/version.rb +1 -1
- data/puppet-forge-server.gemspec +2 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/unit/logger_spec.rb +79 -0
- data/spec/unit/models/metadata_spec.rb +51 -0
- data/spec/unit/server_spec.rb +29 -0
- metadata +40 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fc878b60f808ff3ccfd744ef972e0acd5896be2
|
4
|
+
data.tar.gz: a4c0e1961bb1fe2eb452ca1036efac07b05aeccb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ffedd8529f0e510ecdafbfbcfa4e30ef5994a726fc9a3617702ef511527159897f5ff4037842f49ce71272cb9c9a47875e74501d840edaab9b4e3219132452
|
7
|
+
data.tar.gz: b4a98a5d8e131399f6ca7b28207edd604a46c469118f0a46ee3508f96a1e69dcea4c30db30d5f1fb36aeb1272e137e4d03beab8168cc97aa7b29372509772570
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -134,6 +134,10 @@ Puppet module *metadata* json representation is used as a main business *model*.
|
|
134
134
|
1. Create UTs for core logic
|
135
135
|
2. Implement *source* and *git* backends to match [puppet library](https://github.com/drrb/puppet-library) feature set
|
136
136
|
|
137
|
+
## Limitations
|
138
|
+
|
139
|
+
1. Modulefile is not supported with the *directory* backend
|
140
|
+
|
137
141
|
## License
|
138
142
|
|
139
143
|
[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 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 'rspec/core/rake_task'
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new('test:integration') do |t|
|
20
|
+
t.verbose = true
|
21
|
+
t.pattern = 'spec/integration/*_spec.rb'
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec::Core::RakeTask.new('test:unit') do |t|
|
25
|
+
t.verbose = true
|
26
|
+
t.pattern = 'spec/unit/*_spec.rb'
|
27
|
+
end
|
28
|
+
|
29
|
+
RSpec::Core::RakeTask.new('test:all') do |t|
|
30
|
+
t.verbose = true
|
31
|
+
t.pattern = 'spec/**/*_spec.rb'
|
32
|
+
end
|
@@ -41,7 +41,7 @@ module PuppetForgeServer::Api::V3
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
PuppetForgeServer::Logger.get.error "Requested module count is more than 1:\n#{modules.values}" if modules.values.count > 1
|
45
45
|
modules.values.first
|
46
46
|
end
|
47
47
|
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'sinatra/base'
|
18
|
+
require 'sinatra/json'
|
18
19
|
|
19
20
|
module PuppetForgeServer::App
|
20
21
|
class Generic < Sinatra::Base
|
@@ -24,9 +25,10 @@ module PuppetForgeServer::App
|
|
24
25
|
use ::Rack::CommonLogger, PuppetForgeServer::Logger.get(:access)
|
25
26
|
end
|
26
27
|
|
27
|
-
before
|
28
|
+
before do
|
29
|
+
content_type :json
|
28
30
|
env['rack.errors'] = PuppetForgeServer::Logger.get(:server)
|
29
|
-
|
31
|
+
end
|
30
32
|
|
31
33
|
def initialize
|
32
34
|
super(nil)
|
@@ -37,7 +39,7 @@ module PuppetForgeServer::App
|
|
37
39
|
#
|
38
40
|
post '/oauth/token' do
|
39
41
|
PuppetForgeServer::Logger.get(:server).debug "Params: #{params}"
|
40
|
-
|
42
|
+
json :access_token => 'BOGUS_ACCESS_TOKEN'
|
41
43
|
end
|
42
44
|
|
43
45
|
end
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'sinatra/base'
|
18
|
-
require 'json'
|
18
|
+
require 'sinatra/json'
|
19
19
|
|
20
20
|
module PuppetForgeServer::App
|
21
21
|
class Version1 < Sinatra::Base
|
@@ -28,9 +28,10 @@ module PuppetForgeServer::App
|
|
28
28
|
use ::Rack::CommonLogger, PuppetForgeServer::Logger.get(:access)
|
29
29
|
end
|
30
30
|
|
31
|
-
before
|
32
|
-
|
33
|
-
|
31
|
+
before do
|
32
|
+
content_type :json
|
33
|
+
env['rack.errors'] = PuppetForgeServer::Logger.get(:server)
|
34
|
+
end
|
34
35
|
|
35
36
|
def initialize(backends)
|
36
37
|
super(nil)
|
@@ -38,28 +39,20 @@ module PuppetForgeServer::App
|
|
38
39
|
end
|
39
40
|
|
40
41
|
get '/api/v1/releases.json' do
|
41
|
-
unless params[:module]
|
42
|
-
halt 400, {'error' => 'The number of version constraints in the query does not match the number of module names'}.to_json
|
43
|
-
end
|
44
|
-
|
42
|
+
halt 400, json({:error => 'The number of version constraints in the query does not match the number of module names'}) unless params[:module]
|
45
43
|
author, name = params[:module].split '/'
|
46
44
|
version = params[:version] if params[:version]
|
47
|
-
|
48
45
|
metadata = @backends.map do |backend|
|
49
46
|
backend.get_metadata(author, name, {:version => version, :with_checksum => false})
|
50
47
|
end.flatten.compact.uniq
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
{"#{author}/#{name}" => get_releases(metadata)}.to_json
|
48
|
+
halt 400, json({:errors => ["'#{params[:module]}' is not a valid module slug"]}) if metadata.empty?
|
49
|
+
json "#{author}/#{name}" => get_releases(metadata)
|
55
50
|
end
|
56
51
|
|
57
52
|
get '/api/v1/files/*' do
|
58
53
|
captures = params[:captures].first
|
59
54
|
buffer = get_buffer(@backends, captures)
|
60
|
-
|
61
|
-
halt 404, {'errors' => ['404 Not found']}.to_json unless buffer
|
62
|
-
|
55
|
+
halt 404, json({:errors => ['404 Not found']}) unless buffer
|
63
56
|
content_type 'application/octet-stream'
|
64
57
|
attachment captures.split('/').last
|
65
58
|
download buffer
|
@@ -70,7 +63,7 @@ module PuppetForgeServer::App
|
|
70
63
|
metadata = @backends.map do |backend|
|
71
64
|
backend.query_metadata(query, {:with_checksum => false})
|
72
65
|
end.flatten.compact.uniq
|
73
|
-
get_modules(metadata)
|
66
|
+
json get_modules(metadata)
|
74
67
|
end
|
75
68
|
end
|
76
69
|
end
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'sinatra/base'
|
18
|
+
require 'sinatra/json'
|
18
19
|
|
19
20
|
module PuppetForgeServer::App
|
20
21
|
class Version2 < Sinatra::Base
|
@@ -24,9 +25,9 @@ module PuppetForgeServer::App
|
|
24
25
|
use ::Rack::CommonLogger, PuppetForgeServer::Logger.get(:access)
|
25
26
|
end
|
26
27
|
|
27
|
-
before
|
28
|
-
env['rack.errors'] =
|
29
|
-
|
28
|
+
before do
|
29
|
+
env['rack.errors'] = PuppetForgeServer::Logger.get(:server)
|
30
|
+
end
|
30
31
|
|
31
32
|
def initialize(backends)
|
32
33
|
super(nil)
|
@@ -34,7 +35,7 @@ module PuppetForgeServer::App
|
|
34
35
|
end
|
35
36
|
|
36
37
|
post '/v2/releases' do
|
37
|
-
halt 410, {
|
38
|
+
halt 410, json({:errors => ['File not provided']}) unless params['file']
|
38
39
|
states = @backends.map do |backend|
|
39
40
|
backend.upload(params['file'])
|
40
41
|
end.compact
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require 'sinatra/base'
|
18
|
+
require 'sinatra/json'
|
18
19
|
|
19
20
|
module PuppetForgeServer::App
|
20
21
|
class Version3 < Sinatra::Base
|
@@ -27,35 +28,38 @@ module PuppetForgeServer::App
|
|
27
28
|
use ::Rack::CommonLogger, PuppetForgeServer::Logger.get(:access)
|
28
29
|
end
|
29
30
|
|
30
|
-
before
|
31
|
-
|
32
|
-
|
31
|
+
before do
|
32
|
+
content_type :json
|
33
|
+
env['rack.errors'] = PuppetForgeServer::Logger.get(:server)
|
34
|
+
end
|
33
35
|
|
34
36
|
def initialize(backends)
|
35
37
|
super(nil)
|
36
38
|
@backends = backends
|
37
39
|
end
|
38
40
|
|
39
|
-
get '/v3/releases' do
|
40
|
-
halt
|
41
|
-
|
41
|
+
get '/v3/releases/:module' do
|
42
|
+
halt 404, json({:errors => ['404 Not found']}) unless params[:module]
|
42
43
|
author, name, version = params[:module].split '-'
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
halt 400, json({:errors => ["'#{params[:module]}' is not a valid release slug"]}) unless author && name && version
|
45
|
+
releases = releases(author, name, version)
|
46
|
+
halt 404, json({:errors => ['404 Not found']}) unless releases
|
47
|
+
PuppetForgeServer::Logger.get(:server).error "Requested releases count is more than 1:\n#{releases}" if releases.count > 1
|
48
|
+
json releases.first
|
49
|
+
end
|
48
50
|
|
49
|
-
|
50
|
-
{
|
51
|
+
get '/v3/releases' do
|
52
|
+
halt 400, json({:error => 'The number of version constraints in the query does not match the number of module names'}) unless params[:module]
|
53
|
+
author, name = params[:module].split '-'
|
54
|
+
releases = releases(author, name)
|
55
|
+
halt 404, json({:pagination => {:next => false}, :results => []}) unless releases
|
56
|
+
json :pagination => {:next => false, :total => releases.count}, :results => releases
|
51
57
|
end
|
52
58
|
|
53
59
|
get '/v3/files/*' do
|
54
60
|
captures = params[:captures].first
|
55
61
|
buffer = get_buffer(@backends, captures)
|
56
|
-
|
57
|
-
halt 404, {'errors' => ['404 Not found']}.to_json unless buffer
|
58
|
-
|
62
|
+
halt 404, json({:errors => ['404 Not found']}) unless buffer
|
59
63
|
content_type 'application/octet-stream'
|
60
64
|
attachment captures.split('/').last
|
61
65
|
download buffer
|
@@ -64,16 +68,20 @@ module PuppetForgeServer::App
|
|
64
68
|
get '/v3/modules/:author-:name' do
|
65
69
|
author = params[:author]
|
66
70
|
name = params[:name]
|
67
|
-
|
68
|
-
halt 400, {'errors' => "'#{params[:module]}' is not a valid module slug"}.to_json unless author && name
|
69
|
-
|
71
|
+
halt 400, json({:errors => "'#{params[:module]}' is not a valid module slug"}) unless author && name
|
70
72
|
metadata = @backends.map do |backend|
|
71
73
|
backend.get_metadata(author, name)
|
72
74
|
end.flatten.compact.uniq
|
75
|
+
halt 404, json({:errors => ['404 Not found']}) if metadata.empty?
|
76
|
+
json get_modules(metadata)
|
77
|
+
end
|
73
78
|
|
74
|
-
|
75
|
-
|
76
|
-
|
79
|
+
private
|
80
|
+
def releases(author, name, version = nil)
|
81
|
+
metadata = @backends.map do |backend|
|
82
|
+
backend.get_metadata(author, name, {:version => version})
|
83
|
+
end.flatten.compact.uniq
|
84
|
+
metadata.empty? ? nil : get_releases(metadata)
|
77
85
|
end
|
78
86
|
end
|
79
87
|
end
|
@@ -57,10 +57,15 @@ module PuppetForgeServer::Backends
|
|
57
57
|
releases
|
58
58
|
end
|
59
59
|
|
60
|
+
def normalize_metadata(metadata)
|
61
|
+
metadata['name'] = metadata['name'].gsub('/', '-')
|
62
|
+
metadata
|
63
|
+
end
|
64
|
+
|
60
65
|
def get_release_metadata(releases)
|
61
66
|
releases.map do |element|
|
62
67
|
{
|
63
|
-
:metadata => PuppetForgeServer::Models::Metadata.new(element['metadata']),
|
68
|
+
:metadata => PuppetForgeServer::Models::Metadata.new(normalize_metadata(element['metadata'])),
|
64
69
|
:checksum => element['file_md5'],
|
65
70
|
:path => element['file_uri'],
|
66
71
|
:tags => (element['tags'] + (element['metadata']['tags'] ? element['metadata']['tags'] : [])).flatten.uniq
|
@@ -23,8 +23,8 @@ module PuppetForgeServer
|
|
23
23
|
@@DEFAULT_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
24
24
|
@static_loggers = {:server => nil, :access => nil}
|
25
25
|
|
26
|
-
def initialize(destinations = [@@
|
27
|
-
@loggers =
|
26
|
+
def initialize(destinations = [@@DEFAULT_DESTINATION])
|
27
|
+
@loggers = [destinations].flatten.map do |dest|
|
28
28
|
logger = ::Logger.new(dest)
|
29
29
|
logger.formatter = proc do |severity, datetime, progname, msg|
|
30
30
|
datetime = datetime.strftime @@DEFAULT_DATETIME_FORMAT
|
@@ -45,7 +45,7 @@ module PuppetForgeServer
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def respond_to?(method_name, include_private = false)
|
48
|
-
@loggers.each { |logger| false unless logger.respond_to? method_name }
|
48
|
+
@loggers.each { |logger| return false unless (logger.respond_to?(method_name) || %w(write puts).include?(method_name.to_s)) }
|
49
49
|
end
|
50
50
|
|
51
51
|
class << self
|
@@ -17,6 +17,18 @@
|
|
17
17
|
|
18
18
|
require 'rubygems/package'
|
19
19
|
|
20
|
+
module Gem
|
21
|
+
def Version.new(version)
|
22
|
+
super(version.to_s.gsub('-', '.pre.'))
|
23
|
+
rescue ArgumentError
|
24
|
+
if version =~ /^\d+(\.\d+)*/
|
25
|
+
super(version[/^\d+(\.\d+)*/])
|
26
|
+
else
|
27
|
+
super('0')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
20
32
|
class Hash
|
21
33
|
def deep_merge(other)
|
22
34
|
merge(other) do |key, old_val, new_val|
|
@@ -42,8 +54,7 @@ class Array
|
|
42
54
|
|
43
55
|
def version_sort_by
|
44
56
|
sort_by do |element|
|
45
|
-
|
46
|
-
Gem::Version.new(version)
|
57
|
+
Gem::Version.new(yield(element))
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
data/puppet-forge-server.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.require_paths = %w(lib)
|
36
36
|
|
37
37
|
spec.add_dependency 'sinatra', '~> 1.4'
|
38
|
+
spec.add_dependency 'sinatra-contrib', '~> 1.4'
|
38
39
|
spec.add_dependency 'json', '~> 1.8'
|
39
40
|
spec.add_dependency 'rack-mount', '~> 0.8'
|
40
41
|
spec.add_dependency 'open4', '~> 1.3'
|
@@ -42,6 +43,7 @@ Gem::Specification.new do |spec|
|
|
42
43
|
|
43
44
|
spec.add_development_dependency 'rake', '~> 10.3'
|
44
45
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
46
|
+
spec.add_development_dependency 'rspec-core', '~> 3.1'
|
45
47
|
|
46
48
|
spec.required_ruby_version = '>= 1.9.3'
|
47
49
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 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 'rack/test'
|
18
|
+
require 'rspec'
|
19
|
+
require 'puppet_forge_server'
|
20
|
+
|
21
|
+
ENV['RACK_ENV'] = 'test'
|
22
|
+
|
23
|
+
module RSpecMixin
|
24
|
+
include Rack::Test::Methods
|
25
|
+
end
|
26
|
+
|
27
|
+
RSpec.configure do |c|
|
28
|
+
c.include RSpecMixin
|
29
|
+
c.add_formatter(:documentation)
|
30
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 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
|
20
|
+
describe Logger do
|
21
|
+
let(:msg) { 'this is a dummy message' }
|
22
|
+
let(:test_io) { StringIO.new }
|
23
|
+
let(:logger) { PuppetForgeServer::Logger.new(test_io) }
|
24
|
+
|
25
|
+
describe '#info' do
|
26
|
+
it 'should log message on level info' do
|
27
|
+
expect(logger).to respond_to(:info)
|
28
|
+
logger.info msg
|
29
|
+
expect(test_io.string).to include("INFO #{msg}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#error' do
|
34
|
+
it 'should log message on level error' do
|
35
|
+
expect(logger).to respond_to(:error)
|
36
|
+
logger.error msg
|
37
|
+
expect(test_io.string).to include("ERROR #{msg}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#warn' do
|
42
|
+
it 'should log message on level warn' do
|
43
|
+
expect(logger).to respond_to(:warn)
|
44
|
+
logger.warn msg
|
45
|
+
expect(test_io.string).to include("WARN #{msg}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#debug' do
|
50
|
+
it 'should log message on level debug' do
|
51
|
+
expect(logger).to respond_to(:debug)
|
52
|
+
logger.debug msg
|
53
|
+
expect(test_io.string).to include("DEBUG #{msg}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#puts' do
|
58
|
+
it 'should log message' do
|
59
|
+
expect(logger).to respond_to(:puts)
|
60
|
+
logger.puts msg
|
61
|
+
expect(test_io.string).to include(msg)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#<<' do
|
66
|
+
it 'should log message' do
|
67
|
+
expect(logger).to respond_to('<<')
|
68
|
+
logger << msg
|
69
|
+
expect(test_io.string).to include(msg)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#non_existing' do
|
74
|
+
it 'should fail on non existing method' do
|
75
|
+
expect { logger.non_existing }.to raise_error(NoMethodError)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 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::Models
|
20
|
+
describe Metadata do
|
21
|
+
let(:name) { 'dummy_name' }
|
22
|
+
let(:author) { 'dummy_author' }
|
23
|
+
let(:version) { '0.0.0' }
|
24
|
+
let(:project_page) { 'http://bogus-project-page.com' }
|
25
|
+
let(:metadata) { PuppetForgeServer::Models::Metadata.new({:name => name, :author => author, :version => version, :project_page => project_page}) }
|
26
|
+
describe '#initialize' do
|
27
|
+
it 'should create a metadata instance' do
|
28
|
+
expect(metadata.author).to eq author
|
29
|
+
expect(metadata.name).to eq name
|
30
|
+
expect(metadata.version).to eq version
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#hash' do
|
35
|
+
it 'should calculate hash from name, author and version' do
|
36
|
+
expect(metadata.hash).to eq(author.hash ^ name.hash ^ version.hash)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#eql?' do
|
41
|
+
it 'should be equal based only on name, author and version' do
|
42
|
+
metadata2 = metadata.clone
|
43
|
+
expect(metadata).to eq metadata2
|
44
|
+
metadata2.project_page = 'http://bogus-project-page2.com'
|
45
|
+
expect(metadata).to eq metadata2
|
46
|
+
metadata2.name = 'something_else'
|
47
|
+
expect(metadata).not_to eq metadata2
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 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
|
20
|
+
describe Server do
|
21
|
+
describe '#build' do
|
22
|
+
let(:server) { PuppetForgeServer::Server.new }
|
23
|
+
it 'builds rack routeset' do
|
24
|
+
routeset = server.build(nil)
|
25
|
+
expect(routeset.length).to eq 4
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
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
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilja Bobkevic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sinatra-contrib
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.4'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: json
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '3.1'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-core
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.1'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.1'
|
111
139
|
description: Private Puppet forge server supports local files, both v1 and v3 API
|
112
140
|
proxies
|
113
141
|
email: ilja.bobkevic@unibet.com
|
@@ -120,6 +148,7 @@ files:
|
|
120
148
|
- ".travis.yml"
|
121
149
|
- Gemfile
|
122
150
|
- README.md
|
151
|
+
- Rakefile
|
123
152
|
- bin/puppet-forge-server
|
124
153
|
- lib/puppet_forge_server.rb
|
125
154
|
- lib/puppet_forge_server/api/v1/modules.rb
|
@@ -148,6 +177,10 @@ files:
|
|
148
177
|
- lib/puppet_forge_server/utils/url.rb
|
149
178
|
- lib/puppet_forge_server/version.rb
|
150
179
|
- puppet-forge-server.gemspec
|
180
|
+
- spec/spec_helper.rb
|
181
|
+
- spec/unit/logger_spec.rb
|
182
|
+
- spec/unit/models/metadata_spec.rb
|
183
|
+
- spec/unit/server_spec.rb
|
151
184
|
homepage: https://github.com/unibet/puppet-forge-server
|
152
185
|
licenses:
|
153
186
|
- Apache 2
|
@@ -172,4 +205,8 @@ rubygems_version: 2.4.1
|
|
172
205
|
signing_key:
|
173
206
|
specification_version: 4
|
174
207
|
summary: Private Puppet forge server
|
175
|
-
test_files:
|
208
|
+
test_files:
|
209
|
+
- spec/spec_helper.rb
|
210
|
+
- spec/unit/logger_spec.rb
|
211
|
+
- spec/unit/models/metadata_spec.rb
|
212
|
+
- spec/unit/server_spec.rb
|