cheffish 14.0.1 → 14.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +20 -1
  3. data/Rakefile +27 -32
  4. data/cheffish.gemspec +4 -4
  5. data/lib/chef/resource/chef_acl.rb +4 -4
  6. data/lib/chef/resource/chef_data_bag_item.rb +4 -4
  7. data/lib/chef/resource/chef_mirror.rb +10 -10
  8. data/lib/chef/resource/chef_organization.rb +2 -2
  9. data/lib/chef/resource/chef_resolved_cookbooks.rb +7 -7
  10. data/lib/chef/resource/chef_user.rb +3 -3
  11. data/lib/chef/resource/private_key.rb +3 -3
  12. data/lib/chef/resource/public_key.rb +2 -2
  13. data/lib/cheffish.rb +7 -7
  14. data/lib/cheffish/base_resource.rb +1 -1
  15. data/lib/cheffish/basic_chef_client.rb +1 -2
  16. data/lib/cheffish/chef_actor_base.rb +6 -6
  17. data/lib/cheffish/chef_run.rb +2 -2
  18. data/lib/cheffish/key_formatter.rb +1 -1
  19. data/lib/cheffish/merged_config.rb +1 -1
  20. data/lib/cheffish/node_properties.rb +1 -1
  21. data/lib/cheffish/recipe_dsl.rb +2 -2
  22. data/lib/cheffish/rspec/chef_run_support.rb +3 -3
  23. data/lib/cheffish/rspec/matchers/have_updated.rb +2 -2
  24. data/lib/cheffish/version.rb +1 -1
  25. data/spec/functional/fingerprint_spec.rb +27 -27
  26. data/spec/functional/merged_config_spec.rb +9 -9
  27. data/spec/functional/server_api_spec.rb +1 -1
  28. data/spec/integration/chef_acl_spec.rb +16 -18
  29. data/spec/integration/chef_client_spec.rb +3 -3
  30. data/spec/integration/chef_mirror_spec.rb +16 -16
  31. data/spec/integration/chef_node_spec.rb +4 -4
  32. data/spec/integration/chef_role_spec.rb +2 -2
  33. data/spec/integration/chef_user_spec.rb +3 -3
  34. data/spec/integration/private_key_spec.rb +2 -2
  35. data/spec/integration/recipe_dsl_spec.rb +2 -2
  36. data/spec/support/key_support.rb +4 -4
  37. data/spec/support/spec_support.rb +1 -1
  38. data/spec/unit/get_private_key_spec.rb +6 -6
  39. metadata +6 -8
  40. data/README.md +0 -120
@@ -25,7 +25,7 @@ describe Chef::Resource::ChefNode do
25
25
 
26
26
  context "and another chef server is running on port 8899" do
27
27
  before :each do
28
- @server = ChefZero::Server.new(:port => 8899)
28
+ @server = ChefZero::Server.new(port: 8899)
29
29
  @server.start_background
30
30
  end
31
31
 
@@ -50,7 +50,7 @@ describe Chef::Resource::ChefNode do
50
50
  it "the node is created on the second chef server but not the first" do
51
51
  expect_recipe do
52
52
  chef_node "blah" do
53
- chef_server({ :chef_server_url => "http://127.0.0.1:8899" })
53
+ chef_server({ chef_server_url: "http://127.0.0.1:8899" })
54
54
  end
55
55
  end.to have_updated "chef_node[blah]", :create
56
56
  expect { get("nodes/blah") }.to raise_error(Net::HTTPServerException)
@@ -394,7 +394,7 @@ describe Chef::Resource::ChefNode do
394
394
  attribute %w{a b}, "x"
395
395
  end
396
396
  end
397
- end.to raise_error /Attempt to set \["a", "b"\] to x when \["a"\] is not a hash/
397
+ end.to raise_error(/Attempt to set \["a", "b"\] to x when \["a"\] is not a hash/)
398
398
  end
399
399
 
400
400
  it "chef_node with attribute [ a, b, c ], x raises an error" do
@@ -404,7 +404,7 @@ describe Chef::Resource::ChefNode do
404
404
  attribute %w{a b c}, "x"
405
405
  end
406
406
  end
407
- end.to raise_error /Attempt to set \["a", "b", "c"\] to x when \["a"\] is not a hash/
407
+ end.to raise_error(/Attempt to set \["a", "b", "c"\] to x when \["a"\] is not a hash/)
408
408
  end
409
409
 
410
410
  it "chef_node with attribute [ x, y ], z adds a new attribute" do
@@ -25,7 +25,7 @@ describe Chef::Resource::ChefRole do
25
25
 
26
26
  context "and another chef server is running on port 8899" do
27
27
  before :each do
28
- @server = ChefZero::Server.new(:port => 8899)
28
+ @server = ChefZero::Server.new(port: 8899)
29
29
  @server.start_background
30
30
  end
31
31
 
@@ -50,7 +50,7 @@ describe Chef::Resource::ChefRole do
50
50
  it "the role is created on the second chef server but not the first" do
51
51
  expect_recipe do
52
52
  chef_role "blah" do
53
- chef_server({ :chef_server_url => "http://127.0.0.1:8899" })
53
+ chef_server({ chef_server_url: "http://127.0.0.1:8899" })
54
54
  end
55
55
  end.to have_updated "chef_role[blah]", :create
56
56
  expect { get("roles/blah") }.to raise_error(Net::HTTPServerException)
@@ -21,7 +21,7 @@ describe Chef::Resource::ChefUser do
21
21
  end.to have_updated "chef_user[blah]", :create
22
22
  user = get("/users/blah")
23
23
  expect(user["name"]).to eq("blah")
24
- key, format = Cheffish::KeyFormatter.decode(user["public_key"])
24
+ key, _format = Cheffish::KeyFormatter.decode(user["public_key"])
25
25
  expect(key).to be_public_key_for("#{repo_path}/blah.pem")
26
26
  end
27
27
  end
@@ -52,7 +52,7 @@ describe Chef::Resource::ChefUser do
52
52
  end.to have_updated "chef_user[blah]", :create
53
53
  user = get("/users/blah")
54
54
  expect(user["name"]).to eq("blah")
55
- key, format = Cheffish::KeyFormatter.decode(user["public_key"])
55
+ key, _format = Cheffish::KeyFormatter.decode(user["public_key"])
56
56
  expect(key).to be_public_key_for("#{repo_path}/blah.pem")
57
57
  end
58
58
  end
@@ -74,7 +74,7 @@ describe Chef::Resource::ChefUser do
74
74
  end.to have_updated "chef_user[blah]", :create
75
75
  user = get("/users/blah")
76
76
  expect(user["name"]).to eq("blah")
77
- key, format = Cheffish::KeyFormatter.decode(user["public_key"])
77
+ key, _format = Cheffish::KeyFormatter.decode(user["public_key"])
78
78
  expect(key).to be_public_key_for("#{repo_path}/blah.pem")
79
79
  end
80
80
  end
@@ -150,7 +150,7 @@ describe Chef::Resource::PrivateKey do
150
150
  end
151
151
 
152
152
  it "and another public_key based off the first public_key in-memory in a key, the second public_key is created" do
153
- key, format = Cheffish::KeyFormatter.decode(IO.read("#{repo_path}/blah.pub"))
153
+ key, _format = Cheffish::KeyFormatter.decode(IO.read("#{repo_path}/blah.pub"))
154
154
 
155
155
  expect_recipe do
156
156
  public_key "#{repo_path}/blah.pub2" do
@@ -293,7 +293,7 @@ describe Chef::Resource::PrivateKey do
293
293
  converge do
294
294
  private_key "#{repo_path}/blah"
295
295
  end
296
- end.to raise_error /missing pass phrase?/
296
+ end.to raise_error(/missing pass phrase?/)
297
297
  end
298
298
  end
299
299
 
@@ -7,7 +7,7 @@ describe "Cheffish Recipe DSL" do
7
7
 
8
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 = Dir.mktmpdir("chef_repo")
11
11
  end
12
12
 
13
13
  after :each do
@@ -17,7 +17,7 @@ describe "Cheffish Recipe DSL" do
17
17
  it "chef_nodes get put into said server" do
18
18
  tmp_repo = @tmp_repo
19
19
  expect_recipe do
20
- with_chef_local_server :chef_repo_path => tmp_repo
20
+ with_chef_local_server chef_repo_path: tmp_repo
21
21
  chef_node "blah"
22
22
  end.to have_updated "chef_node[blah]", :create
23
23
  expect(File).to exist("#{@tmp_repo}/nodes/blah.json")
@@ -1,10 +1,10 @@
1
1
  RSpec::Matchers.define :be_public_key_for do |private_key, pass_phrase|
2
2
  match do |public_key|
3
3
  if public_key.is_a?(String)
4
- public_key, public_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(public_key)), pass_phrase, public_key)
4
+ public_key, _public_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(public_key)), pass_phrase, public_key)
5
5
  end
6
6
  if private_key.is_a?(String)
7
- private_key, private_key_format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(private_key)), pass_phrase, private_key)
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
10
  encrypted = public_key.public_encrypt("hi there")
@@ -15,10 +15,10 @@ end
15
15
  RSpec::Matchers.define :match_private_key do |expected, pass_phrase|
16
16
  match do |actual|
17
17
  if expected.is_a?(String)
18
- expected, format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(expected)), pass_phrase, expected)
18
+ expected, _format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(expected)), pass_phrase, expected)
19
19
  end
20
20
  if actual.is_a?(String)
21
- actual, format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(actual)), pass_phrase, actual)
21
+ actual, _format = Cheffish::KeyFormatter.decode(IO.read(File.expand_path(actual)), pass_phrase, actual)
22
22
  end
23
23
 
24
24
  encrypted = actual.public_encrypt("hi there")
@@ -3,7 +3,7 @@ require "cheffish/rspec"
3
3
  require "cheffish"
4
4
 
5
5
  RSpec.configure do |config|
6
- config.filter_run :focus => true
6
+ config.filter_run focus: true
7
7
  config.run_all_when_everything_filtered = true
8
8
 
9
9
  config.before :each do
@@ -81,7 +81,7 @@ describe Cheffish do
81
81
  describe "#get_private_key" do
82
82
  context "when private_key_paths has a directory which is empty" do
83
83
  let(:config) do
84
- { :private_key_paths => [ directory_that_exists ] }
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"
@@ -101,7 +101,7 @@ describe Cheffish do
101
101
 
102
102
  context "when private_key_paths leads with a directory that does not exist and then an empty directory" do
103
103
  let(:config) do
104
- { :private_key_paths => [ directory_that_does_not_exist, directory_that_exists ] }
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"
@@ -109,7 +109,7 @@ describe Cheffish do
109
109
 
110
110
  context "when private_keys is empty" do
111
111
  let(:config) do
112
- { :private_keys => {} }
112
+ { private_keys: {} }
113
113
  end
114
114
 
115
115
  it "returns nil" do
@@ -120,7 +120,7 @@ describe Cheffish do
120
120
  context "when private_keys contains the path to a key" do
121
121
  let(:name) { "ned_stark" }
122
122
  let(:config) do
123
- { :private_keys => { name => setup_key } }
123
+ { private_keys: { name => setup_key } }
124
124
  end
125
125
 
126
126
  it "returns the contents of the key file" do
@@ -131,9 +131,9 @@ 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) }
134
+ let(:key) { double("key", to_pem: private_key_contents) }
135
135
  let(:config) do
136
- { :private_keys => { name => key } }
136
+ { private_keys: { name => key } }
137
137
  end
138
138
 
139
139
  it "returns the contents of the key file" 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: 14.0.1
4
+ version: 14.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-23 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-zero
@@ -42,13 +42,10 @@ description: A library to manipulate Chef in Chef.
42
42
  email: jkeiser@chef.io
43
43
  executables: []
44
44
  extensions: []
45
- extra_rdoc_files:
46
- - README.md
47
- - LICENSE
45
+ extra_rdoc_files: []
48
46
  files:
49
47
  - Gemfile
50
48
  - LICENSE
51
- - README.md
52
49
  - Rakefile
53
50
  - cheffish.gemspec
54
51
  - lib/chef/resource/chef_acl.rb
@@ -111,8 +108,9 @@ files:
111
108
  - spec/support/spec_support.rb
112
109
  - spec/unit/get_private_key_spec.rb
113
110
  - spec/unit/recipe_run_wrapper_spec.rb
114
- homepage: http://github.com/chef/cheffish
115
- licenses: []
111
+ homepage: https://github.com/chef/cheffish
112
+ licenses:
113
+ - Apache-2.0
116
114
  metadata: {}
117
115
  post_install_message:
118
116
  rdoc_options: []
data/README.md DELETED
@@ -1,120 +0,0 @@
1
- # Cheffish
2
-
3
- [![Status](https://travis-ci.org/chef/cheffish.svg?branch=master)](https://travis-ci.org/chef/cheffish)
4
- [![Gem Version](https://badge.fury.io/rb/cheffish.svg)](http://badge.fury.io/rb/cheffish)
5
-
6
- This library provides a variety of convergent resources for interacting with the Chef Server; along the way, it happens to provide some very useful and sophisticated ways of running Chef resources as recipes in RSpec examples.
7
-
8
- **This document may have errors, but it should have enough pointers to get you oriented.**
9
-
10
- There are essentially 3 collections here:
11
-
12
- ## Resource/Provider Pairs for Manipulating Chef Servers
13
-
14
- You'd use these in recipes/cookbooks. They are documented on the [main Chef docs site](https://docs.chef.io).
15
-
16
- - [chef_acl](https://docs.chef.io/resource_chef_acl.html)
17
- - [chef_client](https://docs.chef.io/resource_chef_client.html)
18
- - [chef_container](https://docs.chef.io/resource_chef_container.html)
19
- - [chef_data_bag](https://docs.chef.io/resource_chef_data_bag.html)
20
- - [chef_data_bag_item](https://docs.chef.io/resource_chef_data_bag_item.html)
21
- - [chef_environment](https://docs.chef.io/resource_chef_environment.html)
22
- - [chef_group](https://docs.chef.io/resource_chef_group.html)
23
- - [chef_mirror](https://docs.chef.io/resource_chef_mirror.html)
24
- - [chef_node](https://docs.chef.io/resource_chef_node.html)
25
- - [chef_organization](https://docs.chef.io/resource_chef_organization.html)
26
- - [chef_resolved_cookbooks](https://docs.chef.io/resource_chef_resolved_cookbooks.html)
27
- - [chef_role](https://docs.chef.io/resource_chef_role.html)
28
- - [chef_user](https://docs.chef.io/resource_chef_user.html)
29
- - [private_key](https://docs.chef.io/resource_private_key.html)
30
- - [public_key](https://docs.chef.io/resource_public_key.html)
31
-
32
- ## Base/Helper Classes
33
-
34
- To support the resource/provider pairs.
35
-
36
-
37
- ## RSpec Support
38
-
39
- Most of these RSpec...things were developed for testing the resource/provider pairs above; *however*, you can also `require cheffish/rspec/chef_run_support` for any RSpec `expect`s you'd like, as we do for `chef-provisioning` and its drivers (especially `chef-provisioning-aws`).
40
-
41
- The awesomeness here is that instead of instantiating a `run_context` and a `node` and a `resource` as Ruby objects, you can test your resources in an actual recipe:
42
-
43
- ```ruby
44
- when_the_chef_12_server "exists", organization: 'some-org', server_scope: :context, port: 8900..9000 do
45
- file "/tmp/something_important.json" do
46
- content "A resource in its native environment."
47
- end
48
- end
49
- ```
50
-
51
- An enclosing context that spins up `chef-zero` (local mode) Chef servers as dictated by `server_scope`. `Chef::Config` will be set up with the appropriate server URLs (see the `with_*` operators below).
52
-
53
- `server_scope`:
54
- - `:context`
55
- - `:example` *[default?]*
56
- - ?
57
-
58
- `port`:
59
- - port number (8900 is the default)
60
- - port range (server will continue trying up this range until it finds a free port)
61
-
62
- ```ruby
63
- expect_recipe {
64
- # unquoted recipe DSL here.
65
- }.to be_truthy # or write your own matchers.
66
- ```
67
-
68
- Converges the recipe using `expect()` (parentheses), which tests for a value and **cannot** be used with `raise_error`.
69
-
70
- ```ruby
71
- expect_converge {
72
- # unquoted recipe DSL here.
73
- }.to raise_error(ArgumentException)
74
- ```
75
-
76
- Converges the recipe using `expect{ }` (curly brackets), which wraps the block in a `begin..rescue..end` to detect when the block raises an exception; hence, this is **only** for `raise_error`.
77
-
78
- The blocks for the following appear to be mostly optional: what they actually do is set the `Chef::Config` variable in the name to the given value, and if you provide a block, the change is scoped to that block. Probably this would be clearer if it were aliased to (and preferring) `using` rather than `with`.
79
-
80
- - with_chef_server(server_url, options = {}, &block)
81
- - with_chef_local_server(options, &block)
82
- - with_chef_environment(name, &block)
83
- - with_chef_data_bag_item_encryption(encryption_options, &block)
84
- - with_chef_data_bag(name)
85
- - Takes a block, though this is not noted in the method signature.
86
-
87
-
88
-
89
- get_private_key(name)
90
-
91
-
92
- ### RSpec matchers
93
-
94
- These are used with `expect_recipe` or `expect_converge`:
95
-
96
- ```ruby
97
- expect_recipe {
98
- file "/tmp/a_file.json" do
99
- content "Very important content."
100
- end
101
- }.to be_idempotent.and emit_no_warnings_or_errors
102
- ```
103
-
104
- `be_idempotent`
105
-
106
- - Runs the provided recipe *again* (`expect_(recipe|converge)` ran it the first time) and asks the Chef run if it updated anything (using `updated?`, which appears to be defined on `Chef::Resource` instead of `Chef::Client`, so there's some clarification to be done there); the matcher is satisfied if the answer is "no."
107
-
108
-
109
- `emit_no_warnings_or_errors`
110
-
111
- - Greps the Chef client run's log output for WARN/ERROR lines; matcher is satisfied if there aren't any.
112
-
113
- `have_updated`
114
-
115
- - Sifts the recipe's event stream(!) to determine if any resources were updated; matcher is satisfied is the answer is "yes."
116
- - This is *not* the opposite of `be_idempotent`.
117
-
118
- `partially_match`
119
-
120
- - TBD