cheffish 4.0.0 → 4.1.0

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -8
  3. data/Rakefile +24 -12
  4. data/cheffish.gemspec +15 -15
  5. data/lib/chef/resource/chef_acl.rb +63 -63
  6. data/lib/chef/resource/chef_client.rb +9 -9
  7. data/lib/chef/resource/chef_container.rb +9 -9
  8. data/lib/chef/resource/chef_data_bag.rb +9 -9
  9. data/lib/chef/resource/chef_data_bag_item.rb +27 -27
  10. data/lib/chef/resource/chef_environment.rb +21 -22
  11. data/lib/chef/resource/chef_group.rb +19 -19
  12. data/lib/chef/resource/chef_mirror.rb +32 -17
  13. data/lib/chef/resource/chef_node.rb +14 -14
  14. data/lib/chef/resource/chef_organization.rb +29 -30
  15. data/lib/chef/resource/chef_resolved_cookbooks.rb +7 -7
  16. data/lib/chef/resource/chef_role.rb +25 -22
  17. data/lib/chef/resource/chef_user.rb +13 -14
  18. data/lib/chef/resource/private_key.rb +24 -25
  19. data/lib/chef/resource/public_key.rb +6 -7
  20. data/lib/cheffish.rb +17 -17
  21. data/lib/cheffish/array_property.rb +2 -2
  22. data/lib/cheffish/base_properties.rb +3 -3
  23. data/lib/cheffish/base_resource.rb +8 -8
  24. data/lib/cheffish/basic_chef_client.rb +17 -17
  25. data/lib/cheffish/chef_actor_base.rb +8 -8
  26. data/lib/cheffish/chef_run.rb +7 -2
  27. data/lib/cheffish/chef_run_data.rb +2 -2
  28. data/lib/cheffish/chef_run_listener.rb +1 -1
  29. data/lib/cheffish/key_formatter.rb +16 -18
  30. data/lib/cheffish/merged_config.rb +5 -3
  31. data/lib/cheffish/node_properties.rb +11 -7
  32. data/lib/cheffish/recipe_dsl.rb +33 -34
  33. data/lib/cheffish/rspec.rb +3 -3
  34. data/lib/cheffish/rspec/chef_run_support.rb +13 -13
  35. data/lib/cheffish/rspec/matchers.rb +4 -4
  36. data/lib/cheffish/rspec/matchers/be_idempotent.rb +3 -3
  37. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +3 -3
  38. data/lib/cheffish/rspec/matchers/have_updated.rb +3 -3
  39. data/lib/cheffish/rspec/recipe_run_wrapper.rb +8 -7
  40. data/lib/cheffish/rspec/repository_support.rb +6 -6
  41. data/lib/cheffish/server_api.rb +11 -11
  42. data/lib/cheffish/version.rb +1 -1
  43. data/spec/functional/fingerprint_spec.rb +12 -12
  44. data/spec/functional/merged_config_spec.rb +46 -6
  45. data/spec/functional/server_api_spec.rb +3 -3
  46. data/spec/integration/chef_acl_spec.rb +489 -489
  47. data/spec/integration/chef_client_spec.rb +39 -39
  48. data/spec/integration/chef_container_spec.rb +14 -14
  49. data/spec/integration/chef_data_bag_item_spec.rb +9 -9
  50. data/spec/integration/chef_group_spec.rb +219 -219
  51. data/spec/integration/chef_mirror_spec.rb +228 -228
  52. data/spec/integration/chef_node_spec.rb +511 -511
  53. data/spec/integration/chef_organization_spec.rb +126 -126
  54. data/spec/integration/chef_role_spec.rb +33 -33
  55. data/spec/integration/chef_user_spec.rb +37 -37
  56. data/spec/integration/private_key_spec.rb +154 -154
  57. data/spec/integration/recipe_dsl_spec.rb +10 -10
  58. data/spec/integration/rspec/converge_spec.rb +49 -49
  59. data/spec/support/key_support.rb +6 -6
  60. data/spec/support/spec_support.rb +3 -3
  61. data/spec/unit/get_private_key_spec.rb +19 -19
  62. data/spec/unit/recipe_run_wrapper_spec.rb +4 -4
  63. metadata +3 -3
@@ -1,25 +1,25 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
3
- require 'tmpdir'
1
+ require "support/spec_support"
2
+ require "cheffish/rspec/chef_run_support"
3
+ require "tmpdir"
4
4
 
5
- describe 'Cheffish Recipe DSL' do
5
+ describe "Cheffish Recipe DSL" do
6
6
  extend Cheffish::RSpec::ChefRunSupport
7
7
 
8
- context 'when we include with_chef_local_server' do
8
+ context "when we include with_chef_local_server" do
9
9
  before :each do
10
- @tmp_repo = tmp_repo = Dir.mktmpdir('chef_repo')
10
+ @tmp_repo = tmp_repo = Dir.mktmpdir("chef_repo")
11
11
  end
12
12
 
13
13
  after :each do
14
14
  FileUtils.remove_entry_secure @tmp_repo
15
15
  end
16
16
 
17
- it 'chef_nodes get put into said server' do
17
+ it "chef_nodes get put into said server" do
18
18
  tmp_repo = @tmp_repo
19
- expect_recipe {
19
+ expect_recipe do
20
20
  with_chef_local_server :chef_repo_path => tmp_repo
21
- chef_node 'blah'
22
- }.to have_updated 'chef_node[blah]', :create
21
+ chef_node "blah"
22
+ end.to have_updated "chef_node[blah]", :create
23
23
  expect(File).to exist("#{@tmp_repo}/nodes/blah.json")
24
24
  end
25
25
  end
@@ -1,20 +1,20 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
1
+ require "support/spec_support"
2
+ require "cheffish/rspec/chef_run_support"
3
3
 
4
- describe 'Cheffish::RSpec::ChefRunSupport' do
4
+ describe "Cheffish::RSpec::ChefRunSupport" do
5
5
  extend Cheffish::RSpec::ChefRunSupport
6
6
 
7
- let(:temp_file) { Tempfile.new('test') }
7
+ let(:temp_file) { Tempfile.new("test") }
8
8
 
9
9
  context "#recipe" do
10
10
  it "recipe { file ... } updates the file" do
11
- result = recipe {
11
+ result = recipe do
12
12
  file temp_file.path do
13
- content 'test'
13
+ content "test"
14
14
  end
15
- }
15
+ end
16
16
  expect(result.updated?).to be_falsey
17
- expect(IO.read(temp_file.path)).to eq ''
17
+ expect(IO.read(temp_file.path)).to eq ""
18
18
  end
19
19
 
20
20
  it "recipe 'file ...' does not update the file" do
@@ -24,29 +24,29 @@ describe 'Cheffish::RSpec::ChefRunSupport' do
24
24
  end
25
25
  EOM
26
26
  expect(result.updated?).to be_falsey
27
- expect(IO.read(temp_file.path)).to eq ''
27
+ expect(IO.read(temp_file.path)).to eq ""
28
28
  end
29
29
 
30
30
  it "recipe 'file ...' with file and line number does not update the file" do
31
- result = recipe(<<-EOM, __FILE__, __LINE__+1)
31
+ result = recipe(<<-EOM, __FILE__, __LINE__ + 1)
32
32
  file temp_file.path do
33
33
  content 'test'
34
34
  end
35
35
  EOM
36
36
  expect(result.updated?).to be_falsey
37
- expect(IO.read(temp_file.path)).to eq ''
37
+ expect(IO.read(temp_file.path)).to eq ""
38
38
  end
39
39
  end
40
40
 
41
41
  context "#converge" do
42
42
  it "converge { file ... } updates the file" do
43
- result = converge {
43
+ result = converge do
44
44
  file temp_file.path do
45
- content 'test'
45
+ content "test"
46
46
  end
47
- }
47
+ end
48
48
  expect(result.updated?).to be_truthy
49
- expect(IO.read(temp_file.path)).to eq 'test'
49
+ expect(IO.read(temp_file.path)).to eq "test"
50
50
  end
51
51
 
52
52
  it "converge 'file ...' updates the file" do
@@ -56,29 +56,29 @@ describe 'Cheffish::RSpec::ChefRunSupport' do
56
56
  end
57
57
  EOM
58
58
  expect(result.updated?).to be_truthy
59
- expect(IO.read(temp_file.path)).to eq 'test'
59
+ expect(IO.read(temp_file.path)).to eq "test"
60
60
  end
61
61
 
62
62
  it "converge 'file ...' with file and line number updates the file" do
63
- result = converge(<<-EOM, __FILE__, __LINE__+1)
63
+ result = converge(<<-EOM, __FILE__, __LINE__ + 1)
64
64
  file temp_file.path do
65
65
  content 'test'
66
66
  end
67
67
  EOM
68
68
  expect(result.updated?).to be_truthy
69
- expect(IO.read(temp_file.path)).to eq 'test'
69
+ expect(IO.read(temp_file.path)).to eq "test"
70
70
  end
71
71
  end
72
72
 
73
73
  context "#expect_recipe" do
74
74
  it "expect_recipe { file ... }.to be_updated updates the file, and be_idempotent does not fail" do
75
- expect_recipe {
75
+ expect_recipe do
76
76
  file temp_file.path do
77
- content 'test'
77
+ content "test"
78
78
  end
79
- }.to be_updated.and be_idempotent
79
+ end.to be_updated.and be_idempotent
80
80
 
81
- expect(IO.read(temp_file.path)).to eq 'test'
81
+ expect(IO.read(temp_file.path)).to eq "test"
82
82
  end
83
83
 
84
84
  it "expect_recipe 'file ...'.to be_updated updates the file, and be_idempotent does not fail" do
@@ -88,52 +88,52 @@ describe 'Cheffish::RSpec::ChefRunSupport' do
88
88
  end
89
89
  EOM
90
90
 
91
- expect(IO.read(temp_file.path)).to eq 'test'
91
+ expect(IO.read(temp_file.path)).to eq "test"
92
92
  end
93
93
 
94
94
  it "expect_recipe('file ...', file, line).to be_updated updates the file, and be_idempotent does not fail" do
95
- expect_recipe(<<-EOM, __FILE__, __LINE__+1).to be_updated.and be_idempotent
95
+ expect_recipe(<<-EOM, __FILE__, __LINE__ + 1).to be_updated.and be_idempotent
96
96
  file temp_file.path do
97
97
  content 'test'
98
98
  end
99
99
  EOM
100
100
 
101
- expect(IO.read(temp_file.path)).to eq 'test'
101
+ expect(IO.read(temp_file.path)).to eq "test"
102
102
  end
103
103
 
104
104
  it "expect_recipe { file ... }.to be_up_to_date fails" do
105
- expect {
106
- expect_recipe {
105
+ expect do
106
+ expect_recipe do
107
107
  file temp_file.path do
108
- content 'test'
108
+ content "test"
109
109
  end
110
- }.to be_up_to_date
111
- }.to raise_error RSpec::Expectations::ExpectationNotMetError
110
+ end.to be_up_to_date
111
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
112
112
  end
113
113
 
114
114
  it "expect_recipe { }.to be_updated fails" do
115
- expect {
116
- expect_recipe { }.to be_updated
117
- }.to raise_error RSpec::Expectations::ExpectationNotMetError
115
+ expect do
116
+ expect_recipe {}.to be_updated
117
+ end.to raise_error RSpec::Expectations::ExpectationNotMetError
118
118
  end
119
119
 
120
120
  it "expect_recipe { }.to be_up_to_date succeeds" do
121
- expect_recipe { }.to be_up_to_date
121
+ expect_recipe {}.to be_up_to_date
122
122
  end
123
123
 
124
124
  it "expect_recipe { }.to be_idempotent succeeds" do
125
- expect_recipe { }.to be_idempotent
125
+ expect_recipe {}.to be_idempotent
126
126
  end
127
127
  end
128
128
 
129
129
  context "#expect_converge" do
130
130
  it "expect_converge { file ... }.not_to raise_error updates the file" do
131
- expect_converge {
131
+ expect_converge do
132
132
  file temp_file.path do
133
- content 'test'
133
+ content "test"
134
134
  end
135
- }.not_to raise_error
136
- expect(IO.read(temp_file.path)).to eq 'test'
135
+ end.not_to raise_error
136
+ expect(IO.read(temp_file.path)).to eq "test"
137
137
  end
138
138
 
139
139
  it "expect_converge('file ...').not_to raise_error updates the file" do
@@ -142,22 +142,22 @@ describe 'Cheffish::RSpec::ChefRunSupport' do
142
142
  content 'test'
143
143
  end
144
144
  EOM
145
- expect(IO.read(temp_file.path)).to eq 'test'
145
+ expect(IO.read(temp_file.path)).to eq "test"
146
146
  end
147
147
 
148
148
  it "expect_converge('file ...', file, line).not_to raise_error updates the file" do
149
- expect_converge(<<-EOM, __FILE__, __LINE__+1).not_to raise_error
149
+ expect_converge(<<-EOM, __FILE__, __LINE__ + 1).not_to raise_error
150
150
  file temp_file.path do
151
151
  content 'test'
152
152
  end
153
153
  EOM
154
- expect(IO.read(temp_file.path)).to eq 'test'
154
+ expect(IO.read(temp_file.path)).to eq "test"
155
155
  end
156
156
 
157
157
  it "expect_converge { raise 'oh no' }.to raise_error passes" do
158
- expect_converge {
159
- raise 'oh no'
160
- }.to raise_error('oh no')
158
+ expect_converge do
159
+ raise "oh no"
160
+ end.to raise_error("oh no")
161
161
  end
162
162
  end
163
163
 
@@ -168,16 +168,16 @@ describe 'Cheffish::RSpec::ChefRunSupport' do
168
168
  # Capture the variable outside
169
169
  x = nil
170
170
  converge { x = let_variable }
171
- expect(x).to eq 'test'
171
+ expect(x).to eq "test"
172
172
  end
173
173
 
174
174
  it "converge with a file resource referencing let_variable accesses let_variable" do
175
- converge {
175
+ converge do
176
176
  file temp_file.path do
177
177
  content let_variable
178
178
  end
179
- }
180
- expect(IO.read(temp_file.path)).to eq 'test'
179
+ end
180
+ expect(IO.read(temp_file.path)).to eq "test"
181
181
  end
182
182
  end
183
183
  end
@@ -7,8 +7,8 @@ RSpec::Matchers.define :be_public_key_for do |private_key, pass_phrase|
7
7
  private_key, private_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(private_key)), pass_phrase, private_key)
8
8
  end
9
9
 
10
- encrypted = public_key.public_encrypt('hi there')
11
- expect(private_key.private_decrypt(encrypted)).to eq('hi there')
10
+ encrypted = public_key.public_encrypt("hi there")
11
+ expect(private_key.private_decrypt(encrypted)).to eq("hi there")
12
12
  end
13
13
  end
14
14
 
@@ -21,9 +21,9 @@ RSpec::Matchers.define :match_private_key do |expected, pass_phrase|
21
21
  actual, format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(actual)), pass_phrase, actual)
22
22
  end
23
23
 
24
- encrypted = actual.public_encrypt('hi there')
25
- expect(expected.private_decrypt(encrypted)).to eq('hi there')
26
- encrypted = expected.public_encrypt('hi there')
27
- expect(actual.private_decrypt(encrypted)).to eq('hi there')
24
+ encrypted = actual.public_encrypt("hi there")
25
+ expect(expected.private_decrypt(encrypted)).to eq("hi there")
26
+ encrypted = expected.public_encrypt("hi there")
27
+ expect(actual.private_decrypt(encrypted)).to eq("hi there")
28
28
  end
29
29
  end
@@ -1,6 +1,6 @@
1
- require 'cheffish/rspec'
1
+ require "cheffish/rspec"
2
2
 
3
- require 'cheffish'
3
+ require "cheffish"
4
4
 
5
5
  RSpec.configure do |config|
6
6
  config.filter_run :focus => true
@@ -11,4 +11,4 @@ RSpec.configure do |config|
11
11
  end
12
12
  end
13
13
 
14
- require 'chef/providers'
14
+ require "chef/providers"
@@ -1,16 +1,16 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
1
+ require "support/spec_support"
2
+ require "cheffish/rspec/chef_run_support"
3
3
 
4
4
  describe Cheffish do
5
- let(:directory_that_exists) {
5
+ let(:directory_that_exists) do
6
6
  Dir.mktmpdir("cheffish-rspec")
7
- }
7
+ end
8
8
 
9
- let(:directory_that_does_not_exist) {
9
+ let(:directory_that_does_not_exist) do
10
10
  dir = Dir.mktmpdir("cheffish-rspec")
11
11
  FileUtils.remove_entry dir
12
12
  dir
13
- }
13
+ end
14
14
 
15
15
  let(:private_key_contents) { "contents of private key" }
16
16
 
@@ -80,9 +80,9 @@ describe Cheffish do
80
80
 
81
81
  describe "#get_private_key" do
82
82
  context "when private_key_paths has a directory which is empty" do
83
- let(:config) {
83
+ let(:config) do
84
84
  { :private_key_paths => [ directory_that_exists ] }
85
- }
85
+ end
86
86
 
87
87
  it_behaves_like "returning the contents of the key file if it finds one"
88
88
 
@@ -100,17 +100,17 @@ describe Cheffish do
100
100
  end
101
101
 
102
102
  context "when private_key_paths leads with a directory that does not exist and then an empty directory" do
103
- let(:config) {
103
+ let(:config) do
104
104
  { :private_key_paths => [ directory_that_does_not_exist, directory_that_exists ] }
105
- }
105
+ end
106
106
 
107
107
  it_behaves_like "returning the contents of the key file if it finds one"
108
108
  end
109
109
 
110
110
  context "when private_keys is empty" do
111
- let(:config) {
111
+ let(:config) do
112
112
  { :private_keys => {} }
113
- }
113
+ end
114
114
 
115
115
  it "returns nil" do
116
116
  expect(Cheffish.get_private_key("ned_stark", config)).to be_nil
@@ -119,9 +119,9 @@ describe Cheffish do
119
119
 
120
120
  context "when private_keys contains the path to a key" do
121
121
  let(:name) { "ned_stark" }
122
- let(:config) {
123
- { :private_keys => {name => setup_key} }
124
- }
122
+ let(:config) do
123
+ { :private_keys => { name => setup_key } }
124
+ end
125
125
 
126
126
  it "returns the contents of the key file" do
127
127
  setup_key
@@ -131,10 +131,10 @@ describe Cheffish do
131
131
 
132
132
  context "when private_keys contains the path to a key" do
133
133
  let(:name) { "ned_stark" }
134
- let(:key) {double("key", :to_pem => private_key_contents)}
135
- let(:config) {
136
- { :private_keys => {name => key} }
137
- }
134
+ let(:key) { double("key", :to_pem => private_key_contents) }
135
+ let(:config) do
136
+ { :private_keys => { name => key } }
137
+ end
138
138
 
139
139
  it "returns the contents of the key file" do
140
140
  expect(Cheffish.get_private_key(name, config)).to eq(private_key_contents)
@@ -1,5 +1,5 @@
1
- require 'support/spec_support'
2
- require 'cheffish/rspec/chef_run_support'
1
+ require "support/spec_support"
2
+ require "cheffish/rspec/chef_run_support"
3
3
  # require 'cheffish/rspec/recipe_run_wrapper'
4
4
 
5
5
  module MyModule
@@ -15,11 +15,11 @@ end
15
15
  describe Cheffish::RSpec::RecipeRunWrapper do
16
16
  extend Cheffish::RSpec::ChefRunSupport
17
17
 
18
- let(:run_wrapper) {
18
+ let(:run_wrapper) do
19
19
  Cheffish::RSpec::RecipeRunWrapper.new(chef_config) do
20
20
  log "test recipe in specs"
21
21
  end
22
- }
22
+ end
23
23
 
24
24
  context "defines #respond_to_missing? on the client" do
25
25
  it "calls the new super.respond_to_missing" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheffish
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-zero
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.6.6
133
+ rubygems_version: 2.5.1
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: A library to manipulate Chef in Chef.