berkshelf 8.0.5 → 8.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef3b782c88bc9fe560b6c02c84ab32f6df5e2bf39d3c4b56d441079952e56a96
4
- data.tar.gz: bd6f6b271645d42e62c29fa74e3a7d4633533b8dd104e386d064374d175dd27e
3
+ metadata.gz: 80b38fc167aeaac8e33a0219cc4ada1bf3e1614a5553294cabfdc7460c5f56b6
4
+ data.tar.gz: 4f642360c7e11c3946c8463cd422dd2279a27f3bcf6512481183dd55e98613d8
5
5
  SHA512:
6
- metadata.gz: 8f9111b9f7a17c8dd8a65463e963a4a6f5c662d3affd9cec1125f90b0d5d71b7a742ef51e6b50161791cdd94f920acd2240ba2fc1472054f596d2e7dd1b18d25
7
- data.tar.gz: d5113a1ebeb056843f92b6ae6e25d6850127e257cea2596a4c7bc55d42ba8f81c76388c8451a5fca126231f029271b6f6197e57504fa201113219721aef0a619
6
+ metadata.gz: 452b88f63d021f69c75c196f3bd39e1e4f4595e208d75b1f88bc190964c79d05ce8fabc03726884d22396072c00c63fd8423194b495054e96c46cc9439d11bc7
7
+ data.tar.gz: d05010ba4e991b5300b1bda01f1efc73f797e1f85af0666095ff633524f1e3ec54ab650a0ecb81bd59402fd100f6249af7e7fa31f36d526192d88212b32ac5fa
data/berkshelf.gemspec CHANGED
@@ -42,7 +42,11 @@ Gem::Specification.new do |s|
42
42
  s.add_dependency "octokit", "~> 4.0"
43
43
  s.add_dependency "mixlib-archive", ">= 1.1.4", "< 2.0" # needed for ruby 3.0 / Dir.chdir removal
44
44
  s.add_dependency "concurrent-ruby", "~> 1.0"
45
- s.add_dependency "chef", ">= 15.7.32" # needed for --skip-syntax-check
45
+ if RUBY_VERSION.match?(/3.0/)
46
+ s.add_dependency "chef", "~> 17.0" # needed for --skip-syntax-check
47
+ elsif
48
+ s.add_dependency "chef", ">= 15.7.32"
49
+ end
46
50
  s.add_dependency "chef-config"
47
51
  # this is required for Mixlib::Config#from_json
48
52
  s.add_dependency "mixlib-config", ">= 2.2.5"
@@ -16,7 +16,7 @@ module Berkshelf
16
16
  def add_trusted_cert(cert)
17
17
  @store.add_cert(cert)
18
18
  rescue OpenSSL::X509::StoreError => e
19
- raise e unless e.message == "cert already in hash table"
19
+ raise e unless e.message.match(/cert already in hash table/)
20
20
  end
21
21
 
22
22
  def trusted_certs_dir
@@ -1,3 +1,5 @@
1
+ require 'chef/version_class'
2
+
1
3
  module Berkshelf
2
4
  module Validator
3
5
  class << self
@@ -25,10 +27,19 @@ module Berkshelf
25
27
  base, name = Pathname.new(cookbook.path.to_s).split
26
28
 
27
29
  files = Dir.glob("#{name}/**/*.rb", base: base.to_s).select { |f| f =~ /[[:space:]]/ }
30
+ validate_versions(cookbook)
28
31
 
29
32
  raise InvalidCookbookFiles.new(cookbook, files) unless files.empty?
30
33
  end
31
34
  end
35
+
36
+ def validate_versions(cookbook)
37
+ cookbook_dependencies = cookbook.dependencies
38
+ cookbook_dependencies.each do |cookbook_name, cookbook_version|
39
+ version = cookbook_version.gsub(/[^\d,\.]/, '')
40
+ Chef::Version.new(version)
41
+ end
42
+ end
32
43
  end
33
44
  end
34
45
  end
@@ -1,3 +1,3 @@
1
1
  module Berkshelf
2
- VERSION = "8.0.5".freeze
2
+ VERSION = "8.0.9".freeze
3
3
  end
@@ -130,17 +130,17 @@ describe Berkshelf::APIClient::Connection do
130
130
  end
131
131
 
132
132
  it "raises Berkshelf::APIClient::ServiceUnavailable for 500s" do
133
- stub_request(:get, "http://supermarket.getchef.com/universe").to_return(status: [500, "Internal Server Error"])
133
+ stub_request(:get, "http://supermarket.getchef.com/universe").to_return(status: 500, body: "Internal Server Error")
134
134
  expect { subject }.to raise_error(Berkshelf::APIClient::ServiceUnavailable)
135
135
  end
136
136
 
137
137
  it "raises Berkshelf::APIClient::ServiceNotFound for 404s" do
138
- stub_request(:get, "http://supermarket.getchef.com/universe").to_return(status: [404, "Not Found"])
138
+ stub_request(:get, "http://supermarket.getchef.com/universe").to_return(status: 404, body: "Not Found")
139
139
  expect { subject }.to raise_error(Berkshelf::APIClient::ServiceNotFound)
140
140
  end
141
141
 
142
142
  it "raises Net::HTTPBadRequest for 400s" do
143
- stub_request(:get, "http://supermarket.getchef.com/universe").to_return(status: [400, "Bad Request"])
143
+ stub_request(:get, "http://supermarket.getchef.com/universe").to_return(status: 400, body: "Bad Request")
144
144
  expect { subject }.to raise_error(Berkshelf::APIClient::BadResponse)
145
145
  end
146
146
 
@@ -107,7 +107,7 @@ describe Berkshelf::CommunityREST do
107
107
  it "raises a CookbookNotFound error on a 404 response for a non-existent cookbook" do
108
108
  stub_request(:get, "#{api_uri}/cookbooks/not_real/versions/1_0_0").to_return(
109
109
  status: 404,
110
- body: nil
110
+ body: "Not Found"
111
111
  )
112
112
 
113
113
  expect do
@@ -142,7 +142,7 @@ describe Berkshelf::CommunityREST do
142
142
  it "raises a CookbookNotFound error on a 404 response" do
143
143
  stub_request(:get, "#{api_uri}/cookbooks/not_real").to_return(
144
144
  status: 404,
145
- body: nil
145
+ body: "Not Found"
146
146
  )
147
147
 
148
148
  expect do
@@ -177,7 +177,7 @@ describe Berkshelf::CommunityREST do
177
177
  it "raises a CookbookNotFound error on a 404 response" do
178
178
  stub_request(:get, "#{api_uri}/cookbooks/not_real").to_return(
179
179
  status: 404,
180
- body: nil
180
+ body: "Not Found"
181
181
  )
182
182
 
183
183
  expect do
@@ -6,6 +6,7 @@ describe Berkshelf::Validator do
6
6
 
7
7
  it "raises an error when the cookbook has spaces in the files" do
8
8
  allow(Dir).to receive(:glob).and_return(["/there are/spaces/in this/recipes/default.rb"])
9
+ allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1.0.0"})
9
10
  expect do
10
11
  subject.validate_files(cookbook)
11
12
  end.to raise_error(Berkshelf::InvalidCookbookFiles)
@@ -13,6 +14,21 @@ describe Berkshelf::Validator do
13
14
 
14
15
  it "does not raise an error when the cookbook is valid" do
15
16
  allow(Dir).to receive(:glob).and_return(["/there-are/no-spaces/in-this/recipes/default.rb"])
17
+ allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1.0.0"})
18
+ expect do
19
+ subject.validate_files(cookbook)
20
+ end.to_not raise_error
21
+ end
22
+
23
+ it "raises an error when the cookbook version is not valid" do
24
+ allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1"})
25
+ expect do
26
+ subject.validate_files(cookbook)
27
+ end.to raise_error
28
+ end
29
+
30
+ it "does not raise an error when the cookbook version is valid" do
31
+ allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1.0"})
16
32
  expect do
17
33
  subject.validate_files(cookbook)
18
34
  end.to_not raise_error
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.5
4
+ version: 8.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-10-27 00:00:00.000000000 Z
15
+ date: 2023-09-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mixlib-shellout